Commit Graph
6 Commits
Author SHA1 Message Date
Rich MegginsonandRichard Megginson 091570301d test: ensure role gathers the facts it uses by having test clear_facts before include_role
The role gathers the facts it uses.  For example, if the user uses
`ANSIBLE_GATHERING=explicit`, the role uses the `setup` module with the
facts and subsets it requires.

This change allows us to test this.  Before every role invocation, the test
will use `meta: clear_facts` so that the role starts with no facts.

Create a task file tests/tasks/run_role_with_clear_facts.yml to do the tasks
to clear the facts and run the role.  Note that this means we don't need to
use `gather_facts` for the tests.

Some vars defined using `ansible_facts` have been changed to be defined with
`set_fact` instead.  This is because of the fact that `vars` are lazily
evaluated - the var might be referenced when the facts have been cleared, and
will issue an error like `ansible_facts["distribution"] is undefined`.  This is
typically done for blocks that have a `when` condition that uses `ansible_facts`
and the block has a role invocation using run_role_with_clear_facts.yml
These have been rewritten to define the `when` condition using `set_fact`.  This
is because the `when` condition is evaluated every time a task is invoked in the
block, and if the facts are cleared, this will raise an undefined variable error.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2026-03-19 09:18:34 -06:00
Rich MegginsonandRichard Megginson cc5de8664f feat: ensure role works on ostree systems
Ensure role works on ostree systems

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2025-01-31 15:35:25 -07:00
Rich MegginsonandRichard Megginson 129feb1ac1 test: add cleanup for cron test; fix formatting
Ensure cron test restores state of crontab after test.
Fix formatting in a few places.
Do not check ansible managed header and fingerprint unless the test
uses a custom template with header and fingerprint.
Use default for gather_facts unless otherwise needed.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2025-01-07 11:31:56 -07:00
Radovan SrokaandSergei Petrosian 2c0be7a450 Use command instead of shell
Signed-off-by: Radovan Sroka <rsroka@redhat.com>
2025-01-07 13:06:03 +01:00
Radovan SrokaandSergei Petrosian e9ddf8804c Fix suggestions
Signed-off-by: Radovan Sroka <rsroka@redhat.com>
2025-01-07 13:06:03 +01:00
Radovan SrokaandSergei Petrosian 49e267a29b feat: Allow setup aide inside of cron job
Signed-off-by: Radovan Sroka <rsroka@redhat.com>
2025-01-07 13:06:03 +01:00