mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 02:15:17 +00:00
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:
parent
77e47a2476
commit
2b17fe73e9
3 changed files with 16 additions and 0 deletions
|
|
@ -121,3 +121,11 @@ network_packages: "{{
|
|||
__network_provider_setup[network_provider]['packages'] }}"
|
||||
network_service_name: "{{
|
||||
__network_provider_setup[network_provider]['service_name'] }}"
|
||||
|
||||
# ansible_facts required by the role
|
||||
__network_required_facts:
|
||||
- distribution
|
||||
- distribution_major_version
|
||||
- distribution_version
|
||||
- os_family
|
||||
- python
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
---
|
||||
- name: Test executing the role with default parameters
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
roles:
|
||||
- linux-system-roles.network
|
||||
tasks:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue