siotp/sio2/AP/apdb.yml
Alhassane Kone 9e35ca41c6 maj
2023-11-30 08:42:38 +01:00

53 lines
1.3 KiB
YAML

---
- name: apdb
hosts: web
become: yes
tasks:
- name: 1. Installer mariadb
apt:
name:
- mariadb-server
- python3-pymysql
state: present
- name: 2. s'assurer que mariadb est en fonctionnement
service:
name: mariadb
state: started
- name: 3. Creer un utilisateur et lui attribuer tous les droits
community.mysql.mysql_user:
name: admin
password: admin
priv: '*.*:ALL,GRANT'
state: present
login_unix_socket: /var/run/mysqld/mysqld.sock
- name: 4. Creation de la base de donnee 'sdis2023'
community.mysql.mysql_db:
name: sdis2023
state: present
login_unix_socket: /var/run/mysqld/mysqld.sock
- name: 5. copier la base de donnée sur l'hôte distant
copy:
src: sdis2023.sql
dest: /tmp/sdis2023.sql
- name: 6. Restore la base de donnée
community.mysql.mysql_db:
name: sdis2023
state: import
target: /tmp/sdis2023.sql
login_unix_socket: /var/run/mysqld/mysqld.sock
# - name: 5. Dump multiple databases
#community.mysql.mysql_db:
#state: dump
#name:
#- sdis2023
#target: sdis2023.sql
#login_unix_socket: /var/run/mysqld/mysqld.sock