diff --git a/tasks/set_vars.yml b/tasks/set_vars.yml index 0a07c3e..a765d4a 100644 --- a/tasks/set_vars.yml +++ b/tasks/set_vars.yml @@ -1,9 +1,9 @@ --- - name: Ensure ansible_facts used by role setup: - gather_subset: min - when: not ansible_facts.keys() | list | - intersect(__ssh_required_facts) == __ssh_required_facts + gather_subset: "{{ __ssh_required_facts_subsets }}" + when: __ssh_required_facts | + difference(ansible_facts.keys() | list) | length > 0 - name: Set platform/version specific variables include_vars: "{{ __vars_file }}" diff --git a/vars/main.yml b/vars/main.yml index 8801bd0..4e16d52 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -19,3 +19,9 @@ __ssh_required_facts: - distribution_major_version - distribution_version - os_family + +# the subsets of ansible_facts that need to be gathered in case any of the +# facts in required_facts is missing; see the documentation of +# the 'gather_subset' parameter of the 'setup' module +__ssh_required_facts_subsets: "{{ ['!all', '!min'] + + __ssh_required_facts }}"