Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the Molecule tests for the Type C schema (Consul) #511

Merged
merged 4 commits into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions add_balancer.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
---
- name: add_balancer.yml | Add haproxy balancer node (to the cluster "{{ patroni_cluster_name }}")
- name: add_balancer.yml | Add HAProxy balancer node
hosts: balancers
become: true
become_method: sudo
any_errors_fatal: true
gather_facts: true
vars_files:
- vars/main.yml
- vars/system.yml

pre_tasks:
- name: Include main variables
ansible.builtin.include_vars: "vars/main.yml"
tags: always

- name: Include system variables
ansible.builtin.include_vars: "vars/system.yml"
tags: always

- name: Include OS-specific variables
ansible.builtin.include_vars: "vars/{{ ansible_os_family }}.yml"
tags: always
Expand Down Expand Up @@ -122,13 +126,18 @@
become_method: sudo
gather_facts: true
any_errors_fatal: true
vars_files:
- vars/main.yml
- vars/system.yml
vars:
add_balancer: true

pre_tasks:
- name: Include main variables
ansible.builtin.include_vars: "vars/main.yml"
tags: always

- name: Include system variables
ansible.builtin.include_vars: "vars/system.yml"
tags: always

- name: Include OS-specific variables
ansible.builtin.include_vars: "vars/{{ ansible_os_family }}.yml"
tags: always
Expand Down
41 changes: 29 additions & 12 deletions add_pgnode.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
---
- name: add_pgnode.yml | PostgreSQL High-Availability Cluster Scaling (add a replica node to the cluster "{{ patroni_cluster_name }}")
- name: add_pgnode.yml | PostgreSQL HA Cluster Scaling (add a replica node)
hosts: postgres_cluster
become: true
become_method: sudo
any_errors_fatal: true
gather_facts: true
handlers:
- ansible.builtin.import_tasks: roles/patroni/handlers/main.yml
vars_files:
- vars/main.yml
- vars/system.yml

pre_tasks:
- name: Include main variables
ansible.builtin.include_vars: "vars/main.yml"
tags: always

- name: Include system variables
ansible.builtin.include_vars: "vars/system.yml"
tags: always

- name: Include OS-specific variables
ansible.builtin.include_vars: "vars/{{ ansible_os_family }}.yml"
tags: always
Expand Down Expand Up @@ -134,11 +139,16 @@
become_method: sudo
gather_facts: true
any_errors_fatal: true
vars_files:
- vars/main.yml
- vars/system.yml

pre_tasks:
- name: Include main variables
ansible.builtin.include_vars: "vars/main.yml"
tags: always

- name: Include system variables
ansible.builtin.include_vars: "vars/system.yml"
tags: always

- name: Include OS-specific variables
ansible.builtin.include_vars: "vars/{{ ansible_os_family }}.yml"
tags: always
Expand All @@ -165,9 +175,11 @@
become_method: sudo
gather_facts: true
any_errors_fatal: true
vars_files:
- vars/main.yml
pre_tasks:
- name: Include main variables
ansible.builtin.include_vars: "vars/main.yml"
tags: always

- name: Include OS-specific variables
ansible.builtin.include_vars: "vars/{{ ansible_os_family }}.yml"
tags: always
Expand All @@ -187,13 +199,18 @@
become_method: sudo
gather_facts: true
any_errors_fatal: true
vars_files:
- vars/main.yml
- vars/system.yml
vars:
existing_pgcluster: true

pre_tasks:
- name: Include main variables
ansible.builtin.include_vars: "vars/main.yml"
tags: always

- name: Include system variables
ansible.builtin.include_vars: "vars/system.yml"
tags: always

- name: Include OS-specific variables
ansible.builtin.include_vars: "vars/{{ ansible_os_family }}.yml"
tags: always
Expand Down
13 changes: 9 additions & 4 deletions balancers.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
---
- name: balancers.yml | Configure load balancers
- name: balancers.yml | Configure HAProxy load balancers
hosts: balancers
become: true
become_method: sudo
any_errors_fatal: true
gather_facts: true
vars_files:
- vars/main.yml
- vars/system.yml
vars:
vip_manager_disable: false # or 'true' for disable vip-manager service (if installed)

pre_tasks:
- name: Include main variables
ansible.builtin.include_vars: "vars/main.yml"
tags: always

- name: Include system variables
ansible.builtin.include_vars: "vars/system.yml"
tags: always

- name: Include OS-specific variables
ansible.builtin.include_vars: "vars/{{ ansible_os_family }}.yml"
tags: always
Expand Down
51 changes: 35 additions & 16 deletions config_pgcluster.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
---
- name: config_pgcluster.yml | Configuration PostgreSQL HA Cluster (based on "Patroni" and "{{ dcs_type }}")
- name: config_pgcluster.yml | Configuration PostgreSQL HA Cluster (based on "Patroni")
hosts: postgres_cluster
gather_facts: true
vars_files:
- vars/main.yml
- vars/system.yml
pre_tasks:
- name: Include main variables
ansible.builtin.include_vars: "vars/main.yml"

- name: Include system variables
ansible.builtin.include_vars: "vars/system.yml"

- name: Include OS-specific variables
ansible.builtin.include_vars: "vars/{{ ansible_os_family }}.yml"

Expand Down Expand Up @@ -76,10 +79,15 @@
handlers:
- ansible.builtin.import_tasks: roles/patroni/handlers/main.yml
- ansible.builtin.import_tasks: roles/pgbouncer/handlers/main.yml
vars_files:
- vars/main.yml
- vars/system.yml
pre_tasks:
- name: Include main variables
ansible.builtin.include_vars: "vars/main.yml"
tags: always

- name: Include system variables
ansible.builtin.include_vars: "vars/system.yml"
tags: always

- name: Include OS-specific variables
ansible.builtin.include_vars: "vars/{{ ansible_os_family }}.yml"
tags: always
Expand Down Expand Up @@ -155,9 +163,11 @@
become_method: sudo
gather_facts: true
any_errors_fatal: true
vars_files:
- vars/main.yml
pre_tasks:
- name: Include main variables
ansible.builtin.include_vars: "vars/main.yml"
tags: always

- name: Include OS-specific variables
ansible.builtin.include_vars: "vars/{{ ansible_os_family }}.yml"
tags: always
Expand All @@ -172,9 +182,11 @@
become: true
become_method: sudo
any_errors_fatal: true
vars_files:
- vars/main.yml
pre_tasks:
- name: Include main variables
ansible.builtin.include_vars: "vars/main.yml"
tags: always

- name: Include OS-specific variables
ansible.builtin.include_vars: "vars/{{ ansible_os_family }}.yml"
tags: always
Expand Down Expand Up @@ -221,9 +233,11 @@
become_method: sudo
any_errors_fatal: true
environment: "{{ proxy_env | default({}) }}"
vars_files:
- vars/main.yml
pre_tasks:
- name: Include main variables
ansible.builtin.include_vars: "vars/main.yml"
tags: always

- name: Include OS-specific variables
ansible.builtin.include_vars: "vars/{{ ansible_os_family }}.yml"
tags: always
Expand Down Expand Up @@ -277,9 +291,14 @@
become_method: sudo
gather_facts: true
any_errors_fatal: true
vars_files:
- vars/main.yml
- vars/system.yml
pre_tasks:
- name: Include main variables
ansible.builtin.include_vars: "vars/main.yml"
tags: always

- name: Include system variables
ansible.builtin.include_vars: "vars/system.yml"
tags: always
roles:
# finish (info)
- role: deploy-finish
52 changes: 30 additions & 22 deletions consul.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
---
- name: consul.yml | Consul Playbook
hosts: localhost
- name: consul.yml | Configure Consul instances
hosts: consul_instances
become: true
become_method: sudo
any_errors_fatal: true
gather_facts: false
vars_files:
- vars/main.yml
tasks:
gather_facts: true
environment: "{{ proxy_env | default({}) }}"

pre_tasks:
- name: Include main variables
ansible.builtin.include_vars: "vars/main.yml"
tags: always

- name: Include system variables
ansible.builtin.include_vars: "vars/system.yml"
tags: always

- name: Include OS-specific variables
ansible.builtin.include_vars: "vars/{{ ansible_os_family }}.yml"
tags: always

- name: Check if the consul role requirements (ansible.utils) are installed
ansible.builtin.command: ansible-galaxy collection list ansible.utils
changed_when: false
failed_when: false
register: ansible_utils_result
delegate_to: localhost
run_once: true # noqa run-once

- name: Consul role requirements
ansible.builtin.fail:
msg:
- "Please install consul role requirements (ansible.utils)"
- "ansible-galaxy install -r roles/consul/requirements.yml"
delegate_to: localhost
run_once: true # noqa run-once
when:
- ansible_utils_result.stderr is search("unable to find")

Expand All @@ -28,6 +46,8 @@
until: package_status is success
delay: 5
retries: 3
delegate_to: localhost
run_once: true # noqa run-once

- name: Make sure the python3-pip package are present on the control host
ansible.builtin.package:
Expand All @@ -37,6 +57,8 @@
until: package_status is success
delay: 5
retries: 3
delegate_to: localhost
run_once: true # noqa run-once

- name: Install netaddr dependency on the control host
ansible.builtin.pip:
Expand All @@ -45,22 +67,8 @@
become: false
environment:
PIP_BREAK_SYSTEM_PACKAGES: "1"

- name: consul.yml | Configure Consul instances
hosts: consul_instances
become: true
become_method: sudo
any_errors_fatal: true
gather_facts: true
vars_files:
- vars/main.yml
- vars/system.yml
environment: "{{ proxy_env | default({}) }}"

pre_tasks:
- name: Include OS-specific variables
ansible.builtin.include_vars: "vars/{{ ansible_os_family }}.yml"
tags: always
delegate_to: localhost
run_once: true # noqa run-once

- name: Update apt cache
ansible.builtin.apt:
Expand Down
Loading