diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2023-08-29 20:27:13 +0200 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2023-08-29 20:29:53 +0200 |
commit | e52ae9cb238069836dd30ee8a4d5636daf74bf7d (patch) | |
tree | 59187b4cf663f13a86d7bc7468f33f18a562a83a /roles | |
parent | v0.0.22 (diff) | |
download | infra-ansible-e52ae9cb238069836dd30ee8a4d5636daf74bf7d.tar.gz infra-ansible-e52ae9cb238069836dd30ee8a4d5636daf74bf7d.zip |
apt_repo: always overwrite the .list file
Diffstat (limited to '')
-rw-r--r-- | roles/apt_repo/tasks/main.yml | 20 | ||||
-rw-r--r-- | roles/apt_repo/templates/repo.list.j2 | 3 |
2 files changed, 18 insertions, 5 deletions
diff --git a/roles/apt_repo/tasks/main.yml b/roles/apt_repo/tasks/main.yml index f382f6a..b6779fd 100644 --- a/roles/apt_repo/tasks/main.yml +++ b/roles/apt_repo/tasks/main.yml @@ -23,9 +23,19 @@ ansible.builtin.setup: gather_subset: [distribution_release] + # Not using the apt_repository module, since it _adds_ a new repository + # in the .list file. That way, we can end up with an invalid repository + # line. - name: 'Add repository: {{ apt_repo_name }}' - ansible.builtin.apt_repository: - repo: 'deb [signed-by={{ key_path }}] {{ apt_repo_url }} {{ distro }} {{ apt_repo_component }}' - filename: '{{ apt_repo_name }}' - vars: - distro: '{{ apt_repo_distro | default(ansible_distribution_release) }}' + ansible.builtin.template: + src: repo.list.j2 + dest: '/etc/apt/sources.list.d/{{ apt_repo_name }}.list' + owner: root + group: root + mode: '644' + register: repo_file + + - name: Refresh apt repositories + ansible.builtin.apt: + update_cache: true + when: repo_file.changed diff --git a/roles/apt_repo/templates/repo.list.j2 b/roles/apt_repo/templates/repo.list.j2 new file mode 100644 index 0000000..ffb100c --- /dev/null +++ b/roles/apt_repo/templates/repo.list.j2 @@ -0,0 +1,3 @@ +{{ ansible_managed | comment }} + +deb [signed-by={{ key_path }}] {{ apt_repo_url }} {{ apt_repo_distro | default(ansible_distribution_release) }} {{ apt_repo_component }} |