ansible-mysql/tests/test.yml

114 lines
2.8 KiB
YAML
Raw Normal View History

2015-07-12 17:15:59 +07:00
---
- hosts: all
gather_facts: false
pre_tasks:
- name: SETUP | Get facts
setup:
register: s
- name: DEBUG | Show facts
debug:
var: s
tasks:
- name: APT | Install some packages
apt:
name: "{{ p }}"
2021-09-01 18:36:46 +07:00
update_cache: true
cache_valid_time: 3600
vars:
p: ['ca-certificates', 'curl', 'strace', 'vim']
2015-08-09 02:34:17 +07:00
- hosts: master
2015-08-09 02:34:17 +07:00
roles:
- ../../
tasks:
- name: COPY | Deploy first dump
copy:
src: import1.sql
dest: /tmp/import1.sql
2021-09-01 18:47:31 +07:00
mode: 0644
owner: root
group: root
register: c
- name: MYSQL_DB | Import first dump
mysql_db:
name: "{{ item }}"
state: import
target: /tmp/import1.sql
2021-09-01 18:31:11 +07:00
login_unix_socket: "{{ mariadb_socket }}"
2019-04-12 14:38:42 +07:00
loop: ['testrepl', 'norepl']
when: c.changed
2021-09-01 18:47:31 +07:00
tags:
- skip_ansible_lint
2015-08-09 02:34:17 +07:00
- hosts: slave
pre_tasks:
- name: SHELL | Get master IP
2021-09-01 18:47:31 +07:00
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:
2018-03-18 00:47:35 +07:00
# MariaDB don't read /etc/hosts (from vagrant host plugin)
2018-03-17 23:28:54 +07:00
mariadb_replication_host: "{{ ip.stdout }}"
# Need this to use vagrant 'delegate_to'
2018-03-17 23:28:54 +07:00
mariadb_slave_import_from: "{{ ansible_hostname | replace ('slave', 'master') }}"
2015-08-09 02:34:17 +07:00
roles:
- ../../
tasks:
- block:
2021-09-01 18:36:46 +07:00
- name: COPY | Deploy dump
copy:
src: import2.sql
dest: /tmp/import2.sql
2021-09-01 18:47:31 +07:00
mode: 0644
owner: root
group: root
2021-09-01 18:36:46 +07:00
delegate_to: "{{ mariadb_slave_import_from }}"
register: c
- name: MYSQL_DB | Import another dump
mysql_db:
name: "{{ item }}"
state: import
target: /tmp/import2.sql
login_unix_socket: "{{ mariadb_socket }}"
loop: ['testrepl', 'norepl']
when: c.changed
2018-03-17 23:28:54 +07:00
delegate_to: "{{ mariadb_slave_import_from }}"
- name: MYSQL_REPLICATION | Get slave infos
mysql_replication:
mode: getslave
register: slave
- name: FAIL | if slave threads are not running
fail:
msg: "Slave issue"
when: slave.Slave_IO_Running != 'Yes' or slave.Slave_SQL_Running != 'Yes'
2015-08-09 02:34:17 +07:00
- hosts: galera
pre_tasks:
- name: SET_FACT | Apply some configuration
set_fact:
2019-08-07 22:41:45 +07:00
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 }}"
2019-08-07 22:41:45 +07:00
mariadb_version: '10.3'
roles:
- ../../