Ansible version finalisée

This commit is contained in:
“cameron.desrayaud” 2021-12-15 09:56:20 +01:00
parent d9bb729bc1
commit 9f0082b1f2
25 changed files with 99 additions and 81 deletions

View File

@ -0,0 +1,10 @@
---
- name: mysql dump playbook
hosts: test
become: yes
become_method: sudo
remote_user: root
roles:
- mysql_dump

View File

@ -1,5 +1,5 @@
--- ---
- name: Tomcat playbook - name: MariaDB playbook
hosts: test hosts: test
become: yes become: yes
become_method: sudo become_method: sudo

View File

@ -0,0 +1,6 @@
---
- name: restart mariadb
service:
name: mariadb
state: restarted

View 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

View File

@ -0,0 +1,4 @@
- name: Restart mysqld
ansible.builtin.service:
name: mysqld
state: restarted

View 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

View 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

View File

@ -1,6 +0,0 @@
- name: exportation du dump
copy:
src: db-sauv.sql.gz
dest: /tmp

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,8 +0,0 @@
---
- hosts: all
tasks:
- name: install openjdk-17
apt :
name: openjdk-17-jdk
state: present