From 9cdcef9dca8548edee3438b4cf249f6fd49ee66b Mon Sep 17 00:00:00 2001 From: NaeiKinDus Date: Mon, 27 Nov 2023 00:00:00 +0000 Subject: [PATCH] feat(common): setup additional components to apt source list --- .../extensions/molecule/default/create.yml | 2 ++ .../roles/common/defaults/main.yml | 3 +++ .../roles/common/tasks/main.yml | 22 +++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/collections/ansible_collections/nullified/infrastructure/extensions/molecule/default/create.yml b/collections/ansible_collections/nullified/infrastructure/extensions/molecule/default/create.yml index ae51279..3b91987 100644 --- a/collections/ansible_collections/nullified/infrastructure/extensions/molecule/default/create.yml +++ b/collections/ansible_collections/nullified/infrastructure/extensions/molecule/default/create.yml @@ -51,6 +51,8 @@ hosts: "{{ item.name }}": ansible_connection: community.docker.docker + custom_common: + deb822_format: true ansible.builtin.set_fact: molecule_inventory: > {{ molecule_inventory | combine(inventory_partial_yaml | from_yaml) }} diff --git a/collections/ansible_collections/nullified/infrastructure/roles/common/defaults/main.yml b/collections/ansible_collections/nullified/infrastructure/roles/common/defaults/main.yml index f8c3f0f..b42ef36 100644 --- a/collections/ansible_collections/nullified/infrastructure/roles/common/defaults/main.yml +++ b/collections/ansible_collections/nullified/infrastructure/roles/common/defaults/main.yml @@ -8,3 +8,6 @@ common_gitconfig_force_sign: false common_gitconfig_signingkey: "" common_apt_packages: [] common_install_fonts: false +common: + apt_components: ['contrib', 'non-free', 'non-free-firmware'] + deb822_format: false diff --git a/collections/ansible_collections/nullified/infrastructure/roles/common/tasks/main.yml b/collections/ansible_collections/nullified/infrastructure/roles/common/tasks/main.yml index 6450a0c..a3fbf1b 100644 --- a/collections/ansible_collections/nullified/infrastructure/roles/common/tasks/main.yml +++ b/collections/ansible_collections/nullified/infrastructure/roles/common/tasks/main.yml @@ -1,4 +1,26 @@ --- +- name: '[common] merge with custom vars' + set_fact: + common: "{{ common|combine(custom_common) }}" + changed_when: false + +- name: '[apt] verify components of default sources' + block: + - name: '[apt] default source.list' + ansible.builtin.replace: + path: '/etc/apt/sources.list' + regexp: '^(deb((?!{{ item }}).)+)$' + replace: '\1 {{ item }}' + when: not common.deb822_format | bool + loop: '{{ common.apt_components }}' + - name: '[apt] default deb822 debian.sources' + ansible.builtin.replace: + path: '/etc/apt/sources.list.d/debian.sources' + regexp: '^(Components: ((?!{{ item }}).)+)$' + replace: '\1 {{ item }}' + loop: '{{ common.apt_components }}' + when: common.deb822_format | bool + - name: '[apt] install dependencies and tools' become: true ansible.builtin.apt: