Compare commits
No commits in common. "da3b0cb28b9276e95511d32d088e9276abeba6fe" and "d05c5d3086a4d54414a3ede38e866a2d71341615" have entirely different histories.
da3b0cb28b
...
d05c5d3086
@ -1,10 +0,0 @@
|
|||||||
- name: Install Gitea Server
|
|
||||||
hosts: all
|
|
||||||
become: true
|
|
||||||
vars_files:
|
|
||||||
- host_vars/gitea.yml
|
|
||||||
roles:
|
|
||||||
- base
|
|
||||||
- docker
|
|
||||||
- mariadb
|
|
||||||
- gitea
|
|
@ -1,45 +0,0 @@
|
|||||||
# base
|
|
||||||
allow_reboot: false
|
|
||||||
manage_network: false
|
|
||||||
|
|
||||||
users:
|
|
||||||
git:
|
|
||||||
uid: 1001
|
|
||||||
gid: 1001
|
|
||||||
home: true
|
|
||||||
|
|
||||||
# Import my GPG key for git signature verification
|
|
||||||
root_gpgkeys:
|
|
||||||
- name: kris@lamoureux.io
|
|
||||||
id: FBF673CEEC030F8AECA814E73EDA9C3441EDA925
|
|
||||||
|
|
||||||
# docker
|
|
||||||
docker_users:
|
|
||||||
- vagrant
|
|
||||||
|
|
||||||
docker_compose_env_nolog: false # dev only setting
|
|
||||||
docker_compose_deploy:
|
|
||||||
# Traefik
|
|
||||||
- name: traefik
|
|
||||||
url: https://github.com/krislamo/traefik
|
|
||||||
version: 398eb48d311db78b86abf783f903af4a1658d773
|
|
||||||
enabled: true
|
|
||||||
accept_newhostkey: true
|
|
||||||
trusted_keys:
|
|
||||||
- FBF673CEEC030F8AECA814E73EDA9C3441EDA925
|
|
||||||
env:
|
|
||||||
ENABLE: true
|
|
||||||
# Gitea
|
|
||||||
- name: gitea
|
|
||||||
url: https://github.com/krislamo/gitea
|
|
||||||
version: b0ce66f6a1ab074172eed79eeeb36d7e9011ef8f
|
|
||||||
env:
|
|
||||||
USER_UID: "{{ users.git.uid }}"
|
|
||||||
USER_GID: "{{ users.git.gid }}"
|
|
||||||
DB_PASSWD: "{{ gitea.DB_PASSWD }}"
|
|
||||||
|
|
||||||
# gitea
|
|
||||||
gitea:
|
|
||||||
DB_NAME: gitea
|
|
||||||
DB_USER: gitea
|
|
||||||
DB_PASSWD: password
|
|
@ -23,10 +23,9 @@ function ssh_connect {
|
|||||||
[yY])
|
[yY])
|
||||||
printf "[INFO]: Starting new vagrant SSH tunnel on PID "
|
printf "[INFO]: Starting new vagrant SSH tunnel on PID "
|
||||||
sudo -u "$USER" ssh -fNT -i "$PRIVATE_KEY" \
|
sudo -u "$USER" ssh -fNT -i "$PRIVATE_KEY" \
|
||||||
-L 22:localhost:22 \
|
-L 8443:localhost:8443 \
|
||||||
-L 80:localhost:80 \
|
-L 80:localhost:80 \
|
||||||
-L 443:localhost:443 \
|
-L 443:localhost:443 \
|
||||||
-L 8443:localhost:8443 \
|
|
||||||
-o UserKnownHostsFile=/dev/null \
|
-o UserKnownHostsFile=/dev/null \
|
||||||
-o StrictHostKeyChecking=no \
|
-o StrictHostKeyChecking=no \
|
||||||
vagrant@"$HOST_IP" 2>/dev/null
|
vagrant@"$HOST_IP" 2>/dev/null
|
||||||
|
@ -66,27 +66,13 @@
|
|||||||
mode: 0400
|
mode: 0400
|
||||||
when: authorized_keys is defined
|
when: authorized_keys is defined
|
||||||
|
|
||||||
- name: Create system user groups
|
|
||||||
ansible.builtin.group:
|
|
||||||
name: "{{ item.key }}"
|
|
||||||
gid: "{{ item.value.gid }}"
|
|
||||||
state: present
|
|
||||||
loop: "{{ users | dict2items }}"
|
|
||||||
loop_control:
|
|
||||||
label: "{{ item.key }}"
|
|
||||||
when: users is defined
|
|
||||||
|
|
||||||
- name: Create system users
|
- name: Create system users
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
name: "{{ item.key }}"
|
name: "{{ item.name }}"
|
||||||
state: present
|
state: present
|
||||||
uid: "{{ item.value.uid }}"
|
shell: "{{ item.shell | default('/bin/bash') }}"
|
||||||
group: "{{ item.value.gid }}"
|
create_home: "{{ item.home | default(false) }}"
|
||||||
shell: "{{ item.value.shell | default('/bin/bash') }}"
|
loop: "{{ users }}"
|
||||||
create_home: "{{ item.value.home | default(false) }}"
|
|
||||||
loop: "{{ users | dict2items }}"
|
|
||||||
loop_control:
|
|
||||||
label: "{{ item.key }}"
|
|
||||||
when: users is defined
|
when: users is defined
|
||||||
|
|
||||||
- name: Set authorized_keys for system users
|
- name: Set authorized_keys for system users
|
||||||
@ -94,9 +80,7 @@
|
|||||||
user: "{{ item.key }}"
|
user: "{{ item.key }}"
|
||||||
key: "{{ item.value.key }}"
|
key: "{{ item.value.key }}"
|
||||||
state: present
|
state: present
|
||||||
loop: "{{ users | dict2items }}"
|
loop: "{{ users }}"
|
||||||
loop_control:
|
|
||||||
label: "{{ item.key }}"
|
|
||||||
when: users is defined and item.value.key is defined
|
when: users is defined and item.value.key is defined
|
||||||
|
|
||||||
- name: Manage filesystem mounts
|
- name: Manage filesystem mounts
|
||||||
|
@ -1,23 +1,38 @@
|
|||||||
- name: Install MySQL module for Ansible
|
- name: Create Gitea directory
|
||||||
ansible.builtin.apt:
|
ansible.builtin.file:
|
||||||
name: python3-pymysql
|
path: "{{ gitea_root }}"
|
||||||
state: present
|
state: directory
|
||||||
|
|
||||||
- name: Create Gitea database
|
- name: Create Gitea database
|
||||||
community.mysql.mysql_db:
|
community.mysql.mysql_db:
|
||||||
name: "{{ gitea.DB_NAME }}"
|
name: "{{ gitea_dbname }}"
|
||||||
state: present
|
state: present
|
||||||
login_unix_socket: /var/run/mysqld/mysqld.sock
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
||||||
|
|
||||||
- name: Create Gitea database user
|
- name: Create Gitea database user
|
||||||
community.mysql.mysql_user:
|
community.mysql.mysql_user:
|
||||||
name: "{{ gitea.DB_USER }}"
|
name: "{{ gitea_dbuser }}"
|
||||||
password: "{{ gitea.DB_PASSWD }}"
|
password: "{{ gitea_dbpass }}"
|
||||||
host: '%'
|
host: '%'
|
||||||
state: present
|
state: present
|
||||||
priv: "{{ gitea.DB_NAME }}.*:ALL"
|
priv: "{{ gitea_dbname }}.*:ALL"
|
||||||
login_unix_socket: /var/run/mysqld/mysqld.sock
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
||||||
|
|
||||||
|
- name: Create git user
|
||||||
|
ansible.builtin.user:
|
||||||
|
name: git
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Git user uid
|
||||||
|
ansible.builtin.getent:
|
||||||
|
database: passwd
|
||||||
|
key: git
|
||||||
|
|
||||||
|
- name: Git user gid
|
||||||
|
ansible.builtin.getent:
|
||||||
|
database: group
|
||||||
|
key: git
|
||||||
|
|
||||||
- name: Create git's .ssh directory
|
- name: Create git's .ssh directory
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: /home/git/.ssh
|
path: /home/git/.ssh
|
||||||
@ -55,11 +70,28 @@
|
|||||||
dest: /usr/local/bin/gitea
|
dest: /usr/local/bin/gitea
|
||||||
mode: 0755
|
mode: 0755
|
||||||
|
|
||||||
|
- name: Install Gitea's docker-compose file
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: docker-compose.yml.j2
|
||||||
|
dest: "{{ gitea_root }}/docker-compose.yml"
|
||||||
|
notify: restart_gitea
|
||||||
|
|
||||||
|
- name: Install Gitea's docker-compose variables
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: compose-env.j2
|
||||||
|
dest: "{{ gitea_root }}/.env"
|
||||||
|
notify: restart_gitea
|
||||||
|
|
||||||
- name: Create Gitea's logging directory
|
- name: Create Gitea's logging directory
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
name: /var/log/gitea
|
name: /var/log/gitea
|
||||||
state: directory
|
state: directory
|
||||||
|
|
||||||
|
- name: Create Gitea's initial log file
|
||||||
|
ansible.builtin.file:
|
||||||
|
name: /var/log/gitea/gitea.log
|
||||||
|
state: touch
|
||||||
|
|
||||||
- name: Install Gitea's Fail2ban filter
|
- name: Install Gitea's Fail2ban filter
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: fail2ban-filter.conf.j2
|
src: fail2ban-filter.conf.j2
|
||||||
|
3
roles/mariadb/defaults/main.yml
Normal file
3
roles/mariadb/defaults/main.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
mariadb_trust:
|
||||||
|
- "172.16.0.0/12"
|
||||||
|
- "192.168.0.0/16"
|
@ -1,5 +0,0 @@
|
|||||||
- name: Restart MariaDB
|
|
||||||
ansible.builtin.service:
|
|
||||||
name: mariadb
|
|
||||||
state: restarted
|
|
||||||
listen: restart_mariadb
|
|
@ -3,20 +3,23 @@
|
|||||||
name: mariadb-server
|
name: mariadb-server
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Regather facts for the potentially new docker0 interface
|
- name: Change the bind-address to allow Docker
|
||||||
ansible.builtin.setup:
|
|
||||||
|
|
||||||
- name: Change the bind-address to allow from docker0
|
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/mysql/mariadb.conf.d/50-server.cnf
|
path: /etc/mysql/mariadb.conf.d/50-server.cnf
|
||||||
regex: "^bind-address"
|
regex: "^bind-address"
|
||||||
line: "bind-address = {{ ansible_facts.docker0.ipv4.address }}"
|
line: "bind-address = 0.0.0.0"
|
||||||
notify: restart_mariadb
|
register: mariadb_conf
|
||||||
|
|
||||||
- name: Allow database connections from Docker
|
- name: Restart MariaDB
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: mariadb
|
||||||
|
state: restarted
|
||||||
|
when: mariadb_conf.changed
|
||||||
|
|
||||||
|
- name: Allow database connections
|
||||||
community.general.ufw:
|
community.general.ufw:
|
||||||
rule: allow
|
rule: allow
|
||||||
port: "3306"
|
port: "3306"
|
||||||
proto: tcp
|
proto: tcp
|
||||||
src: "{{ item }}"
|
src: "{{ item }}"
|
||||||
loop: "{{ mariadb_trust | default(['172.16.0.0/12']) }}"
|
loop: "{{ mariadb_trust }}"
|
||||||
|
Loading…
Reference in New Issue
Block a user