🔨 Add molecule
parent
98237aab2f
commit
9a79dd8d63
|
@ -0,0 +1,19 @@
|
||||||
|
# Molecule managed
|
||||||
|
|
||||||
|
{% if item.registry is defined %}
|
||||||
|
FROM {{ item.registry.url }}/{{ item.image }}
|
||||||
|
{% else %}
|
||||||
|
FROM {{ item.image }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if item.env is defined %}
|
||||||
|
{% for var, value in item.env.items() %}
|
||||||
|
{% if value %}
|
||||||
|
ENV {{ var }} {{ value }}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y python3 sudo bash ca-certificates iproute2 python-apt-common \
|
||||||
|
&& apt-get clean
|
|
@ -0,0 +1,38 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
scenario:
|
||||||
|
test_sequence:
|
||||||
|
- dependency
|
||||||
|
- syntax
|
||||||
|
- create
|
||||||
|
- prepare
|
||||||
|
- converge
|
||||||
|
- idempotence
|
||||||
|
- verify
|
||||||
|
- destroy
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
role_name_check: 1
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
config_options:
|
||||||
|
defaults:
|
||||||
|
deprecation_warnings: false
|
||||||
|
callback_whitelist: timer,profile_tasks
|
||||||
|
fact_caching: jsonfile
|
||||||
|
fact_caching_connection: ./cache
|
||||||
|
forks: 100
|
||||||
|
connection:
|
||||||
|
pipelining: true
|
||||||
|
playbooks:
|
||||||
|
converge: ../_shared/converge.yml
|
||||||
|
prepare: ../_shared/prepare.yml
|
||||||
|
verify: ../_shared/verify.yml
|
||||||
|
inventory:
|
||||||
|
group_vars:
|
||||||
|
all:
|
||||||
|
is_dev: true
|
||||||
|
links:
|
||||||
|
group_vars: ../_shared/inventory/group_vars/
|
||||||
|
verifier:
|
||||||
|
name: ansible
|
|
@ -0,0 +1,34 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
# Note: master must be converged first
|
||||||
|
- name: Converge master
|
||||||
|
hosts: master
|
||||||
|
gather_facts: true
|
||||||
|
tasks:
|
||||||
|
- name: Include role
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: "hanxhx.mysql"
|
||||||
|
|
||||||
|
- name: COPY | Deploy first dump
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: files/import1.sql
|
||||||
|
dest: /tmp/import1.sql
|
||||||
|
mode: 0644
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
|
||||||
|
- name: MYSQL_DB | Import first dump
|
||||||
|
community.mysql.mysql_db:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: import
|
||||||
|
target: /tmp/import1.sql
|
||||||
|
login_unix_socket: "/run/mysqld/mysqld.sock"
|
||||||
|
loop: "{{ mariadb_databases }}"
|
||||||
|
|
||||||
|
- name: Converge slave
|
||||||
|
hosts: slave
|
||||||
|
gather_facts: true
|
||||||
|
tasks:
|
||||||
|
- name: Include role
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: "hanxhx.mysql"
|
|
@ -9,4 +9,3 @@ INSERT IGNORE INTO `user` (`id`,`email`) VALUES (11,"vitae.dolor@rutrumnon.net")
|
||||||
INSERT IGNORE INTO `user` (`id`,`email`) VALUES (21,"aliquam@atpretium.co.uk"),(22,"cursus@sapienmolestie.edu"),(23,"ornare.Fusce@pede.ca"),(24,"at@estac.co.uk"),(25,"sed@risusodioauctor.ca"),(26,"sit.amet.consectetuer@necorciDonec.com"),(27,"Nulla@infaucibus.co.uk"),(28,"tempus.scelerisque@utlacusNulla.com"),(29,"pellentesque.a@nostraper.com"),(30,"libero.et.tristique@Nunclaoreet.co.uk");
|
INSERT IGNORE INTO `user` (`id`,`email`) VALUES (21,"aliquam@atpretium.co.uk"),(22,"cursus@sapienmolestie.edu"),(23,"ornare.Fusce@pede.ca"),(24,"at@estac.co.uk"),(25,"sed@risusodioauctor.ca"),(26,"sit.amet.consectetuer@necorciDonec.com"),(27,"Nulla@infaucibus.co.uk"),(28,"tempus.scelerisque@utlacusNulla.com"),(29,"pellentesque.a@nostraper.com"),(30,"libero.et.tristique@Nunclaoreet.co.uk");
|
||||||
INSERT IGNORE INTO `user` (`id`,`email`) VALUES (31,"dolor.sit.amet@Donecelementum.net"),(32,"ornare@massanonante.ca"),(33,"quam.elementum@semper.net"),(34,"Duis.ac.arcu@Integermollis.com"),(35,"magna.Sed.eu@magnaPraesent.co.uk"),(36,"Mauris.eu.turpis@mattis.ca"),(37,"ornare.facilisis.eget@urna.net"),(38,"Sed.diam.lorem@fringilla.co.uk"),(39,"pellentesque.Sed.dictum@Donec.edu"),(40,"faucibus.Morbi@nuncid.com");
|
INSERT IGNORE INTO `user` (`id`,`email`) VALUES (31,"dolor.sit.amet@Donecelementum.net"),(32,"ornare@massanonante.ca"),(33,"quam.elementum@semper.net"),(34,"Duis.ac.arcu@Integermollis.com"),(35,"magna.Sed.eu@magnaPraesent.co.uk"),(36,"Mauris.eu.turpis@mattis.ca"),(37,"ornare.facilisis.eget@urna.net"),(38,"Sed.diam.lorem@fringilla.co.uk"),(39,"pellentesque.Sed.dictum@Donec.edu"),(40,"faucibus.Morbi@nuncid.com");
|
||||||
INSERT IGNORE INTO `user` (`id`,`email`) VALUES (41,"ullamcorper@at.co.uk"),(42,"nec.ante.blandit@utcursus.edu"),(43,"diam.vel.arcu@egestasFuscealiquet.com"),(44,"ridiculus@musAeneaneget.com"),(45,"ad@turpisvitaepurus.ca"),(46,"ultrices.posuere.cubilia@purusMaecenas.net"),(47,"luctus@libero.org"),(48,"mi@elitNulla.com"),(49,"elementum@ipsumdolorsit.edu"),(50,"orci@Donec.co.uk");
|
INSERT IGNORE INTO `user` (`id`,`email`) VALUES (41,"ullamcorper@at.co.uk"),(42,"nec.ante.blandit@utcursus.edu"),(43,"diam.vel.arcu@egestasFuscealiquet.com"),(44,"ridiculus@musAeneaneget.com"),(45,"ad@turpisvitaepurus.ca"),(46,"ultrices.posuere.cubilia@purusMaecenas.net"),(47,"luctus@libero.org"),(48,"mi@elitNulla.com"),(49,"elementum@ipsumdolorsit.edu"),(50,"orci@Donec.co.uk");
|
||||||
|
|
|
@ -5,3 +5,4 @@ mariadb_extra_configuration:
|
||||||
innodb_commit_concurrency: 0
|
innodb_commit_concurrency: 0
|
||||||
mariadb_install_xtrabackup_package: true
|
mariadb_install_xtrabackup_package: true
|
||||||
mariadb_slow_query_log_enabled: true
|
mariadb_slow_query_log_enabled: true
|
||||||
|
mariadb_debug_role: true
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
mariadb_use_galera: true
|
||||||
|
mariadb_galera_members: "{{ groups['galera'] }}"
|
|
@ -15,6 +15,5 @@ mariadb_users:
|
||||||
host: '%'
|
host: '%'
|
||||||
mariadb_replication_master: true
|
mariadb_replication_master: true
|
||||||
mariadb_replication_slave: false
|
mariadb_replication_slave: false
|
||||||
mariadb_server_id: 1
|
|
||||||
|
|
||||||
# vim: set ft=yaml :
|
# vim: set ft=yaml :
|
|
@ -4,7 +4,8 @@ mariadb_replication_master: false
|
||||||
mariadb_replication_slave: true
|
mariadb_replication_slave: true
|
||||||
mariadb_replication_user: 'replication'
|
mariadb_replication_user: 'replication'
|
||||||
mariadb_replication_password: '1a2b3c'
|
mariadb_replication_password: '1a2b3c'
|
||||||
mariadb_server_id: 2
|
|
||||||
mariadb_slave_ignore_db: ['norepl']
|
mariadb_slave_ignore_db: ['norepl']
|
||||||
|
mariadb_slave_import_from: "{{ groups['master'][0] }}"
|
||||||
|
mariadb_replication_host: "{{ groups['master'][0] }}"
|
||||||
|
|
||||||
# vim: set ft=yaml :
|
# vim: set ft=yaml :
|
|
@ -0,0 +1,21 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: Prepare hosts
|
||||||
|
hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
tasks:
|
||||||
|
- name: APT | Install some packages
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: "{{ p }}"
|
||||||
|
update_cache: true
|
||||||
|
cache_valid_time: 3600
|
||||||
|
vars:
|
||||||
|
p: ['ca-certificates', 'curl', 'rsync', 'rsyslog', 'ssh', 'strace', 'vim']
|
||||||
|
|
||||||
|
- name: SERVICE | Ensure daemon are started
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: started
|
||||||
|
loop:
|
||||||
|
- rsyslog
|
||||||
|
- ssh
|
|
@ -0,0 +1,32 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: Verify slave
|
||||||
|
hosts: slave
|
||||||
|
gather_facts: false
|
||||||
|
tasks:
|
||||||
|
- name: MYSQL_REPLICATION | Get slave infos
|
||||||
|
community.mysql.mysql_replication:
|
||||||
|
mode: getreplica
|
||||||
|
register: slave
|
||||||
|
|
||||||
|
- name: ASSERT | If slave threads are not running
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- slave.Slave_IO_Running == 'Yes'
|
||||||
|
- slave.Slave_SQL_Running == 'Yes'
|
||||||
|
fail_msg: "Slave issue, please check"
|
||||||
|
success_msg: "Slave is running"
|
||||||
|
|
||||||
|
- name: Check replication data
|
||||||
|
community.mysql.mysql_query:
|
||||||
|
login_db: testrepl
|
||||||
|
query: 'SELECT COUNT(*) AS c FROM user'
|
||||||
|
login_unix_socket: /run/mysqld/mysqld.sock
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: ASSERT | Check replication data
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- result.query_result.0.0.c == 50
|
||||||
|
fail_msg: "Replication data is not correct"
|
||||||
|
success_msg: "Replication data is correct"
|
|
@ -0,0 +1,46 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
- name: debian12-master1
|
||||||
|
image: dokken/debian-12
|
||||||
|
command: /lib/systemd/systemd
|
||||||
|
dockerfile: ../_shared/Dockerfile.j2
|
||||||
|
capabilities:
|
||||||
|
- SYS_ADMIN
|
||||||
|
cgroupns_mode: host
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||||
|
privileged: true
|
||||||
|
networks:
|
||||||
|
- name: "00-molecule-d12-ms"
|
||||||
|
ipv4_address: '172.16.50.1'
|
||||||
|
docker_networks:
|
||||||
|
- name: "00-molecule-d12-ms"
|
||||||
|
ipam_config:
|
||||||
|
- subnet: "172.16.50.0/24"
|
||||||
|
gateway: "172.16.50.254"
|
||||||
|
groups:
|
||||||
|
- master
|
||||||
|
|
||||||
|
- name: debian12-slave1
|
||||||
|
image: dokken/debian-12
|
||||||
|
command: /lib/systemd/systemd
|
||||||
|
dockerfile: ../_shared/Dockerfile.j2
|
||||||
|
capabilities:
|
||||||
|
- SYS_ADMIN
|
||||||
|
cgroupns_mode: host
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||||
|
privileged: true
|
||||||
|
networks:
|
||||||
|
- name: "00-molecule-d12-ms"
|
||||||
|
ipv4_address: '172.16.50.2'
|
||||||
|
groups:
|
||||||
|
- slave
|
||||||
|
|
||||||
|
provisioner:
|
||||||
|
inventory:
|
||||||
|
host_vars: ~
|
||||||
|
group_vars:
|
||||||
|
master: ~
|
||||||
|
slave: ~
|
|
@ -1,7 +0,0 @@
|
||||||
---
|
|
||||||
|
|
||||||
mariadb_use_galera: true
|
|
||||||
mariadb_galera_members:
|
|
||||||
- '{% if is_docker %}docker-{% else %}vbox-{% endif %}{{ ansible_distribution_release }}-{{ mariadb_origin }}-galera-1'
|
|
||||||
- '{% if is_docker %}docker-{% else %}vbox-{% endif %}{{ ansible_distribution_release }}-{{ mariadb_origin }}-galera-2'
|
|
||||||
- '{% if is_docker %}docker-{% else %}vbox-{% endif %}{{ ansible_distribution_release }}-{{ mariadb_origin }}-galera-3'
|
|
Loading…
Reference in New Issue