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

Syntax problem with cron wal-g command #658

Merged
merged 4 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 8 additions & 8 deletions molecule/tests/variables/asserts/wal_g_cron_jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
run_once: true
ansible.builtin.assert:
that:
- wal_g_backup_command[0] == "[ $(curl -s -o /dev/null -w '%{http_code}' http://{{ inventory_hostname }}:{{ patroni_restapi_port }}) = '200' ]"
- wal_g_backup_command[1] == " && wal-g backup-push {{ postgresql_data_dir }} > {{ postgresql_log_dir }}/walg_backup.log 2>&1"
- wal_g_delete_command[0] == "[ $(curl -s -o /dev/null -w '%{http_code}' http://{{ inventory_hostname }}:{{ patroni_restapi_port }}) = '200' ]"
- wal_g_delete_command[1] == " && wal-g delete retain FULL 4 --confirm > {{ postgresql_log_dir }}/walg_delete.log 2>&1"
- wal_g_backup_command[0] == "curl -I -s http://{{ inventory_hostname }}:{{ patroni_restapi_port }} | grep 200"
- wal_g_backup_command[1] == " && wal-g --config {{ postgresql_home_dir }}/.walg.json backup-push {{ postgresql_data_dir }} > {{ postgresql_log_dir }}/walg_backup.log 2>&1"

Check failure on line 28 in molecule/tests/variables/asserts/wal_g_cron_jobs.yml

View workflow job for this annotation

GitHub Actions / build

28:161 [line-length] line too long (178 > 160 characters)

Check failure on line 28 in molecule/tests/variables/asserts/wal_g_cron_jobs.yml

View workflow job for this annotation

GitHub Actions / build

yaml[line-length]

Line too long (178 > 160 characters)
vitabaks marked this conversation as resolved.
Show resolved Hide resolved
- wal_g_delete_command[0] == "curl -I -s http://{{ inventory_hostname }}:{{ patroni_restapi_port }} | grep 200"
- wal_g_delete_command[1] == " && wal-g --config {{ postgresql_home_dir }}/.walg.json delete retain FULL 4 --confirm > {{ postgresql_log_dir }}/walg_delete.log 2>&1"

Check failure on line 30 in molecule/tests/variables/asserts/wal_g_cron_jobs.yml

View workflow job for this annotation

GitHub Actions / build

30:161 [line-length] line too long (171 > 160 characters)

Check failure on line 30 in molecule/tests/variables/asserts/wal_g_cron_jobs.yml

View workflow job for this annotation

GitHub Actions / build

yaml[line-length]

Line too long (171 > 160 characters)
fail_msg: "Test failed: wal_g_backup_command or wal_g_delete_command do not have the expected content."
success_msg: "Test passed: wal_g_backup_command and wal_g_delete_command have the expected content."

Expand All @@ -45,7 +45,7 @@
- name: Molecule.tests.variables.asserts.wal_g_cron_jobs | Debian | Define Expected First wal_g_cron Job
run_once: true
ansible.builtin.set_fact: # yamllint disable rule:line-length
origin_wal_g_cron_jobs_create_job: "[ $(curl -s -o /dev/null -w '%{http_code}' http://{{ inventory_hostname }}:{{ patroni_restapi_port }}) = '200' ] && wal-g backup-push {{ postgresql_data_dir }} > {{ postgresql_log_dir }}/walg_backup.log 2>&1"
origin_wal_g_cron_jobs_create_job: "curl -I -s http://{{ inventory_hostname }}:{{ patroni_restapi_port }} | grep 200 && wal-g --config {{ postgresql_home_dir }}/.walg.json backup-push {{ postgresql_data_dir }} > {{ postgresql_log_dir }}/walg_backup.log 2>&1"

# 🖨️ Display the first wal_g_cron job for Debian for debugging purposes
- name: Molecule.tests.variables.asserts.wal_g_cron_jobs | Debian | Debug First wal_g_cron Job
Expand All @@ -66,7 +66,7 @@
- name: Molecule.tests.variables.asserts.wal_g_cron_jobs | Debian | Define Expected Second wal_g_cron Job
run_once: true
ansible.builtin.set_fact: # yamllint disable rule:line-length
origin_wal_g_cron_jobs_delete_job: "[ $(curl -s -o /dev/null -w '%{http_code}' http://{{ inventory_hostname }}:{{ patroni_restapi_port }}) = '200' ] && wal-g delete retain FULL 4 --confirm > {{ postgresql_log_dir }}/walg_delete.log 2>&1"
origin_wal_g_cron_jobs_delete_job: "curl -I -s http://{{ inventory_hostname }}:{{ patroni_restapi_port }} | grep 200 && wal-g --config {{ postgresql_home_dir }}/.walg.json delete retain FULL 4 --confirm > {{ postgresql_log_dir }}/walg_delete.log 2>&1"

# 🖨️ Display the second wal_g_cron job for Debian for debugging purposes
- name: Molecule.tests.variables.asserts.wal_g_cron_jobs | Debian | Debug Second wal_g_cron Job
Expand Down Expand Up @@ -97,7 +97,7 @@
- name: Molecule.tests.variables.asserts.wal_g_cron_jobs | RedHat | Define Expected First wal_g_cron Job
run_once: true
ansible.builtin.set_fact: # yamllint disable rule:line-length
origin_wal_g_cron_jobs_create_job: "[ $(curl -s -o /dev/null -w '%{http_code}' http://{{ inventory_hostname }}:{{ patroni_restapi_port }}) = '200' ] && wal-g backup-push {{ postgresql_data_dir }} > {{ postgresql_log_dir }}/walg_backup.log 2>&1"
origin_wal_g_cron_jobs_create_job: "curl -I -s http://{{ inventory_hostname }}:{{ patroni_restapi_port }} | grep 200 && wal-g --config {{ postgresql_home_dir }}/.walg.json backup-push {{ postgresql_data_dir }} > {{ postgresql_log_dir }}/walg_backup.log 2>&1"

# 🖨️ Display the first wal_g_cron job for RedHat for debugging purposes
- name: Molecule.tests.variables.asserts.wal_g_cron_jobs | RedHat | Debug First wal_g_cron Job
Expand All @@ -118,7 +118,7 @@
- name: Molecule.tests.variables.asserts.wal_g_cron_jobs | RedHat | Define Expected Second wal_g_cron Job
run_once: true
ansible.builtin.set_fact: # yamllint disable rule:line-length
origin_wal_g_cron_jobs_delete_job: "[ $(curl -s -o /dev/null -w '%{http_code}' http://{{ inventory_hostname }}:{{ patroni_restapi_port }}) = '200' ] && wal-g delete retain FULL 4 --confirm > {{ postgresql_log_dir }}/walg_delete.log 2>&1"
origin_wal_g_cron_jobs_delete_job: "curl -I -s http://{{ inventory_hostname }}:{{ patroni_restapi_port }} | grep 200 && wal-g --config {{ postgresql_home_dir }}/.walg.json delete retain FULL 4 --confirm > {{ postgresql_log_dir }}/walg_delete.log 2>&1"

# 🖨️ Display the second wal_g_cron job for RedHat for debugging purposes
- name: Molecule.tests.variables.asserts.wal_g_cron_jobs | RedHat | Debug Second wal_g_cron Job
Expand Down
8 changes: 4 additions & 4 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -481,11 +481,11 @@ wal_g_patroni_cluster_bootstrap_command: "wal-g backup-fetch {{ postgresql_data_
# Define job_parts outside of wal_g_cron_jobs
# ⚠️ Ensure there is a space at the beginning of each part to prevent commands from concatenating.
wal_g_backup_command:
- "[ $(curl -s -o /dev/null -w '%{http_code}' http://{{ inventory_hostname }}:{{ patroni_restapi_port }}) = '200' ]"
- " && wal-g backup-push {{ postgresql_data_dir }} > {{ postgresql_log_dir }}/walg_backup.log 2>&1"
- "curl -I -s http://{{ inventory_hostname }}:{{ patroni_restapi_port }} | grep 200"
- " && wal-g --config {{ postgresql_home_dir }}/.walg.json backup-push {{ postgresql_data_dir }} > {{ postgresql_log_dir }}/walg_backup.log 2>&1"
wal_g_delete_command:
- "[ $(curl -s -o /dev/null -w '%{http_code}' http://{{ inventory_hostname }}:{{ patroni_restapi_port }}) = '200' ]"
- " && wal-g delete retain FULL 4 --confirm > {{ postgresql_log_dir }}/walg_delete.log 2>&1"
- "curl -I -s http://{{ inventory_hostname }}:{{ patroni_restapi_port }} | grep 200"
- " && wal-g --config {{ postgresql_home_dir }}/.walg.json delete retain FULL 4 --confirm > {{ postgresql_log_dir }}/walg_delete.log 2>&1"

wal_g_cron_jobs:
- name: "WAL-G: Create daily backup"
Expand Down
Loading