Use FQDN Ansible modules

This commit is contained in:
Emilien Mantel
2021-09-02 17:21:56 +02:00
parent 91e54c36e4
commit befa982e07
15 changed files with 80 additions and 78 deletions

View File

@@ -5,16 +5,16 @@
pre_tasks:
- name: SETUP | Get facts
setup:
ansible.builtin.setup:
register: s
- name: DEBUG | Show facts
debug:
ansible.builtin.debug:
var: s
tasks:
- name: APT | Install some packages
apt:
ansible.builtin.apt:
name: "{{ p }}"
update_cache: true
cache_valid_time: 3600
@@ -22,7 +22,7 @@
p: ['ca-certificates', 'curl', 'strace', 'rsyslog', 'vim']
- name: SERVICE | Ensure rsyslog is started
service:
ansible.builtin.service:
name: rsyslog
state: started
@@ -32,7 +32,7 @@
tasks:
- name: COPY | Deploy first dump
copy:
ansible.builtin.copy:
src: import1.sql
dest: /tmp/import1.sql
mode: 0644
@@ -41,7 +41,7 @@
register: c
- name: MYSQL_DB | Import first dump
mysql_db:
community.mysql.mysql_db:
name: "{{ item }}"
state: import
target: /tmp/import1.sql
@@ -55,14 +55,14 @@
pre_tasks:
- name: SHELL | Get master IP
shell: set -o pipefail && getent hosts {{ ansible_hostname | replace ('slave', 'master') }} | cut -d ' ' -f 1
ansible.builtin.shell: set -o pipefail && getent hosts {{ ansible_hostname | replace ('slave', 'master') }} | cut -d ' ' -f 1
args:
executable: /bin/bash
register: ip
changed_when: false
- name: SET_FACT | Apply some configuration
set_fact:
ansible.builtin.set_fact:
# MariaDB don't read /etc/hosts (from vagrant host plugin)
mariadb_replication_host: "{{ ip.stdout }}"
# Need this to use vagrant 'delegate_to'
@@ -75,7 +75,7 @@
- block:
- name: COPY | Deploy dump
copy:
ansible.builtin.copy:
src: import2.sql
dest: /tmp/import2.sql
mode: 0644
@@ -85,7 +85,7 @@
register: c
- name: MYSQL_DB | Import another dump
mysql_db:
community.mysql.mysql_db:
name: "{{ item }}"
state: import
target: /tmp/import2.sql
@@ -96,12 +96,12 @@
delegate_to: "{{ mariadb_slave_import_from }}"
- name: MYSQL_REPLICATION | Get slave infos
mysql_replication:
community.mysql.mysql_replication:
mode: getslave
register: slave
- name: FAIL | if slave threads are not running
fail:
ansible.builtin.fail:
msg: "Slave issue"
when: slave.Slave_IO_Running != 'Yes' or slave.Slave_SQL_Running != 'Yes'
@@ -109,12 +109,12 @@
pre_tasks:
- name: APT_REPOSITORY | Force galera-3 on Buster + MariaDB from Debian repository (prevent crashes)
set_fact:
ansible.builtin.set_fact:
mariadb_galera_package_name: 'galera-3'
when: ansible_distribution_release == 'buster' and mariadb_origin == 'default'
- name: SET_FACT | Apply some configuration
set_fact:
ansible.builtin.set_fact:
mariadb_galera_primary_node: '{% if is_docker %}docker-{% else %}vbox-{% endif %}{{ ansible_distribution_release }}-{{ mariadb_origin }}-galera-1'
mariadb_wsrep_node_address: "{{ '127.0.0.1' if is_docker else ansible_eth1.ipv4.address }}"