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

Change log file path for pre/post deploy commands to /var/tmp #894

Merged
merged 1 commit into from
Feb 14, 2025
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
20 changes: 10 additions & 10 deletions automation/deploy_pgcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
when: pre_deploy_command_print | default(false) | bool

- name: Run pre-deploy command
ansible.builtin.shell: "{{ pre_deploy_command }} > /tmp/pre_deploy_command.log 2>&1"
ansible.builtin.shell: "{{ pre_deploy_command }} > {{ pre_deploy_command_log | default('/var/tmp/pre_deploy_command.log') }} 2>&1"
args:
executable: /bin/bash
register: pre_deploy_result
Expand All @@ -165,8 +165,8 @@
- item.ansible_job_id is defined

- name: Get pre-deploy command log
ansible.builtin.command: cat /tmp/pre_deploy_command.log
register: pre_deploy_command_log
ansible.builtin.command: "cat {{ pre_deploy_command_log | default('/var/tmp/pre_deploy_command.log') }}"
register: pre_deploy_log_content
delegate_to: "{{ item }}"
loop: "{{ pre_deploy_command_hosts.split(',') | map('extract', groups) | list | flatten }}"
changed_when: false
Expand All @@ -175,11 +175,11 @@
- name: Print pre-deploy command result
ansible.builtin.debug:
msg: "{{ item.stdout_lines }}"
loop: "{{ pre_deploy_command_log.results }}"
loop: "{{ pre_deploy_log_content.results }}"
loop_control:
label: "{{ item.item }}"
when:
- pre_deploy_command_log.results is defined
- pre_deploy_log_content.results is defined
- item.stdout_lines is defined

- name: Stop if pre-deploy command failed
Expand Down Expand Up @@ -410,7 +410,7 @@
when: post_deploy_command_print | default(false) | bool

- name: Run post-deploy command
ansible.builtin.shell: "{{ post_deploy_command }} > /tmp/post_deploy_command.log 2>&1"
ansible.builtin.shell: "{{ post_deploy_command }} > {{ post_deploy_command_log | default('/var/tmp/post_deploy_command.log') }} 2>&1"
args:
executable: /bin/bash
register: post_deploy_result
Expand All @@ -436,8 +436,8 @@
- item.ansible_job_id is defined

- name: Get post-deploy command log
ansible.builtin.command: cat /tmp/post_deploy_command.log
register: post_deploy_command_log
ansible.builtin.command: "cat {{ post_deploy_command_log | default('/var/tmp/post_deploy_command.log') }}"
register: post_deploy_log_content
delegate_to: "{{ item }}"
loop: "{{ post_deploy_command_hosts.split(',') | map('extract', groups) | list | flatten }}"
changed_when: false
Expand All @@ -446,11 +446,11 @@
- name: Print post-deploy command result
ansible.builtin.debug:
msg: "{{ item.stdout_lines }}"
loop: "{{ post_deploy_command_log.results }}"
loop: "{{ post_deploy_log_content.results }}"
loop_control:
label: "{{ item.item }}"
when:
- post_deploy_command_log.results is defined
- post_deploy_log_content.results is defined
- item.stdout_lines is defined

- name: Stop if post-deploy command failed
Expand Down
2 changes: 2 additions & 0 deletions automation/vars/system.yml
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,13 @@ pre_deploy_command_timeout: 3600 # Timeout in seconds
pre_deploy_command_hosts: "postgres_cluster" # host groups where the pre_deploy_command should be executed
pre_deploy_command_print: true # Print the command in the ansible log
pre_deploy_command_print_result: true # Print the result of the command execution to the ansible log
pre_deploy_command_log: "/var/tmp/pre_deploy_command.log"

post_deploy_command: "" # Command or script to be executed after the Postgres cluster deployment
post_deploy_command_timeout: 3600 # Timeout in seconds
post_deploy_command_hosts: "postgres_cluster" # host groups where the post_deploy_command should be executed
post_deploy_command_print: true # Print the command in the ansible log
post_deploy_command_print_result: true # Print the result of the command execution to the ansible log
post_deploy_command_log: "/var/tmp/post_deploy_command.log"

...