Merge "run-production-playbook: rename with original timestamp"
This commit is contained in:
@@ -81,11 +81,17 @@
|
|||||||
metadata:
|
metadata:
|
||||||
type: text
|
type: text
|
||||||
|
|
||||||
# If we aren't publishing logs through zuul then keep a set on
|
# Save files locally on bridge
|
||||||
# bridge directly.
|
- name: Get original timestamp from file header
|
||||||
- name: Get a current timestamp
|
shell: |
|
||||||
|
head -1 /var/log/ansible/{{ playbook_name.log }} | sed -n 's/^Running \(.*\):.*$/\1/p'
|
||||||
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
|
register: _log_timestamp
|
||||||
|
|
||||||
|
- name: Turn timestamp into a string
|
||||||
set_fact:
|
set_fact:
|
||||||
_log_timestamp: "{{ lookup('pipe', 'date +%Y-%m-%dT%H:%M:%S') }}"
|
_log_timestamp: '{{ _log_timestamp.stdout | trim }}'
|
||||||
|
|
||||||
- name: Rename playbook log on bridge
|
- name: Rename playbook log on bridge
|
||||||
when: not infra_prod_playbook_collect_log
|
when: not infra_prod_playbook_collect_log
|
||||||
@@ -95,6 +101,17 @@
|
|||||||
src: "/var/log/ansible/{{ playbook_name }}.log"
|
src: "/var/log/ansible/{{ playbook_name }}.log"
|
||||||
dest: "/var/log/ansible/{{ playbook_name }}.log.{{ _log_timestamp }}"
|
dest: "/var/log/ansible/{{ playbook_name }}.log.{{ _log_timestamp }}"
|
||||||
|
|
||||||
|
# Reset the access/modification time to the timestamp in the filename; this
|
||||||
|
# makes lining things up more logical
|
||||||
|
- name: Reset file time
|
||||||
|
file:
|
||||||
|
src: '/var/log/ansible/{{ playbook_name }}.log.{{ _log_timestamp }}'
|
||||||
|
state: touch
|
||||||
|
modification_time: '{{ _log_timestamp }}'
|
||||||
|
modification_time_format: '%Y-%m%-%dT%H:%M:%S'
|
||||||
|
access_time: '{{ _log_timestamp }}'
|
||||||
|
access_time_format: '%Y-%m%-%dT%H:%M:%S'
|
||||||
|
|
||||||
- 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
|
||||||
become: yes
|
become: yes
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
set_fact:
|
set_fact:
|
||||||
_log_timestamp: "{{ lookup('pipe', 'date +%Y-%m-%dT%H:%M:%S') }}"
|
_log_timestamp: "{{ lookup('pipe', 'date +%Y-%m-%dT%H:%M:%S') }}"
|
||||||
|
|
||||||
|
# NOTE(ianw) : this gets parsed by the post playbook. If this
|
||||||
|
# is updated, that parsing should be too
|
||||||
- name: Log a playbook start header
|
- name: Log a playbook start header
|
||||||
become: yes
|
become: yes
|
||||||
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'
|
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'
|
||||||
|
|||||||
Reference in New Issue
Block a user