Ansible version finalisée
This commit is contained in:
parent
d9bb729bc1
commit
9f0082b1f2
10
Mission2/ansible/mysql-dump.yml
Normal file
10
Mission2/ansible/mysql-dump.yml
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
- name: mysql dump playbook
|
||||
hosts: test
|
||||
become: yes
|
||||
become_method: sudo
|
||||
remote_user: root
|
||||
|
||||
roles:
|
||||
- mysql_dump
|
||||
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
- name: Tomcat playbook
|
||||
- name: MariaDB playbook
|
||||
hosts: test
|
||||
become: yes
|
||||
become_method: sudo
|
6
Mission2/ansible/roles/mysql/handlers/main.yml
Normal file
6
Mission2/ansible/roles/mysql/handlers/main.yml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
- name: restart mariadb
|
||||
service:
|
||||
name: mariadb
|
||||
state: restarted
|
||||
|
49
Mission2/ansible/roles/mysql/tasks/main.yml
Normal file
49
Mission2/ansible/roles/mysql/tasks/main.yml
Normal file
@ -0,0 +1,49 @@
|
||||
---
|
||||
- name: "MYSQL - update cache"
|
||||
apt:
|
||||
update_cache: yes
|
||||
|
||||
- name: "MYSQL - installation"
|
||||
apt:
|
||||
name: mariadb-server
|
||||
state: latest
|
||||
|
||||
- name: "PYTHON3 - installation"
|
||||
apt:
|
||||
name: python3-pymysql
|
||||
state: latest
|
||||
|
||||
- name: "MYSQL - démarrage de mysql"
|
||||
service:
|
||||
name: "mysqld"
|
||||
state: started
|
||||
enabled: yes
|
||||
|
||||
- name: "MYSQL - creation base de données"
|
||||
community.mysql.mysql_db:
|
||||
name: sdis29
|
||||
state: present
|
||||
login_unix_socket: /var/run/mysqld/mysqld.sock
|
||||
check_implicit_admin: yes
|
||||
|
||||
- name: "MYSQL - creation utilisateur"
|
||||
mysql_user:
|
||||
name: "dev"
|
||||
password: "Azerty1+"
|
||||
priv: "*.*:ALL"
|
||||
host: "localhost"
|
||||
login_unix_socket: /var/run/mysqld/mysqld.sock
|
||||
|
||||
- name: copie de la base de donnée
|
||||
copy:
|
||||
src: ~/sauvegarde/sql/sdis29-dump.sql
|
||||
dest: /tmp/
|
||||
|
||||
- name: Importation de la base de données
|
||||
mysql_db:
|
||||
name: sdis29
|
||||
state: import
|
||||
target: /tmp/sdis29.sql
|
||||
login_user: dev
|
||||
login_password: Azerty1+
|
||||
login_unix_socket: /var/run/mysqld/mysqld.sock
|
4
Mission2/ansible/roles/mysql_dump/handlers/main.yml
Normal file
4
Mission2/ansible/roles/mysql_dump/handlers/main.yml
Normal file
@ -0,0 +1,4 @@
|
||||
- name: Restart mysqld
|
||||
ansible.builtin.service:
|
||||
name: mysqld
|
||||
state: restarted
|
15
Mission2/ansible/roles/mysql_dump/tasks/main.yml
Normal file
15
Mission2/ansible/roles/mysql_dump/tasks/main.yml
Normal file
@ -0,0 +1,15 @@
|
||||
- name: exportation de la base de données
|
||||
mysql_db:
|
||||
name: sdis29
|
||||
state: dump
|
||||
target: /tmp/sdis29-dump.sql
|
||||
login_user: dev
|
||||
login_password: Azerty1+
|
||||
login_unix_socket: /var/run/mysqld/mysqld.sock
|
||||
|
||||
- name: importation du dump de la base de donnée
|
||||
ansible.builtin.fetch:
|
||||
src: /tmp/sdis29-dump.sql
|
||||
dest: /root/sauvegarde/sql/
|
||||
flat: yes
|
||||
|
14
Mission2/ansible/roles/mysql_inject/tasks/main.yml
Normal file
14
Mission2/ansible/roles/mysql_inject/tasks/main.yml
Normal file
@ -0,0 +1,14 @@
|
||||
- name: copie de la base de donnée
|
||||
copy:
|
||||
src: sdis29.sql
|
||||
dest: /tmp
|
||||
|
||||
- name: Importation de la base de données
|
||||
mysql_db:
|
||||
name: sdis29
|
||||
state: import
|
||||
target: /tmp/sdis29.sql
|
||||
login_user: dev
|
||||
login_password: Azerty1+
|
||||
login_unix_socket: /var/run/mysqld/mysqld.sock
|
||||
|
@ -1,6 +0,0 @@
|
||||
|
||||
|
||||
- name: exportation du dump
|
||||
copy:
|
||||
src: db-sauv.sql.gz
|
||||
dest: /tmp
|
@ -1,5 +0,0 @@
|
||||
- name: Restoration la base de données
|
||||
community.mysql.mysql_db:
|
||||
name: my_db
|
||||
state: import
|
||||
target: /tmp/db-sauv.sql.gz
|
@ -1,22 +0,0 @@
|
||||
---
|
||||
# handlers file for mariadb
|
||||
- name: set mariadb log selinux
|
||||
sefcontext:
|
||||
target: '/var/log/mariadb(/.*)?'
|
||||
setype: mysqld_log_t
|
||||
state: present
|
||||
- name: restart mariadb server
|
||||
systemd:
|
||||
name: "{{ mariadb_service }}"
|
||||
state: restarted
|
||||
enabled: yes
|
||||
|
||||
- name: Remove test database priviledges
|
||||
command: mysql -u root -p{{ mysql_root_password }} -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'"
|
||||
|
||||
- name: Flush Priviliges
|
||||
command: mysql -u root -p{{ mysql_root_password }} -e "FLUSH PRIVILEGES"
|
||||
|
||||
- name: Update repo cache
|
||||
apt:
|
||||
update_cache: yes
|
@ -1,39 +0,0 @@
|
||||
- name: "[MYSQL] - update cache"
|
||||
apt:
|
||||
update_cache: yes
|
||||
|
||||
- name: "[MYSQL] - install"
|
||||
apt:
|
||||
name: mariadb-server
|
||||
state: latest
|
||||
|
||||
- name: "[Python] - install"
|
||||
apt:
|
||||
name: python
|
||||
state: latest
|
||||
|
||||
- name: "[MYSQL] - start mysql"
|
||||
service:
|
||||
name: "mysqld"
|
||||
state: started
|
||||
enabled: yes
|
||||
|
||||
- name: "[MYSQL] - create database"
|
||||
community.mysql.mysql_db:
|
||||
name:
|
||||
- sdis29
|
||||
state: present
|
||||
|
||||
- name: "[MYSQL] - create user"
|
||||
mysql_user:
|
||||
name: "dev"
|
||||
password: "Azerty1+"
|
||||
priv: "*.*:ALL"
|
||||
host: "127.0.0.1"
|
||||
become: yes
|
||||
|
||||
- name: Restoration la base de données
|
||||
community.mysql.mysql_db:
|
||||
name: my_db
|
||||
state: import
|
||||
target: /tmp/db-sauv.sql.gz
|
@ -1,8 +0,0 @@
|
||||
---
|
||||
- hosts: all
|
||||
|
||||
tasks:
|
||||
- name: install openjdk-17
|
||||
apt :
|
||||
name: openjdk-17-jdk
|
||||
state: present
|
Loading…
x
Reference in New Issue
Block a user