From 9019c0dbe75d41a1b3a2a7f9d82afa8bcdf9f149 Mon Sep 17 00:00:00 2001 From: Elam Monnot Date: Mon, 30 Jan 2023 10:36:52 +0100 Subject: [PATCH] modification de lb-bd --- s-lb-bd.yml | 68 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 21 deletions(-) diff --git a/s-lb-bd.yml b/s-lb-bd.yml index c31f907..b079fa6 100644 --- a/s-lb-bd.yml +++ b/s-lb-bd.yml @@ -1,24 +1,50 @@ --- - - hosts: localhost - connection: local - vars: - maria_dbhost: "192.168.102.254" - maria_dbname: "wordpress" - maria_dbuser: "wp" - maria_dbpasswd: "wp" +- hosts: all + become: true + tasks: + - name: modules python pour + apt: + name: python3-pymysql + state: present - roles: - - base - - goss - - post - #- s-lb-bd-ab - - mariadb-ab -# - role: db-user -# cli_ip: "192.168.102.1" -# - role: db-user -# cli_ip: "192.168.102.2" -# - role: db-user -# cli_ip: "192.168.102.3" - - snmp-agent -# - post + - name: install mariadb-server + apt: + name: mariadb-server + state: present + + - name: Cree Bd wordpress + mysql_db: + db: wordpressdb + login_unix_socket: /var/run/mysqld/mysqld.sock + state: present + + - name: Ouvre port 3306 mariadb-server + replace: + path: /etc/mysql/mariadb.conf.d/50-server.cnf + regexp: '^bind-address.*' + replace: '#bind-adress = 127.0.0.1' + backup: yes + notify: restart mariadb + + - name: Create MySQL user for wordpress + mysql_user: + name: wordpressuser + password: wordpresspasswd + priv: "wordpressdb.*:ALL" + host: '%' + state: present + login_unix_socket: /var/run/mysqld/mysqld.sock + + handlers: + - name: restart mariadb + ansible.builtin.service: + name: mariadb + state: restarted + + roles: + - base + - goss + - post + - mariadb-ab + - snmp-agent