From c43f7364879ed6f18796c532ca31f9a8cff5eaff Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 20 Nov 2023 01:25:24 +0100 Subject: ppa: derive the distribution automatically --- roles/ppa/defaults/main.yml | 1 - roles/ppa/tasks/main.yml | 17 +++++++++++++++-- roles/ppa/vars/Debian_10.yml | 1 + roles/ppa/vars/Debian_11.yml | 1 + roles/ppa/vars/Debian_12.yml | 1 + roles/ppa/vars/Debian_9.yml | 1 + roles/ppa/vars/Ubuntu.yml | 1 + 7 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 roles/ppa/vars/Debian_10.yml create mode 100644 roles/ppa/vars/Debian_11.yml create mode 100644 roles/ppa/vars/Debian_12.yml create mode 100644 roles/ppa/vars/Debian_9.yml create mode 100644 roles/ppa/vars/Ubuntu.yml diff --git a/roles/ppa/defaults/main.yml b/roles/ppa/defaults/main.yml index c5b9e09..8aaa24f 100644 --- a/roles/ppa/defaults/main.yml +++ b/roles/ppa/defaults/main.yml @@ -1,4 +1,3 @@ #ppa_name: #ppa_key: #ppa_owner: -#ppa_distro: diff --git a/roles/ppa/tasks/main.yml b/roles/ppa/tasks/main.yml index e71a2a8..4a86ced 100644 --- a/roles/ppa/tasks/main.yml +++ b/roles/ppa/tasks/main.yml @@ -1,6 +1,19 @@ - name: Get host distro ansible.builtin.setup: - gather_subset: [distribution_release] + gather_subset: + - distribution + - distribution_major_version + - distribution_release + - os_family + +- name: Set platform-specific variables + ansible.builtin.include_vars: "{{ __ppa_vars_file }}" + loop: + - "{{ ansible_facts['os_family'] }}.yml" + - "{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}.yml" + vars: + __ppa_vars_file: "{{ role_path }}/vars/{{ item }}" + when: __ppa_vars_file is file - name: Set up PPA repository ansible.builtin.include_role: @@ -9,4 +22,4 @@ apt_repo_name: '{{ ppa_name }}' apt_repo_key_url: 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x{{ ppa_key }}' apt_repo_url: 'https://ppa.launchpadcontent.net/{{ ppa_owner }}/{{ ppa_name }}/ubuntu' - apt_repo_distro: '{{ ppa_distro | default(ansible_distribution_release) }}' + apt_repo_distro: '{{ ppa_distro }}' diff --git a/roles/ppa/vars/Debian_10.yml b/roles/ppa/vars/Debian_10.yml new file mode 100644 index 0000000..0913769 --- /dev/null +++ b/roles/ppa/vars/Debian_10.yml @@ -0,0 +1 @@ +ppa_distro: bionic diff --git a/roles/ppa/vars/Debian_11.yml b/roles/ppa/vars/Debian_11.yml new file mode 100644 index 0000000..abd3f09 --- /dev/null +++ b/roles/ppa/vars/Debian_11.yml @@ -0,0 +1 @@ +ppa_distro: focal diff --git a/roles/ppa/vars/Debian_12.yml b/roles/ppa/vars/Debian_12.yml new file mode 100644 index 0000000..3960beb --- /dev/null +++ b/roles/ppa/vars/Debian_12.yml @@ -0,0 +1 @@ +ppa_distro: jammy diff --git a/roles/ppa/vars/Debian_9.yml b/roles/ppa/vars/Debian_9.yml new file mode 100644 index 0000000..983186c --- /dev/null +++ b/roles/ppa/vars/Debian_9.yml @@ -0,0 +1 @@ +ppa_distro: xenial diff --git a/roles/ppa/vars/Ubuntu.yml b/roles/ppa/vars/Ubuntu.yml new file mode 100644 index 0000000..8dc9312 --- /dev/null +++ b/roles/ppa/vars/Ubuntu.yml @@ -0,0 +1 @@ +ppa_distro: '{{ ansible_distribution_release }}' -- cgit v1.2.3