support playbooks which use gather_facts: false

Some users prefer to use `gather_facts: false` in their playbooks.
However, the network role requires certain ansible_facts to be set.  If
the user wants to use the network role with `gather_facts: false`, the
role will gather the minimum subset of facts required.  If the user does
not want the role to gather facts, the user can either not use the
network role, or ensure that all required facts are in the facts cache.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
This commit is contained in:
Rich Megginson 2022-04-12 14:03:45 -06:00 committed by Till Maas
parent 77e47a2476
commit 2b17fe73e9
3 changed files with 16 additions and 0 deletions

View file

@ -1,6 +1,13 @@
# SPDX-License-Identifier: BSD-3-Clause
# get service facts, used in defaults/main.yml
---
- name: Ensure ansible_facts used by role
setup:
gather_subset: min
when: not ansible_facts.keys() | list |
intersect(__network_required_facts) == __network_required_facts
no_log: true
- name: Check which services are running
service_facts:
no_log: true