production-playbook logs : don't use ansible_date_time
ansible_date_time is actually the cached fact time that has little bearing on the actual time this is running [1] -- which is what you want to see when, for example, tracing backwards to see why some runs are randomly timing out. [1] https://docs.ansible.com/ansible/latest/user_guide/playbooks_vars_facts.html#ansible-facts Change-Id: I8b5559178e29f8604edf6a42507322fc928afb21
This commit is contained in:
parent
87306d239d
commit
3ab81bb834
@ -16,9 +16,13 @@
|
|||||||
- name: Run the production playbook and capture logs
|
- name: Run the production playbook and capture logs
|
||||||
block:
|
block:
|
||||||
|
|
||||||
|
- name: Get a current timestamp
|
||||||
|
set_fact:
|
||||||
|
_log_timestamp: "{{ lookup('pipe', 'date +%Y-%m-%dT%H:%M:%S') }}"
|
||||||
|
|
||||||
- name: Log a playbook start header
|
- name: Log a playbook start header
|
||||||
become: yes
|
become: yes
|
||||||
shell: 'echo "Running {{ ansible_date_time.iso8601 }}: ansible-playbook -v -f {{ infra_prod_ansible_forks }} /home/zuul/src/opendev.org/opendev/system-config/playbooks/{{ playbook_name }}" > /var/log/ansible/{{ playbook_name }}.log'
|
shell: 'echo "Running {{ _log_timestamp }}: ansible-playbook -v -f {{ infra_prod_ansible_forks }} /home/zuul/src/opendev.org/opendev/system-config/playbooks/{{ playbook_name }}" > /var/log/ansible/{{ playbook_name }}.log'
|
||||||
|
|
||||||
- name: Run specified playbook on bridge.o.o and redirect output
|
- name: Run specified playbook on bridge.o.o and redirect output
|
||||||
become: yes
|
become: yes
|
||||||
@ -113,7 +117,7 @@
|
|||||||
copy:
|
copy:
|
||||||
remote_src: yes
|
remote_src: yes
|
||||||
src: "/var/log/ansible/{{ playbook_name }}.log"
|
src: "/var/log/ansible/{{ playbook_name }}.log"
|
||||||
dest: "/var/log/ansible/{{ playbook_name }}.log.{{ ansible_date_time.iso8601 }}"
|
dest: "/var/log/ansible/{{ playbook_name }}.log.{{ _log_timestamp }}"
|
||||||
|
|
||||||
- name: Cleanup old playbook logs on bridge
|
- name: Cleanup old playbook logs on bridge
|
||||||
when: not infra_prod_playbook_collect_log
|
when: not infra_prod_playbook_collect_log
|
||||||
|
Loading…
x
Reference in New Issue
Block a user