b099b439b4
More importantly, put the log collection in an always section of block, otherwise we won't get logs if a playbook fails, which is pretty much exactly when we want to get logs. Change-Id: Ia8e581e522f75a5f5945bc2143eec63b93381a94
56 lines
2.2 KiB
YAML
56 lines
2.2 KiB
YAML
- hosts: localhost
|
|
tasks:
|
|
- name: Add bridge.o.o to inventory
|
|
add_host:
|
|
name: bridge.openstack.org
|
|
ansible_python_interpreter: python3
|
|
ansible_user: zuulcd
|
|
|
|
- hosts: localhost
|
|
tasks:
|
|
- name: Add bridge.o.o hostkey to known hosts
|
|
known_hosts:
|
|
name: bridge.openstack.org
|
|
key: "bridge.openstack.org ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCxRzDkWvvVQtsLTAqAwedRWA84/42KKVdFS0QP8lZFsMpgTXUhjipJ7VcFun5gM87tnt0J71rlN+ospBh0/1wfp2jASEskUyGhXAa5xHjnJN7veUyW+AggEosK/OTunvZgf54p1sQg45Sq/uCjc0Ua0fRMOq2o5z/mgpl6rSjLOlWi9wKA/6axnUbs9w4iD5esyBQ+VcISSJOTqhAo/3UG0NwCU+6Ggwwhg0nl5iCMpQfq4A207IbJ72MkJzlQgW3edsRb5POzdZcGxkTYvVdP3kgHP4Bof3MFFZjBUMz6SuRQyNV5poysMtbtlO0SvgAJNhXr6Vn0GA9XhqFP6+HT"
|
|
|
|
- hosts: bridge.openstack.org
|
|
tasks:
|
|
- name: Ensure run dir
|
|
file:
|
|
state: directory
|
|
path: /var/run/ansible
|
|
|
|
- name: Run the production playbook and capture logs
|
|
block:
|
|
|
|
- name: Log a playbook start header
|
|
become: yes
|
|
shell: 'echo "Running {{ ansible_date_time.iso8601 }}: ansible-playbook -v -f {{ ansible_forks }} /opt/system-config/playbooks/{{ playbook_name }}" > /var/log/ansible/{{ playbook_name }}.log'
|
|
|
|
- name: Run specified playbook on bridge.o.o and redirect output
|
|
become: yes
|
|
shell: 'ansible-playbook -v -f {{ ansible_forks }} /opt/system-config/playbooks/{{ playbook_name }} >> /var/log/ansible/{{ playbook_name }}.log'
|
|
|
|
always:
|
|
|
|
# Not using normal zuul job roles as bridge.openstack.org is not a
|
|
# test node with all the normal bits in place.
|
|
- name: Collect log output
|
|
synchronize:
|
|
dest: "{{ zuul.executor.log_root }}/{{ playbook_name }}.log"
|
|
mode: pull
|
|
src: "/var/log/ansible/{{ playbook_name }}.log"
|
|
verify_host: true
|
|
when: infra_prod_playbook_collect_log
|
|
|
|
- name: Return playbook log artifact to Zuul
|
|
when: infra_prod_playbook_collect_log
|
|
zuul_return:
|
|
data:
|
|
zuul:
|
|
artifacts:
|
|
- name: "Playbook Log"
|
|
url: "{{ playbook_name }}.log"
|
|
metadata:
|
|
type: text
|