85 lines
2.5 KiB
YAML
85 lines
2.5 KiB
YAML
---
|
|
- name: Converge
|
|
hosts: all
|
|
tasks:
|
|
|
|
- name: "List available plugins"
|
|
shell: |
|
|
export PATH=$PATH:/usr/local/sbin:/usr/sbin
|
|
source {{ infrared_venv }}/bin/activate
|
|
ir plugin list
|
|
args:
|
|
executable: /bin/bash
|
|
register: plugin_output
|
|
changed_when: false
|
|
|
|
- name: "Verify playbook list plugins output"
|
|
debug:
|
|
msg: "{{ plugin_output }}"
|
|
|
|
- name: "Check if ansible-role-collect-logs is present"
|
|
fail:
|
|
msg: "ansible-role-collect-logs not installed"
|
|
when: "'ansible-role-collect-logs' not in plugin_output.stdout"
|
|
|
|
- name: Get directory with collected log files
|
|
stat:
|
|
path: "{{ infrared_location }}/collected_files_test"
|
|
register:
|
|
collected_files_dir
|
|
|
|
- name: Ensure directory with collected log files is created
|
|
assert:
|
|
that:
|
|
- collected_files_dir.stat.exists
|
|
|
|
- name: Get the stats of collected files
|
|
stat:
|
|
path: "{{ item }}"
|
|
register: collected_files_stats
|
|
loop:
|
|
- "{{ infrared_location }}/collected_files_test/localhost/tmp/dummy.log.gz"
|
|
- "{{ infrared_location }}/collected_files_test/localhost/tmp/1MB_dummy.log.gz"
|
|
- "{{ infrared_location }}/collected_files_test/localhost/tmp/just_file.gz"
|
|
- "{{ infrared_location }}/collected_files_test/localhost/tmp/config.conf.gz"
|
|
|
|
- name: Ensure all files were collected
|
|
assert:
|
|
that:
|
|
- item.stat.exists
|
|
loop: "{{ collected_files_stats.results }}"
|
|
|
|
- name: Get the stats of excluded files
|
|
stat:
|
|
path: "{{ item }}"
|
|
register: excluded_files_stats
|
|
loop:
|
|
- "{{ infrared_location }}/collected_files_test/localhost/tmp/exclude.log.gz"
|
|
- "{{ infrared_location }}/collected_files_test/localhost/tmp/exclude_append.log.gz"
|
|
|
|
- name: Ensure excluded files were not collected
|
|
assert:
|
|
that:
|
|
- not item.stat.exists
|
|
loop: "{{ excluded_files_stats.results }}"
|
|
|
|
- name: Get tar files with logs
|
|
find: paths={{ infrared_location }}/collected_files_test/ patterns='*.tar'
|
|
register: tar_files
|
|
|
|
- name: Ensure .tar files with logs are deleted
|
|
assert:
|
|
that:
|
|
- tar_files.matched == 0
|
|
|
|
- name: Get file generated by find
|
|
stat:
|
|
path: /tmp/localhost-rsync-list
|
|
register:
|
|
rsync_list
|
|
|
|
- name: Ensure that find is used to generate list of files for rsync
|
|
assert:
|
|
that:
|
|
- rsync_list.stat.exists
|