ansible-role-collect-logs/roles/collect_logs/molecule/infrared/converge.yml

100 lines
3.2 KiB
YAML

---
- name: Converge
hosts: all
tasks:
- name: "Download Infrared"
git:
repo: "https://github.com/redhat-openstack/infrared.git"
version: "master"
dest: "{{ infrared_location }}"
update: true
- name: "Create Infrared venv"
pip:
name:
- pbr
- pip
- setuptools
virtualenv: "{{ infrared_venv }}"
- name: "Install Infrared"
# this task is always changed, the problem is on pip module side:
# https://github.com/ansible/ansible/issues/28952
pip:
name: "."
virtualenv: "{{ infrared_venv }}"
chdir: "{{ infrared_location }}"
- name: "Create infrared_plugin dir"
file:
path: "{{ infrared_location }}/infrared_plugin"
state: directory
mode: 0755
- name: "Copy ansible-role-collect-logs to test host"
synchronize:
src: "{{ playbook_dir }}/../../../../"
dest: "{{ ansible_env.HOME }}/artcl-src"
rsync_opts:
- "--exclude=.tox"
- name: "Install ansible-role-collect-logs plugin"
shell: |
export PATH=$PATH:/usr/local/sbin:/usr/sbin
source {{ infrared_venv }}/bin/activate
ir plugin add {{ ansible_env.HOME }}/artcl-src --src-path infrared_plugin
args:
executable: /bin/bash
register: plugin_install_output
changed_when: true
- name: "Debug: output from plugin installation task main playbook"
debug:
msg: "{{ plugin_install_output }}"
- name: "Create an empty dummy file"
file:
path: "{{ item }}"
state: touch
mode: 0644
with_items:
- "/tmp/dummy.log"
- "/tmp/append.log"
- "/tmp/exclude.log"
- "/tmp/exclude_append.log"
- "/tmp/config.conf"
- "/tmp/just_file"
changed_when: false
- name: "Create a dummy file of 1MB"
command: dd if=/dev/urandom of=/tmp/1MB_dummy.log bs=1MB count=1
args:
creates: "/tmp/1MB_dummy.log"
changed_when: false
- name: "Run infrared ansible-role-collect-logs"
become: false
shell: |
export PATH=$PATH:/usr/local/sbin:/usr/sbin
source {{ infrared_venv }}/bin/activate
ir ansible-role-collect-logs --openstack_nodes localhost \
--collect_log_types "testing" \
--artcl_collect_dir {{ infrared_location }}/collected_files_test \
--artcl_collect_list /tmp/*.log,/tmp/just_file \
--artcl_collect_list_append /tmp/config.conf \
--artcl_exclude_list /tmp/exclude.log \
--artcl_exclude_list_append /tmp/exclude_append.log \
--artcl_gzip true \
--artcl_rsync_collect_list false \
--local_working_dir "{{ infrared_location }}" \
--disable_artifacts_cleanup true
args:
executable: /bin/bash
register: output_collection
changed_when: true
- name: "Debug collection output"
debug:
msg: "{{ output_collection }}"