Skip to content

Commit

Permalink
support gather_facts: false; support setup-snapshot.yml
Browse files Browse the repository at this point in the history
Some users use `gather_facts: false` in their playbooks.  This changes
the role to work in that case, by gathering only the facts it requires
to run.
CI testing can be sped up by creating a snapshot image pre-installed
with packages.  tests/setup-snapshot.yml can be used by a CI system
to do this.

Logging role tests used to check installed packages are necessary and
sufficient. Also, they uninstalled the installed packages at the end
of each test. They are eliminated since it'd get broken when the pre-
installed snapshot image is used.

- Remove the unnecessary setup task from tests_include_vars_from_parent.yml.

- Run set_vars.yml in the roles/rsyslog/tasks level via the logging role.

- To gather the all package names to be installed in tests/setup-
  snapshot.yml, set __snapshot_gather_vars to true.

- Improved the way how to get the packages to be installed then install
  them using the info. (using varnames lookup)

- tests/setup-snapshot.yml needs to gather the necessary ansible facts
  and the packages to be used in the series of tests. The task is done
  using the logging role where only gathering but no other tasks is
  executed.

- In ovirt/set_vars.yml, replacing default_ipv4 with network since gather_
  subset only takes allowed keywords.
  • Loading branch information
nhosoi committed Apr 26, 2022
1 parent b220c21 commit c7c6483
Show file tree
Hide file tree
Showing 21 changed files with 490 additions and 674 deletions.
8 changes: 8 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,11 @@ logging_files_template_format: ""
# Output forward format
# Allowed values: "traditional", "syslog", or "modern"; default to "modern"
logging_forwards_template_format: ""

# ansible_facts required by the role
__logging_required_facts:
- distribution
- distribution_major_version
- distribution_version
- os_family
- default_ipv4
13 changes: 2 additions & 11 deletions roles/rsyslog/tasks/inputs/ovirt/main.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
---
# yamllint disable rule:line-length
- name: Set platform/version specific variables
include_vars: "{{ item }}"
loop:
- "{{ role_path }}/vars/inputs/ovirt/default.yml"
- "{{ role_path }}/vars/inputs/ovirt/{{ ansible_facts['os_family'] }}.yml"
- "{{ role_path }}/vars/inputs/ovirt/{{ ansible_facts['distribution'] }}.yml"
- "{{ role_path }}/vars/inputs/ovirt/{{ ansible_facts['distribution'] }}_\
{{ ansible_facts['distribution_major_version'] }}.yml"
- "{{ role_path }}/vars/inputs/ovirt/{{ ansible_facts['distribution'] }}_\
{{ ansible_facts['distribution_version'] }}.yml"
when: item is file
- name: Set ovirt platform/version specific variables
include_tasks: "{{ role_path }}/tasks/inputs/ovirt/set_vars.yml"

# yamllint enable rule:line-length
# Deploy configuration files
Expand Down
23 changes: 23 additions & 0 deletions roles/rsyslog/tasks/inputs/ovirt/set_vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
# SPDX-License-Identifier: GPL-3.0-only

- name: Ensure ansible_facts used by role
setup:
gather_subset:
- min
- network
when: not ansible_facts.keys() | list |
intersect(__logging_required_facts) == __logging_required_facts

- name: Set platform/version specific variables
include_vars: "{{ item }}"
loop:
- "{{ role_path }}/vars/inputs/ovirt/default.yml"
- "{{ role_path }}/vars/inputs/ovirt/{{ ansible_facts['os_family'] }}.yml"
- "{{ role_path }}/vars/inputs/ovirt/{{ ansible_facts['distribution'] }}.\
yml"
- "{{ role_path }}/vars/inputs/ovirt/{{ ansible_facts['distribution'] }}_\
{{ ansible_facts['distribution_major_version'] }}.yml"
- "{{ role_path }}/vars/inputs/ovirt/{{ ansible_facts['distribution'] }}_\
{{ ansible_facts['distribution_version'] }}.yml"
when: item is file
Loading

0 comments on commit c7c6483

Please sign in to comment.