ansible-role-collect-logs/infrared_plugin/main.yml

76 lines
2.2 KiB
YAML

---
# This file and plugin.spec are required by Infrared project
# This section collects data from the nodes
- hosts: "{{ other.openstack_nodes }}"
remote_user: "{{ other.remote_user }}"
ignore_errors: true
gather_facts: false
vars:
ansible_python_interpreter: "{{ py_interpreter.get('stdout_lines', ['/usr/libexec/platform-python']) | first | trim }}"
tasks:
- name: Detect python interpreter
raw: 'command -v python3 python2 /usr/libexec/platform-python'
register: py_interpreter
- name: Gather facts
setup:
- name: Remap infrared parameters to role variables
set_fact:
"{{ item.key }}": "{{ item.value }}"
with_dict: "{{ other }}"
- name: Ansible role collect logs
include_role:
name: collect_logs
# This section takes care of preparing the collected data for publishing
# and for publishing itself
- hosts: localhost
ignore_errors: true
tasks:
- name: Remap infrared parameters to role variables
set_fact:
"{{ item.key }}": "{{ item.value }}"
with_dict: "{{ other }}"
- name: Disable artcl_collect to prepare for publishing
set_fact:
# override artcl_collect to false because in ansible-role-collect-logs
# role collect and publish tasks are complementary
artcl_collect: false
when: artcl_publish|default(false)|bool
- name: Set path to a report server key
set_fact:
artcl_report_server_key: "-i {{ artcl_report_server_key }}"
when: artcl_report_server_key is defined
- name: Extract the logs
shell: |
cat *.tar | tar xf - -i
args:
chdir: "{{ artcl_collect_dir }}"
executable: /bin/bash
- name: delete the tar file after extraction
shell: |
rm -r *.tar
args:
chdir: "{{ artcl_collect_dir }}"
executable: /bin/bash
- name: Ansible role collect logs
include_role:
name: collect_logs
when: artcl_publish|default(false)|bool
- name: Delete artifact files from localhost
file:
state: absent
path: "{{ artcl_collect_dir }}"
when: not disable_artifacts_cleanup | default(false) | bool