diff --git a/tasks/main.yml b/tasks/main.yml index 61fe89b..d8e5017 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,17 +2,7 @@ --- # Set up internal variables. - name: Set version specific variables - include_vars: "{{ lookup('first_found', ffparams) }}" - vars: - ffparams: - files: - - "{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_version'] }}.yml" # yamllint disable-line rule:line-length - - "{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}.yml" # yamllint disable-line rule:line-length - - "{{ ansible_facts['distribution'] }}.yml" - - "{{ ansible_facts['os_family'] }}.yml" - - "default.yml" - paths: - - "{{ role_path }}/vars" + include_tasks: set_vars.yml - name: Include the appropriate provider tasks include_tasks: "main-{{ nbde_client_provider }}.yml" diff --git a/tasks/set_vars.yml b/tasks/set_vars.yml new file mode 100644 index 0000000..648bf0e --- /dev/null +++ b/tasks/set_vars.yml @@ -0,0 +1,20 @@ +--- +- name: Ensure ansible_facts used by role + setup: + gather_subset: min + when: not ansible_facts.keys() | list | + intersect(__nbde_client_required_facts) == + __nbde_client_required_facts + +- name: Set platform/version specific variables + include_vars: "{{ lookup('first_found', ffparams) }}" + vars: + ffparams: + files: + - "{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_version'] }}.yml" # yamllint disable-line rule:line-length + - "{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}.yml" # yamllint disable-line rule:line-length + - "{{ ansible_facts['distribution'] }}.yml" + - "{{ ansible_facts['os_family'] }}.yml" + - "default.yml" + paths: + - "{{ role_path }}/vars" diff --git a/tests/setup-snapshot.yml b/tests/setup-snapshot.yml new file mode 100644 index 0000000..25a30a2 --- /dev/null +++ b/tests/setup-snapshot.yml @@ -0,0 +1,12 @@ +- hosts: all + tasks: + - name: Set platform/version specific variables + include_role: + name: linux-system-roles.nbde_client + tasks_from: set_vars.yml + public: true + + - name: Install test packages + package: + name: "{{ __nbde_client_packages }}" + state: present diff --git a/tests/tests_default.yml b/tests/tests_default.yml index e06c459..4c3cb51 100644 --- a/tests/tests_default.yml +++ b/tests/tests_default.yml @@ -1,7 +1,7 @@ --- - name: Ensure that the role runs with default parameters hosts: all - + gather_facts: false roles: - linux-system-roles.nbde_client diff --git a/vars/main.yml b/vars/main.yml index 009f09d..2b0cbc2 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -5,4 +5,11 @@ # Mostly useful when debugging/testing. __nbde_client_update_initramfs: yes +# ansible_facts required by the role +__nbde_client_required_facts: + - distribution + - distribution_major_version + - distribution_version + - os_family + # vim:set ts=2 sw=2 et: