From 45d559454357adb56a21743d8ab958c30a3ab847 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sun, 17 Mar 2024 15:26:51 +0100 Subject: make the mechanism of inclusion of platform-specific vars more uniform --- roles/docker/tasks/main.yml | 12 +++++++++--- roles/docker/vars/Debian.yml | 6 ++++++ roles/docker/vars/Ubuntu.yml | 1 + roles/docker/vars/main.yml | 7 ------- roles/ppa/tasks/main.yml | 3 ++- 5 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 roles/docker/vars/Debian.yml create mode 120000 roles/docker/vars/Ubuntu.yml delete mode 100644 roles/docker/vars/main.yml diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index a5327e0..26089f3 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -1,14 +1,20 @@ -- name: Ensure ansible_facts used by role +- name: Get host distro ansible.builtin.setup: - gather_subset: os_family + gather_subset: + - distribution + - distribution_major_version + - distribution_release + - os_family - name: Set platform-specific variables ansible.builtin.include_vars: "{{ __docker_vars_file }}" loop: - "{{ ansible_facts['os_family'] }}.yml" + - "{{ ansible_facts['distribution'] }}.yml" + - "{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}.yml" vars: __docker_vars_file: "{{ role_path }}/vars/{{ item }}" - when: __docker_vars_file is file + when: __docker_vars_file is exists - name: Configure Docker logging driver when: docker_logging_driver is defined and docker_logging_driver diff --git a/roles/docker/vars/Debian.yml b/roles/docker/vars/Debian.yml new file mode 100644 index 0000000..5ff84d1 --- /dev/null +++ b/roles/docker/vars/Debian.yml @@ -0,0 +1,6 @@ +docker_package_names: + - docker.io + - docker-compose +docker_service_name: docker +docker_prune_module_deps: + - python3-requests diff --git a/roles/docker/vars/Ubuntu.yml b/roles/docker/vars/Ubuntu.yml new file mode 120000 index 0000000..4e197bc --- /dev/null +++ b/roles/docker/vars/Ubuntu.yml @@ -0,0 +1 @@ +Debian.yml \ No newline at end of file diff --git a/roles/docker/vars/main.yml b/roles/docker/vars/main.yml deleted file mode 100644 index 1a8db5f..0000000 --- a/roles/docker/vars/main.yml +++ /dev/null @@ -1,7 +0,0 @@ -# Ubuntu/Debian: -docker_package_names: - - docker.io - - docker-compose -docker_service_name: docker -docker_prune_module_deps: - - python3-requests diff --git a/roles/ppa/tasks/main.yml b/roles/ppa/tasks/main.yml index 4a86ced..083acdd 100644 --- a/roles/ppa/tasks/main.yml +++ b/roles/ppa/tasks/main.yml @@ -10,10 +10,11 @@ ansible.builtin.include_vars: "{{ __ppa_vars_file }}" loop: - "{{ ansible_facts['os_family'] }}.yml" + - "{{ ansible_facts['distribution'] }}.yml" - "{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}.yml" vars: __ppa_vars_file: "{{ role_path }}/vars/{{ item }}" - when: __ppa_vars_file is file + when: __ppa_vars_file is exists - name: Set up PPA repository ansible.builtin.include_role: -- cgit v1.2.3