-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
…te reset if it actually is in a failed state
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[defaults] | ||
inventory = ./inventory |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
|
||
- name: Creating Galera Test Scenario | ||
hosts: localhost | ||
vars: | ||
openstack_cloud: testing | ||
openstack_ssh_key: testing | ||
openstack_flavor_name: gp1a.4 | ||
openstack_image_name_deb12: debian-12-generic-amd64 | ||
openstack_image_name_deb11: debian-11-generic-amd64 | ||
openstack_network_name: network-k0stesting_generic | ||
tasks: | ||
- name: Include variables | ||
ansible.builtin.include_vars: "vars/main.yml" | ||
|
||
- name: Fetch Image (Deb12) | ||
openstack.cloud.image_info: | ||
cloud: "{{ openstack_cloud }}" | ||
image: "{{ openstack_image_name_deb12 }}" | ||
register: _openstack_image_deb12 | ||
|
||
- name: Fetch Flavor | ||
openstack.cloud.compute_flavor_info: | ||
cloud: "{{ openstack_cloud }}" | ||
name: "{{ openstack_flavor_name }}" | ||
register: _openstack_flavor | ||
|
||
- name: Fetch Network | ||
openstack.cloud.networks_info: | ||
cloud: "{{ openstack_cloud }}" | ||
name: "{{ openstack_network_name }}" | ||
register: _openstack_network | ||
|
||
- name: Ensure SSH Key exists | ||
openstack.cloud.keypair: | ||
name: "{{ openstack_ssh_key }}" | ||
cloud: "{{ openstack_cloud }}" | ||
public_key_file: "{{ ansible_env.HOME }}/.ssh/testing.pub" | ||
|
||
- name: Create Galera Instances | ||
openstack.cloud.server: | ||
name: "{{ item }}" | ||
state: present | ||
image: "{{ _openstack_image_deb12.images[0].id }}" | ||
key_name: "{{ openstack_ssh_key }}" | ||
flavor: "{{ _openstack_flavor.flavors[0].id }}" | ||
network: "{{ _openstack_network.networks[0].id }}" | ||
terminate_volume: true | ||
security_groups: | ||
- 1aa4fd40-1650-4151-84a7-3f5ecc4c4b23 | ||
cloud: "{{ openstack_cloud }}" | ||
metadata: | ||
group: "{{ the_role_name }}" | ||
auto_ip: false | ||
loop: | ||
- galera-1 | ||
- galera-2 | ||
- galera-3 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
|
||
- name: Destroying Test Scenario | ||
hosts: localhost | ||
vars: | ||
openstack_cloud: testing | ||
tasks: | ||
|
||
- name: Destroy Instances | ||
openstack.cloud.server: | ||
state: absent | ||
name: "{{ item }}" | ||
cloud: "{{ openstack_cloud }}" | ||
loop: | ||
- galera-1 | ||
- galera-2 | ||
- galera-3 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
plugin: openstack.cloud.openstack | ||
expand_hostvars: true | ||
private: true | ||
legacy_groups: false | ||
keyed_groups: | ||
- key: openstack.metadata.group | ||
default_value: galera | ||
parent_group: all | ||
leading_separator: false | ||
only_clouds: | ||
- testing |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
|
||
- name: Creating Test Environment for Galera | ||
hosts: mariadb_galera_cluster | ||
order: sorted | ||
pre_tasks: | ||
- name: Set hostname | ||
ansible.builtin.hostname: | ||
name: "{{ inventory_hostname }}" | ||
become: true | ||
- name: Reload facts | ||
ansible.builtin.setup: | ||
- name: Refresh Inventory | ||
ansible.builtin.meta: refresh_inventory | ||
- name: Set Hostnames | ||
ansible.builtin.lineinfile: | ||
path: /etc/hosts | ||
line: "{{ hostvars[item].ansible_facts.default_ipv4.address }} {{ hostvars[item].ansible_facts.fqdn }}" | ||
become: true | ||
loop: "{{ ansible_play_hosts }}" | ||
- name: Set Hostnames IPv6 | ||
ansible.builtin.lineinfile: | ||
path: /etc/hosts | ||
line: "{{ hostvars[item].ansible_facts.default_ipv6.address }} {{ hostvars[item].ansible_facts.fqdn }}" | ||
become: true | ||
loop: "{{ ansible_play_hosts }}" | ||
- name: Include variables | ||
ansible.builtin.include_vars: "vars/main.yml" | ||
- name: Load mysqld_exporter vars | ||
ansible.builtin.include_vars: | ||
file: mysqld_exporter.yml | ||
roles: | ||
- role: adit.mariadb_galera_cluster | ||
Check failure on line 33 in tests/playbook.yml GitHub Actions / pre-commit Lintsyntax-check[specific]
Check failure on line 33 in tests/playbook.yml GitHub Actions / Molecule Test (debian10, 3.10)syntax-check[specific]
Check failure on line 33 in tests/playbook.yml GitHub Actions / Molecule Test (debian11, 3.10)syntax-check[specific]
Check failure on line 33 in tests/playbook.yml GitHub Actions / Molecule Test (debian12, 3.10)syntax-check[specific]
Check failure on line 33 in tests/playbook.yml GitHub Actions / Molecule Test (rocky8, 3.10)syntax-check[specific]
Check failure on line 33 in tests/playbook.yml GitHub Actions / Molecule Test (rocky9, 3.10)syntax-check[specific]
Check failure on line 33 in tests/playbook.yml GitHub Actions / Molecule Test (ubuntu1804, 3.10)syntax-check[specific]
Check failure on line 33 in tests/playbook.yml GitHub Actions / Molecule Test (ubuntu2004, 3.10)syntax-check[specific]
Check failure on line 33 in tests/playbook.yml GitHub Actions / Molecule Test (ubuntu2204, 3.10)syntax-check[specific]
|
||
tags: | ||
- mariadb_galera_cluster | ||
|
||
- name: MySQL Clustercheck | ||
hosts: mariadb_galera_cluster | ||
order: sorted | ||
pre_tasks: | ||
- name: Include variables | ||
ansible.builtin.include_vars: "vars/main.yml" | ||
- name: Load mysqld_exporter vars | ||
ansible.builtin.include_vars: | ||
file: mysqld_exporter.yml | ||
roles: | ||
- role: adit.mysql_clustercheck | ||
tags: | ||
- mysql_clustercheck | ||
|
||
- name: MySQL Clustercheck | ||
hosts: mariadb_galera_cluster | ||
order: sorted | ||
pre_tasks: | ||
- name: Include variables | ||
ansible.builtin.include_vars: "vars/main.yml" | ||
- name: Load mysqld_exporter vars | ||
ansible.builtin.include_vars: | ||
file: mysqld_exporter.yml | ||
roles: | ||
- role: prometheus.prometheus.mysqld_exporter | ||
tags: | ||
- prometheus_mysqld_exporter |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--- | ||
|
||
- name: Linking role | ||
hosts: localhost | ||
vars: | ||
requirements_yml_file: '../requirements.yml' | ||
test_requirements_yml_file: './test_requirements.yml' | ||
tasks: | ||
- name: Include variables | ||
ansible.builtin.include_vars: "vars/main.yml" | ||
|
||
- name: Removing existing link | ||
ansible.builtin.file: | ||
path: '~/.ansible/roles/adit.{{ the_role_name }}' | ||
state: absent | ||
- name: Linking role | ||
ansible.builtin.file: | ||
state: link | ||
path: '~/.ansible/roles/adit.{{ the_role_name }}' | ||
src: "{{ playbook_dir }}/.." | ||
- name: Check if requirements_yml_file exists | ||
ansible.builtin.stat: | ||
path: "{{ requirements_yml_file }}" | ||
register: requirements_yml | ||
|
||
- name: Include requirements_yml_file as variables | ||
ansible.builtin.include_vars: "{{ requirements_yml_file }}" | ||
when: | ||
- requirements_yml.stat.exists | ||
|
||
- name: Remove roles | ||
ansible.builtin.file: | ||
path: "~/.ansible/roles/{{ item.name }}" | ||
state: absent | ||
with_items: | ||
- "{{ roles }}" | ||
when: | ||
- roles is defined | ||
|
||
- name: Install roles | ||
ansible.builtin.command: | ||
cmd: "ansible-galaxy install -r {{ requirements_yml_file }}" | ||
register: ansible_galaxy_output | ||
with_items: | ||
- "{{ roles }}" | ||
when: | ||
- roles is defined | ||
changed_when: ansible_galaxy_output.rc != 0 | ||
|
||
######################### Role-Requirements for test-Playbooks | ||
- name: Check if test_requirements_yml_file exists | ||
ansible.builtin.stat: | ||
path: "{{ test_requirements_yml_file }}" | ||
register: test_requirements_yml | ||
|
||
- name: "Install required roles for test-environment" | ||
when: | ||
- test_requirements_yml.stat.exists | ||
block: | ||
- name: Include test_requirements_yml_file as variables | ||
ansible.builtin.include_vars: "{{ test_requirements_yml_file }}" | ||
|
||
- name: Remove roles | ||
ansible.builtin.file: | ||
path: "~/.ansible/roles/{{ item.name }}" | ||
state: absent | ||
with_items: | ||
- "{{ roles }}" | ||
when: | ||
- roles is defined | ||
|
||
- name: Install roles | ||
ansible.builtin.command: | ||
cmd: "ansible-galaxy install -r {{ test_requirements_yml_file }}" | ||
register: ansible_galaxy_output | ||
with_items: | ||
- "{{ roles }}" | ||
when: | ||
- roles is defined | ||
changed_when: ansible_galaxy_output.rc != 0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
roles: | ||
- name: adit.mysql_clustercheck | ||
src: https://group_549_bot_5c252634c40b20e971f823cea50a2254:[email protected]/adit/infrastructure/ansible/mysql_clustercheck.git | ||
scm: git | ||
version: 0.1.1 | ||
collections: | ||
- name: community.docker | ||
version: "*" # Need to ensure that the latest version is installed or Molecule fails | ||
- name: prometheus.prometheus | ||
version: 0.17.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
|
||
- name: Test stuff | ||
hosts: mariadb_galera_cluster | ||
tags: | ||
- testing | ||
tasks: | ||
- name: Print ssh command | ||
ansible.builtin.debug: | ||
msg: 'ssh {{ ansible_default_ipv4.address }}' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# tests/vars/main.yml | ||
# defintion of needed variables | ||
--- | ||
|
||
db_path: "{{ kv_path }}/database" | ||
galera_cluster_bind_interface: '{{ ansible_default_ipv4.interface }}' | ||
galera_cluster_name: "testcluster" | ||
galera_cluster_nodes_group: "{{ the_role_name }}" | ||
galera_mysql_first_node: "{{ groups[the_role_name][0] }}" | ||
kv_path: "/customer/{{ customer }}/mariadb" | ||
mariadb_debian_repo_key_url: "https://mariadb.org/mariadb_release_signing_key.asc" | ||
the_role_name: 'mariadb_galera_cluster' | ||
user_path: "{{ kv_path }}/user" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
|
||
# MySQLd Exporter Vars | ||
mysqld_exporter_username: "test" | ||
mysqld_exporter_password: "test" |