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

chore(ansible-lint.yml): remove yaml[line-length] from skip_list #417

Merged
merged 117 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from 115 commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
057df41
🔧 chore(ansible-lint.yml): remove yaml[line-length] from skip_list
ThomasSanson Jul 14, 2023
916f089
🔧 chore(.gitignore): add *.log to ignore log files
ThomasSanson Jul 14, 2023
93ec948
✨ feat(tests): add new assert tests for pg_probackup_command_value an…
ThomasSanson Jul 14, 2023
b75f46f
🔧 chore(molecule/default/verify.yml): include asserts playbook for po…
ThomasSanson Jul 14, 2023
a970d14
✨ feat(tests): add assertions for wal_g_cron_jobs in molecule test
ThomasSanson Jul 14, 2023
2de6341
🔧 refactor(tests): extract complex string into a variable for better …
ThomasSanson Jul 14, 2023
3595b14
📝 docs: Add new test file pg_probackup.yml for testing pg_probackup c…
ThomasSanson Jul 14, 2023
3e41bdd
🔧 refactor(pg_probackup.yml, main.yml): improve variable naming and r…
ThomasSanson Jul 14, 2023
6b28198
🔧 refactor(pg_probackup.yml): rename pg_probackup_first_value to orig…
ThomasSanson Jul 14, 2023
bb3c8e7
✨ feat(main.yml): add a comment to pg_probackup_command_parts to prev…
ThomasSanson Jul 14, 2023
958486c
📝 docs(main.yml): split long comment line into multiple lines for bet…
ThomasSanson Jul 14, 2023
9685bdb
🔧 refactor(main.yml): remove trailing spaces in commented out postgre…
ThomasSanson Jul 14, 2023
766f7f8
🔧 refactor(wal_g_cron_jobs.yml, main.yml): rename wal_g_cron_jobs_fir…
ThomasSanson Jul 14, 2023
7cb8e9a
🔧 refactor(wal_g_cron_jobs.yml): improve job naming and add wal_g_cro…
ThomasSanson Jul 14, 2023
a65d3b7
📝 docs(main.yml): add comment to ensure space at the beginning of eac…
ThomasSanson Jul 14, 2023
ec5e654
🔄 refactor(vip_manager_package_repo): switch from Debian to RedHat va…
ThomasSanson Jul 14, 2023
543f409
🔤 style(vip_manager_package_repo.yml): add newline at end of file
ThomasSanson Jul 14, 2023
f76d3c0
📝 docs(RedHat.yml): improve comments readability by splitting long li…
ThomasSanson Jul 14, 2023
7e84bf0
🔧 refactor(vip_manager_package_repo): split URL into parts for better…
ThomasSanson Jul 14, 2023
4dd69a3
🔧 refactor(vip_manager_package_repo.yml): disable yamllint line-lengt…
ThomasSanson Jul 14, 2023
f726428
✨ feat(molecule): add tests for role swap in Ansible
ThomasSanson Jul 14, 2023
98cedf0
🔧 refactor(swap): improve readability of condition checks in create.y…
ThomasSanson Jul 14, 2023
4d7a973
🔧 refactor(main.yml): rename task names for better clarity and unders…
ThomasSanson Jul 14, 2023
06d4dcb
✨ feat(molecule): add pre-checks role and tests for TimescaleDB
ThomasSanson Jul 14, 2023
b8d38d9
✨ feat(tests): add pgbouncer pool size calculation and validation in …
ThomasSanson Jul 15, 2023
e8fc8f1
🔧 refactor(pgbouncer.yml): rename origin_pgbouncer_pool_size to pgbou…
ThomasSanson Jul 15, 2023
0202932
🔧 refactor(pgbouncer.yml): improve readability of pgbouncer_pool_size…
ThomasSanson Jul 15, 2023
256579d
🔧 refactor(tests): improve readability and add new tests in pgbouncer…
ThomasSanson Jul 15, 2023
5e32d1c
📝 docs(pgbouncer.yml): remove trailing periods from comments for cons…
ThomasSanson Jul 15, 2023
a31365e
🔧 refactor(pgbouncer.yml): improve readability of pgbouncer_total_poo…
ThomasSanson Jul 15, 2023
723ebf9
🔧 refactor(tests): enhance wal_g_cron_jobs.yml test file for better r…
ThomasSanson Jul 15, 2023
5aa46e2
🔧 refactor(pgbouncer.yml): simplify task names for better readability…
ThomasSanson Jul 15, 2023
6bb0b7c
🔧 refactor(wal_g_cron_jobs.yml): simplify task names for better reada…
ThomasSanson Jul 15, 2023
8f33f8d
🔀 refactor(vip_manager_package_repo.yml): improve task descriptions a…
ThomasSanson Jul 15, 2023
4343e96
🔧 refactor(wal_g_cron_jobs.yml): replace assert and debug with ansibl…
ThomasSanson Jul 15, 2023
bedb938
🔧 refactor(pg_probackup.yml): replace debug and assert modules with a…
ThomasSanson Jul 15, 2023
f2e8e95
🔧 refactor(deploy_pgcluster.yml): improve readability of CPU model in…
ThomasSanson Jul 15, 2023
def0f9f
🔧 refactor(system_info.yml): update comment for CPU model operations …
ThomasSanson Jul 15, 2023
50dc239
🔧 refactor(deploy_pgcluster.yml, system_info.yml): improve readabilit…
ThomasSanson Jul 15, 2023
1f56cd2
🔧 refactor(deploy_pgcluster.yml, system_info.yml): remove trailing sp…
ThomasSanson Jul 15, 2023
ee0ce0b
✨ feat(tests): add new test file baseurl.yml to validate _baseurl var…
ThomasSanson Jul 15, 2023
776b841
🔧 refactor(postgrespro_vars.yml, baseurl.yml): use string concatenati…
ThomasSanson Jul 15, 2023
ad52b23
✨ feat(tests): add apt_repository variable tests in molecule
ThomasSanson Jul 15, 2023
18e8465
🔧 refactor(postgrespro_vars.yml, apt_repository.yml): use string conc…
ThomasSanson Jul 15, 2023
0a1c466
🔧 refactor(molecule/tests): improve readability and semantics in test…
ThomasSanson Jul 15, 2023
f9326b6
🔧 refactor(haproxy.tmpl.yml): update task names and variables for bet…
ThomasSanson Jul 15, 2023
30876b1
🔧 refactor(haproxy.tmpl.yml): rename tasks for clarity and consistency
ThomasSanson Jul 15, 2023
46a2a40
✨ feat(tests): add tests for deploy-finish role and haproxy_nodes var…
ThomasSanson Jul 15, 2023
c9fa2ec
🔧 refactor(deploy-finish): simplify haproxy_nodes variable assignment…
ThomasSanson Jul 15, 2023
dc94372
✨ feat(haproxy_nodes.yml): add operations and tests for postgres_clus…
ThomasSanson Jul 15, 2023
c006061
🔧 refactor(haproxy_nodes.yml, main.yml): simplify postgres_cluster_no…
ThomasSanson Jul 15, 2023
314d59c
🎨 style: remove trailing spaces in ansible scripts for better code re…
ThomasSanson Jul 15, 2023
5c48f59
✨ feat(molecule): add tests for haproxy role
ThomasSanson Jul 15, 2023
afb8d82
🔧 refactor(haproxy.cfg.yml): update test cases and variable names for…
ThomasSanson Jul 15, 2023
8612cb2
✨ feat(molecule): add tests for role patroni and refactor custom_wal_…
ThomasSanson Jul 15, 2023
bed494c
🔧 refactor(verify.yml): remove direct import of confd tests, add it t…
ThomasSanson Jul 15, 2023
c3abd26
🔧 refactor(molecule tests): optimize test execution by adding run_onc…
ThomasSanson Jul 15, 2023
3221c9d
🔧 refactor(timescaledb.yml): remove unnecessary include vars and add …
ThomasSanson Jul 15, 2023
1e38508
🔧 chore(confd/main.yml): add run_once directive to Molecule.tests.rol…
ThomasSanson Jul 15, 2023
b71f2a5
🔧 refactor(tests): delegate tasks to localhost and run once to optimi…
ThomasSanson Jul 15, 2023
0f13006
🔧 refactor(deploy-finish): simplify main.yml by removing redundant ta…
ThomasSanson Jul 15, 2023
91c716b
🔧 refactor(haproxy.cfg.yml, main.yml): add run_once and delegate_to t…
ThomasSanson Jul 15, 2023
00d0922
🔧 refactor(custom_wal_dir.yml, main.yml): add run_once to tasks to op…
ThomasSanson Jul 15, 2023
a6df07b
🔧 refactor(pgbouncer.yml): add run_once: true to debug tasks to avoid…
ThomasSanson Jul 15, 2023
dc4df44
📝 docs(molecule/tests/variables/main.yml): rename task name for bette…
ThomasSanson Jul 15, 2023
6490f27
🔧 refactor(pg_probackup.yml): update task names to include full path …
ThomasSanson Jul 15, 2023
9e48b7c
🔧 refactor(apt_repository.yml): rename test names from baseurl to apt…
ThomasSanson Jul 15, 2023
c5686ed
📝 docs(molecule/tests/roles/swap/main.yml): rename task name for bett…
ThomasSanson Jul 15, 2023
852cf7c
🔧 refactor(tests): update task names in create.yml and delete.yml for…
ThomasSanson Jul 15, 2023
f5d599b
🔧 refactor(molecule/tests): update task names to include full path fo…
ThomasSanson Jul 15, 2023
15e6691
🔧 refactor(haproxy_nodes.yml): update task names to reflect the corre…
ThomasSanson Jul 15, 2023
8b93c7b
🔧 refactor(verify.yml): rename tasks for better readability and consi…
ThomasSanson Jul 15, 2023
cf86a54
🔧 refactor(molecule/tests/variables/main.yml): update task inclusion …
ThomasSanson Jul 15, 2023
cd870d2
🔧 refactor(confd/main.yml): change the way tasks are included and loo…
ThomasSanson Jul 15, 2023
634edad
🔧 refactor(deploy-finish/main.yml): replace with_fileglob with lookup…
ThomasSanson Jul 15, 2023
d6c9867
🔧 refactor(haproxy/main.yml): modify task inclusion method for better…
ThomasSanson Jul 15, 2023
d46f7a8
🔧 refactor(patroni/main.yml): change the way tasks are included and l…
ThomasSanson Jul 15, 2023
d0932e4
🔧 refactor(pre-checks/main.yml): change the way tasks are included an…
ThomasSanson Jul 15, 2023
14a75b9
🔧 refactor(tests/roles/swap/main.yml): update task inclusion method i…
ThomasSanson Jul 15, 2023
d5f7d02
🔧 chore(confd/main.yml): add newline at end of file to adhere to POSI…
ThomasSanson Jul 15, 2023
1bb5ebd
🔧 refactor(patroni/tasks/main.yml): improve readability by separating…
ThomasSanson Jul 15, 2023
771bd86
🔧 chore(verify.yml): include OS-specific variables for better configu…
ThomasSanson Jul 16, 2023
7b823de
🔧 chore(haproxy.tmpl.yml): ensure tmp directory creation is delegated…
ThomasSanson Jul 16, 2023
50d31d9
📝 docs(tests): update comments in main.yml for better understanding
ThomasSanson Jul 16, 2023
ce8989a
📝 docs(apt_repository.yml): improve clarity and precision of comments…
ThomasSanson Jul 16, 2023
4acb474
📝 docs(baseurl.yml): refine comments and task names for clarity and s…
ThomasSanson Jul 16, 2023
56bbaf0
📝 docs(pg_probackup.yml): enhance comments for better understanding a…
ThomasSanson Jul 16, 2023
f415374
📝 docs(vip_manager_package_repo.yml): add comments to tasks for bette…
ThomasSanson Jul 16, 2023
de5412a
📝 docs(wal_g_cron_jobs.yml): Improve clarity and precision of test de…
ThomasSanson Jul 16, 2023
725c667
📝 docs(tests): update comments in main.yml for better understanding o…
ThomasSanson Jul 16, 2023
49bda86
📝 docs(create.yml): improve comments for better understanding of the …
ThomasSanson Jul 16, 2023
1c2a5da
📝 docs(delete.yml): improve comments for better understanding of the …
ThomasSanson Jul 16, 2023
f6cf282
📝 docs(pre-checks/main.yml): add detailed comments to explain the pur…
ThomasSanson Jul 16, 2023
251d83b
📝 docs(timescaledb.yml): add detailed comments to explain the purpose…
ThomasSanson Jul 16, 2023
b618086
📝 docs(patroni/main.yml): update task description to include and exec…
ThomasSanson Jul 16, 2023
2adc145
🚀 feat(haproxy/main.yml): Incorporate variable tests for HAProxy
ThomasSanson Jul 16, 2023
9c3432e
🚀 feat(deploy-finish/main.yml): change task name and add detailed com…
ThomasSanson Jul 16, 2023
5633c2c
🚀 feat(confd/main.yml): include variable tests for the main role in C…
ThomasSanson Jul 16, 2023
ceb7fa8
🔧 fix(confd/tasks/main.yml): remove unnecessary condition in 'when' c…
ThomasSanson Jul 16, 2023
67768be
🔧 refactor(Debian.yml, RedHat.yml): simplify vip_manager_package_repo…
ThomasSanson Jul 16, 2023
1952bec
🔧 chore(.gitignore): ensure newline at end of file
ThomasSanson Jul 16, 2023
eee0380
📝 docs(verify.yml): add comments to improve code readability and unde…
ThomasSanson Jul 16, 2023
54d7475
🔧 refactor(postgrespro_vars.yml, baseurl.yml): simplify OracleLinux U…
ThomasSanson Jul 16, 2023
d7e0726
🔧 refactor(haproxy): rename loop variables for better clarity and und…
ThomasSanson Jul 16, 2023
5e4770b
🔧 refactor(patroni/tasks/main.yml): replace item with specific patron…
ThomasSanson Jul 16, 2023
eccb6e0
🔧 chore(.yamllint): set maximum line length to 160 characters
ThomasSanson Jul 16, 2023
d8e3600
🔧 refactor(main.yml): add loop_var to loop_control for better loop it…
ThomasSanson Jul 16, 2023
9f6a530
📝 docs(haproxy.cfg.yml): update task description to reflect actual fu…
ThomasSanson Jul 16, 2023
610bd7b
✏️ refactor(haproxy.cfg.yml): simplify task name for preparing haprox…
ThomasSanson Jul 16, 2023
959e15e
📝 docs(haproxy.tmpl.yml): update task names for clarity
ThomasSanson Jul 16, 2023
c5c4c39
🔧 refactor(haproxy): change port numbers from 8080-8084 to 5000-5004 …
ThomasSanson Jul 16, 2023
b41a0ad
🔧 fix(custom_wal_dir.yml): update postgresql_version from 9 to 9.6 in…
ThomasSanson Jul 16, 2023
6834588
🔧 fix(custom_wal_dir.yml): update PostgreSQL version from 9 to 9.6 in…
ThomasSanson Jul 16, 2023
d8d5d9f
🔄 refactor(main.yml): rename pg_probackup_command to pg_probackup_res…
ThomasSanson Jul 16, 2023
640fd8f
🔄 refactor(haproxy.tmpl.yml, haproxy.cfg.yml): reorder and update por…
ThomasSanson Jul 17, 2023
b207edc
🔄 refactor(wal_g_cron_jobs.yml, main.yml): rename wal_g_cron_create_j…
ThomasSanson Jul 17, 2023
5a01696
🔧 refactor: rename 'wal_g_cron_delete_job_parts' to 'wal_g_delete_com…
ThomasSanson Jul 17, 2023
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
3 changes: 2 additions & 1 deletion .config/.yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
extends: default

rules:
line-length: disable
line-length:
max: 160
comments-indentation: disable
comments:
min-spaces-from-content: 1
Expand Down
1 change: 0 additions & 1 deletion .config/ansible-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ skip_list:
- package-latest
- risky-file-permissions # TODO
- role-name
- yaml[line-length]

exclude_paths:
- ../.venv
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
.idea
.venv
.vscode/settings.json
__pycache__/
__pycache__/
*.log
molecule/**/tmp
15 changes: 13 additions & 2 deletions deploy_pgcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,20 @@
system_info:
OS: "{{ ansible_distribution | default('N/A') }} {{ ansible_distribution_version | default('N/A') }}"
Kernel: "{{ ansible_kernel | default('N/A') }}"
CPU model: "{{ ansible_processor[2] | default('N/A') }}, count: {{ ansible_processor_count | default('N/A') }}, cores: {{ ansible_processor_cores | default('N/A') }}"
CPU model: >-
{{ ansible_processor[2] | default('N/A') }},
count: {{ ansible_processor_count | default('N/A') }},
cores: {{ ansible_processor_cores | default('N/A') }}
Memory: "{{ (ansible_memtotal_mb / 1024) | round(2) if ansible_memtotal_mb is defined else 'N/A' }} GB"
Disk space total: "{{ (ansible_mounts | map(attribute='size_total') | map('int') | sum / 1024 / 1024 / 1024) | round(2) if ansible_mounts is defined else 'N/A' }} GB"
Disk space total: >-
{{
(ansible_mounts
| map(attribute='size_total')
| map('int')
| sum / 1024 / 1024 / 1024
)
| round(2) if ansible_mounts is defined else 'N/A'
}} GB
Architecture: "{{ ansible_architecture | default('N/A') }}"
Virtualization type: "{{ ansible_virtualization_type | default('N/A') }}"
Product name: "{{ ansible_product_name | default('N/A') }}"
Expand Down
27 changes: 24 additions & 3 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
---
- name: Molecule | Verify | All
# 🚀 This playbook is designed to verify the default Molecule configuration
# 🎯 The objective is to ensure that all tasks and roles are correctly set up and functioning as expected

- name: Molecule.default.verify
hosts: all
gather_facts: true

tasks:
- name: Include vars of vars/main.yml
# 📝 Including the main variables file for the Molecule default configuration
# This file contains all the necessary variables for the playbook
- name: Molecule.default.verify | Include Main Variables
ansible.builtin.include_vars:
file: ../../vars/main.yml

- name: Molecule | Verify | Include all tests
# 🔄 Including OS-specific variables
# These variables are specific to the operating system on which the playbook is running
- name: Molecule.default.verify | Include OS-Specific Variables
ansible.builtin.include_vars:
file: "../../vars/{{ ansible_os_family }}.yml"

# 🔄 Including all tests for the Molecule default configuration
# These tests ensure that all components of the configuration are functioning correctly
- name: Molecule.default.verify | Include All Tests
ansible.builtin.include_tasks: "{{ item }}"
with_fileglob:
- ../tests/variables/main.yml
- ../tests/etcd/*.yml
- ../tests/patroni/*.yml
- ../tests/postgres/*.yml
- ../tests/roles/confd/main.yml
- ../tests/roles/deploy-finish/main.yml
- ../tests/roles/haproxy/main.yml
- ../tests/roles/patroni/main.yml
- ../tests/roles/pre-checks/main.yml
- ../tests/roles/swap/main.yml
7 changes: 5 additions & 2 deletions molecule/postgrespro/vars/postgrespro_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ postgresql_bin_dir: "/opt/pgpro/std-{{ postgresql_version }}/bin"
postgresql_unix_socket_dir: "/tmp"

# YUM Repository
_baseurl:
_baseurl: # yamllint disable rule:line-length
vitabaks marked this conversation as resolved.
Show resolved Hide resolved
CentOS: "https://repo.postgrespro.ru//pgpro-archive/pgpro-{{ postgrespro_minor_version }}/centos/{{ ansible_distribution_major_version }}/os/x86_64/rpms/"
RedHat: "https://repo.postgrespro.ru//pgpro-archive/pgpro-{{ postgrespro_minor_version }}/rhel/{{ ansible_distribution_major_version }}Server/os/x86_64/rpms/"
OracleLinux: "https://repo.postgrespro.ru//pgpro-archive/pgpro-{{ postgrespro_minor_version }}/oraclelinux/{{ ansible_distribution_major_version }}Server/os/x86_64/rpms/"
Expand All @@ -25,7 +25,10 @@ yum_repository:
apt_repository_keys:
- key: "https://repo.postgrespro.ru/keys/GPG-KEY-POSTGRESPRO"
apt_repository:
- repo: "deb https://repo.postgrespro.ru//pgpro-archive/pgpro-{{ postgrespro_minor_version }}/{{ ansible_distribution | lower }}/ {{ ansible_distribution_release }} main"
- repo: >-
{{ 'deb https://repo.postgrespro.ru//pgpro-archive/pgpro-' ~
postgrespro_minor_version ~ '/' ~ (ansible_distribution | lower) ~ '/' ~
' ' ~ ansible_distribution_release ~ ' main' }}

install_postgresql_repo: false

Expand Down
13 changes: 13 additions & 0 deletions molecule/tests/roles/confd/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
# 🚀 This task is designed to include variable tests for the main role in the Confd molecule tests
# 🎯 The goal is to ensure that all variable tests are executed in a systematic and organised manner

# 🔄 Including variable tests for the main role in the Confd molecule tests
# We use a loop to include all YAML files in the 'variables' directory
# Each file is included as a task, ensuring that all variable tests are executed
- name: Molecule.tests.roles.confd.main | Include Variable Tests
run_once: true
ansible.builtin.include_tasks: "{{ molecule_tests_roles_confd_main_file }}"
loop: "{{ lookup('fileglob', 'variables/*.yml', wantlist=True) }}"
loop_control:
loop_var: molecule_tests_roles_confd_main_file
162 changes: 162 additions & 0 deletions molecule/tests/roles/confd/variables/haproxy.tmpl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
---
# 🚀 These tasks aim to test the "ansible.builtin.lineinfile" task
# 🎯 The objective is to ensure that the lines are correctly replaced

# 📂 Ensure tmp directory exists
- name: Molecule.tests.roles.confd.variables.haproxy.tmpl | Ensure tmp directory exists
run_once: true
delegate_to: localhost
ansible.builtin.file:
path: "./tmp"
state: directory

# 🔄 Define a dummy template file
- name: Molecule.tests.roles.confd.variables.haproxy.tmpl | Set template file test data
ansible.builtin.set_fact:
haproxy_listen_port:
master: 5000
replicas: 5001
replicas_sync: 5002
replicas_async: 5003
stats: 7000
inventory_hostname: una.name
cluster_vip: fake.vip.url.com

# ===============================
# 💻 Case cluster_vip is defined
# ===============================

# 📝 Establishing test data for haproxy.cluster_vip.defined.tmpl
- name: Molecule.tests.roles.confd.variables.haproxy.tmpl | Establish haproxy.tmpl Test Data
run_once: true
delegate_to: localhost
ansible.builtin.copy:
dest: "./tmp/haproxy.cluster_vip.defined.tmpl"
content: |
bind *:{{ haproxy_listen_port.stats }}
bind *:{{ haproxy_listen_port.master }}
bind *:{{ haproxy_listen_port.replicas }}
bind *:{{ haproxy_listen_port.replicas_sync }}
bind *:{{ haproxy_listen_port.replicas_async }}

# 🚀 Execute the main task here
# This task updates the 'haproxy.tmpl' file
# replacing lines that start with 'bind' and include specific ports
# The new lines will either bind to the inventory_hostname or the cluster_vip, depending on the specific port.
- name: Molecule.tests.roles.confd.variables.haproxy.tmpl | Update haproxy.tmpl (replace "bind")
run_once: true
delegate_to: localhost
ansible.builtin.lineinfile:
path: ./tmp/haproxy.cluster_vip.defined.tmpl
regexp: "{{ bind_config_with_vip_item.regexp }}"
line: "{{ bind_config_with_vip_item.line }}"
backrefs: true
loop:
- regexp: '^.*bind.*:{{ haproxy_listen_port.stats }}$'
line: ' bind {{ inventory_hostname }}:{{ haproxy_listen_port.stats }}'
- regexp: '^.*bind.*:{{ haproxy_listen_port.master }}$'
line: ' bind {{ cluster_vip }}:{{ haproxy_listen_port.master }}'
- regexp: '^.*bind.*:{{ haproxy_listen_port.replicas }}$'
line: ' bind {{ cluster_vip }}:{{ haproxy_listen_port.replicas }}'
- regexp: '^.*bind.*:{{ haproxy_listen_port.replicas_sync }}$'
line: ' bind {{ cluster_vip }}:{{ haproxy_listen_port.replicas_sync }}'
- regexp: '^.*bind.*:{{ haproxy_listen_port.replicas_async }}$'
line: ' bind {{ cluster_vip }}:{{ haproxy_listen_port.replicas_async }}'
loop_control:
loop_var: bind_config_with_vip_item
label: "{{ bind_config_with_vip_item.line }}"

# 🖨️ Debugging the established haproxy.tmpl
- name: Molecule.tests.roles.confd.variables.haproxy.tmpl | Debug haproxy.tmpl
run_once: true
delegate_to: localhost
ansible.builtin.command:
cmd: cat ./tmp/haproxy.cluster_vip.defined.tmpl
register: output
- name: Molecule.tests.roles.confd.variables.haproxy.tmpl | Debug haproxy.tmpl content
run_once: true
ansible.builtin.debug:
var: output.stdout_lines

# ✅ Verifying the correctness of the established haproxy.tmpl
# If the lines are not replaced correctly, the test fails and an error message is displayed
- name: Molecule.tests.roles.confd.variables.haproxy.tmpl | Validate updated haproxy.tmpl
run_once: true
ansible.builtin.assert:
that:
- "output.stdout_lines[0] == ' bind una.name:7000'"
- "output.stdout_lines[1] == ' bind fake.vip.url.com:5000'"
- "output.stdout_lines[2] == ' bind fake.vip.url.com:5001'"
- "output.stdout_lines[3] == ' bind fake.vip.url.com:5002'"
- "output.stdout_lines[4] == ' bind fake.vip.url.com:5003'"
fail_msg: "Test failed: Lines are not replaced correctly in haproxy.tmpl."
success_msg: "Test passed: Lines are replaced correctly in haproxy.tmpl."

# ===================================
# 💻 Case cluster_vip is not defined
# ===================================

# 📝 Establishing test data for haproxy.cluster_vip.not.defined.tmpl
- name: Molecule.tests.roles.confd.variables.haproxy.tmpl | Establish haproxy.tmpl Test Data - 2nd round
run_once: true
delegate_to: localhost
ansible.builtin.copy:
dest: "./tmp/haproxy.cluster_vip.not.defined.tmpl"
content: |
bind *:{{ haproxy_listen_port.stats }}
bind *:{{ haproxy_listen_port.master }}
bind *:{{ haproxy_listen_port.replicas }}
bind *:{{ haproxy_listen_port.replicas_sync }}
bind *:{{ haproxy_listen_port.replicas_async }}

# 🚀 Execute the new task here
# This task updates the 'haproxy.tmpl' file again, this time replacing lines that start with 'bind' and include specific ports
# The new lines will bind to the inventory_hostname.
- name: Molecule.tests.roles.confd.variables.haproxy.tmpl | Prepare haproxy.tmpl template file (replace "bind" - 2nd round)
run_once: true
delegate_to: localhost
ansible.builtin.lineinfile:
path: ./tmp/haproxy.cluster_vip.not.defined.tmpl
regexp: "{{ bind_config_without_vip_item.regexp }}"
line: "{{ bind_config_without_vip_item.line }}"
backrefs: true
loop:
- regexp: '^.*bind.*:{{ haproxy_listen_port.stats }}$'
line: ' bind {{ inventory_hostname }}:{{ haproxy_listen_port.stats }}'
- regexp: '^.*bind.*:{{ haproxy_listen_port.master }}$'
line: ' bind {{ inventory_hostname }}:{{ haproxy_listen_port.master }}'
- regexp: '^.*bind.*:{{ haproxy_listen_port.replicas }}$'
line: ' bind {{ inventory_hostname }}:{{ haproxy_listen_port.replicas }}'
- regexp: '^.*bind.*:{{ haproxy_listen_port.replicas_sync }}$'
line: ' bind {{ inventory_hostname }}:{{ haproxy_listen_port.replicas_sync }}'
- regexp: '^.*bind.*:{{ haproxy_listen_port.replicas_async }}$'
line: ' bind {{ inventory_hostname }}:{{ haproxy_listen_port.replicas_async }}'
loop_control:
loop_var: bind_config_without_vip_item
label: "{{ bind_config_without_vip_item.line }}"

# 🖨️ Debugging the established haproxy.tmpl - 2nd round
- name: Molecule.tests.roles.confd.variables.haproxy.tmpl | Debug haproxy.tmpl - 2nd round
run_once: true
delegate_to: localhost
ansible.builtin.command:
cmd: cat ./tmp/haproxy.cluster_vip.not.defined.tmpl
register: output_2
- name: Molecule.tests.roles.confd.variables.haproxy.tmpl | Debug haproxy.tmpl content - 2nd round
run_once: true
ansible.builtin.debug:
var: output_2.stdout_lines

# ✅ Verifying the correctness of the established haproxy.tmpl - 2nd round
# If the lines are not replaced correctly, the test fails and an error message is displayed
- name: Molecule.tests.roles.confd.variables.haproxy.tmpl | Verify haproxy.tmpl - 2nd round
run_once: true
ansible.builtin.assert:
that:
- "output_2.stdout_lines[0] == ' bind una.name:7000'"
- "output_2.stdout_lines[1] == ' bind una.name:5000'"
- "output_2.stdout_lines[2] == ' bind una.name:5001'"
- "output_2.stdout_lines[3] == ' bind una.name:5002'"
- "output_2.stdout_lines[4] == ' bind una.name:5003'"
fail_msg: "Test failed: Lines are not replaced correctly in haproxy.tmpl - 2nd round."
success_msg: "Test passed: Lines are replaced correctly in haproxy.tmpl - 2nd round."
13 changes: 13 additions & 0 deletions molecule/tests/roles/deploy-finish/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
# 🚀 This task is designed to include and execute a series of variable tests for the 'deploy-finish' role in our Molecule test suite.
# 🎯 The objective is to ensure that all variable tests are run in a systematic and efficient manner, thus ensuring the integrity of our deployment process.

# 🔄 Including and executing variable tests for the 'deploy-finish' role
# We use a loop to iterate over all the YAML files in the 'variables' directory, and for each file, we include its tasks in the current playbook.
# This allows us to run a comprehensive set of variable tests in an automated and efficient manner.
- name: Molecule.tests.roles.deploy-finish.main | Include and Execute Variable Tests
run_once: true
ansible.builtin.include_tasks: "{{ molecule_tests_roles_deploy_finish_main_file }}"
loop: "{{ lookup('fileglob', 'variables/*.yml', wantlist=True) }}"
loop_control:
loop_var: molecule_tests_roles_deploy_finish_main_file
71 changes: 71 additions & 0 deletions molecule/tests/roles/deploy-finish/variables/haproxy_nodes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
# 🚀 These tasks aim to test the haproxy_nodes variable
# 🎯 The objective is to guarantee that the list of nodes is correctly set

# ============================================
# 💻 Start haproxy_nodes Operations and Tests
# ============================================

# 📝 Establishing test data for haproxy_nodes
- name: Molecule.tests.rolesdeploy-finish.variables.haproxy_nodes | Establish haproxy_nodes Test Data
run_once: true
ansible.builtin.set_fact:
haproxy_nodes: >-
{{
groups['balancers']
| default([])
| map('extract', hostvars, 'inventory_hostname')
| join(',')
}}

# 🖨️ Debugging the established haproxy_nodes
- name: Molecule.tests.rolesdeploy-finish.variables.haproxy_nodes | Debug haproxy_nodes
run_once: true
ansible.builtin.debug:
var: haproxy_nodes

# ✅ Verifying the correctness of the established haproxy_nodes
# If the haproxy_nodes is not set, the test fails and an error message is displayed
- name: Molecule.tests.rolesdeploy-finish.variables.haproxy_nodes | Verify haproxy_nodes
run_once: true
ansible.builtin.assert:
that:
- "haproxy_nodes is not none"
- "haproxy_nodes != 'N/A'"
- "haproxy_nodes == 'una.name,10.172.0.21,10.172.0.22'"
fail_msg: "Test failed: haproxy_nodes is not set correctly."
success_msg: "Test passed: haproxy_nodes is set correctly."

# =====================================================
# 💻 Start postgres_cluster_nodes Operations and Tests
# =====================================================

# 📝 Establishing test data for postgres_cluster_nodes
- name: Molecule.tests.rolesdeploy-finish.variables.haproxy_nodes | Establish postgres_cluster_nodes Test Data
run_once: true
ansible.builtin.set_fact:
postgres_cluster_nodes: >-
{{
groups['postgres_cluster']
| default([])
| map('extract', hostvars, 'inventory_hostname')
| join(',')
}}

# 🖨️ Debugging the established postgres_cluster_nodes
- name: Molecule.tests.rolesdeploy-finish.variables.haproxy_nodes | Debug postgres_cluster_nodes
run_once: true
ansible.builtin.debug:
var: postgres_cluster_nodes

# ✅ Verifying the correctness of the established postgres_cluster_nodes
# If the postgres_cluster_nodes is not set, the test fails and an error message is displayed
- name: Molecule.tests.rolesdeploy-finish.variables.haproxy_nodes | Verify postgres_cluster_nodes
run_once: true
ansible.builtin.assert:
that:
- "postgres_cluster_nodes is not none"
- "postgres_cluster_nodes != 'N/A'"
- "postgres_cluster_nodes == 'una.name,10.172.0.21,10.172.0.22'"
fail_msg: "Test failed: postgres_cluster_nodes is not set correctly."
success_msg: "Test passed: postgres_cluster_nodes is set correctly."
13 changes: 13 additions & 0 deletions molecule/tests/roles/haproxy/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
# 🚀 The purpose of this task is to incorporate a series of variable tests for HAProxy, a reliable, high performance TCP/HTTP load balancer
# 🎯 The objective is to ensure that the variables used in the HAProxy configuration are correctly defined and functional

# 🔄 Including variable tests for HAProxy
# This task iterates over all the YAML files in the 'variables' directory, and includes each file's tasks in the current playbook
# If a variable test fails, it will be immediately apparent, aiding in debugging and ensuring the robustness of the HAProxy configuration
- name: Molecule.tests.roles.haproxy.main | Incorporate Variable Tests
run_once: true
ansible.builtin.include_tasks: "{{ molecule_tests_roles_haproxy_main_file }}"
loop: "{{ lookup('fileglob', 'variables/*.yml', wantlist=True) }}"
loop_control:
loop_var: molecule_tests_roles_haproxy_main_file
Loading