2022-11-18 07:51:49 +00:00
|
|
|
- name: Install MariaDB Server
|
|
|
|
ansible.builtin.apt:
|
|
|
|
name: mariadb-server
|
2020-01-17 05:46:06 +00:00
|
|
|
state: present
|
2019-01-02 05:04:01 +00:00
|
|
|
|
2022-11-19 10:02:28 +00:00
|
|
|
- name: Change the bind-address to allow Docker
|
|
|
|
ansible.builtin.lineinfile:
|
|
|
|
path: /etc/mysql/mariadb.conf.d/50-server.cnf
|
|
|
|
regex: "^bind-address"
|
|
|
|
line: "bind-address = 0.0.0.0"
|
|
|
|
notify: restart_mariadb
|
|
|
|
|
|
|
|
- name: Install MySQL Support for Python 3
|
|
|
|
ansible.builtin.apt:
|
|
|
|
name: python3-pymysql
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Create MariaDB databases
|
|
|
|
community.mysql.mysql_db:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
state: present
|
|
|
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
|
|
|
loop: "{{ databases }}"
|
|
|
|
no_log: "{{ item.pass is defined }}"
|
|
|
|
|
|
|
|
- name: Create MariaDB users
|
|
|
|
community.mysql.mysql_user:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
password: "{{ item.pass }}"
|
|
|
|
host: '%'
|
|
|
|
state: present
|
|
|
|
priv: "{{ item.name }}.*:ALL"
|
|
|
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
|
|
|
loop: "{{ databases }}"
|
|
|
|
no_log: "{{ item.pass is defined }}"
|
|
|
|
|
2022-11-18 07:51:49 +00:00
|
|
|
- name: Create webserver docker-compose directory
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: "{{ webserver_root }}"
|
|
|
|
state: directory
|
|
|
|
mode: 0600
|
2019-01-02 05:04:01 +00:00
|
|
|
|
2022-11-18 07:51:49 +00:00
|
|
|
- name: Install webserver docker-compose.yml
|
|
|
|
ansible.builtin.copy:
|
|
|
|
src: docker-compose.yml
|
|
|
|
dest: "{{ webserver_root }}/docker-compose.yml"
|
|
|
|
mode: 0600
|
|
|
|
notify: composeup_webserver
|
2019-01-02 05:04:01 +00:00
|
|
|
|
2022-11-18 07:51:49 +00:00
|
|
|
- name: Install docker-compose .env
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: compose-env.j2
|
|
|
|
dest: "{{ webserver_root }}/.env"
|
|
|
|
mode: 0600
|
|
|
|
notify: composeup_webserver
|
2022-11-19 10:02:28 +00:00
|
|
|
|
|
|
|
- name: Allow MariaDB database connections
|
|
|
|
community.general.ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 3306
|
|
|
|
proto: tcp
|
|
|
|
src: "{{ item }}"
|
|
|
|
loop: "{{ mariadb_trust }}"
|
|
|
|
|
|
|
|
- name: Add HTTP and HTTPS firewall rule
|
|
|
|
community.general.ufw:
|
|
|
|
rule: allow
|
|
|
|
port: "{{ item }}"
|
|
|
|
proto: tcp
|
|
|
|
loop:
|
|
|
|
- "80"
|
|
|
|
- "443"
|