diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2019-05-15 20:17:39 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2019-08-08 09:03:13 +0200 |
commit | 09ce67dfcb447aaff46a507e5107c036dc5acd29 (patch) | |
tree | cff9ffec5945c3f95f348a113ffc1d13e503e7cb /ansible/roles/apt-repos/tasks | |
parent | 030305fc22b16851935de4dc52f912c550bdbd09 (diff) | |
download | infra-09ce67dfcb447aaff46a507e5107c036dc5acd29.tar.gz infra-09ce67dfcb447aaff46a507e5107c036dc5acd29.tar.bz2 infra-09ce67dfcb447aaff46a507e5107c036dc5acd29.tar.xz infra-09ce67dfcb447aaff46a507e5107c036dc5acd29.zip |
o Better apt-repos.
Diffstat (limited to 'ansible/roles/apt-repos/tasks')
-rw-r--r-- | ansible/roles/apt-repos/tasks/main.yml | 5 | ||||
-rw-r--r-- | ansible/roles/apt-repos/tasks/repo.yml | 28 |
2 files changed, 33 insertions, 0 deletions
diff --git a/ansible/roles/apt-repos/tasks/main.yml b/ansible/roles/apt-repos/tasks/main.yml new file mode 100644 index 0000000..7a571d3 --- /dev/null +++ b/ansible/roles/apt-repos/tasks/main.yml @@ -0,0 +1,5 @@ +- with_dict: "{{ apt_repos|default('[]') }}" + include_tasks: repo.yml + vars: + state: "{{ item.value.state | default('present') }}" + diff --git a/ansible/roles/apt-repos/tasks/repo.yml b/ansible/roles/apt-repos/tasks/repo.yml new file mode 100644 index 0000000..135aeac --- /dev/null +++ b/ansible/roles/apt-repos/tasks/repo.yml @@ -0,0 +1,28 @@ +- name: "apt-key add {{ item.key }} (key url)" + apt_key: + id: "{{ item.value.key_id }}" + url: "{{ item.value.key_url }}" + state: "{{ state }}" + when: item.value.key_url is defined and item.value.key_id is defined + +- name: "apt-key add {{ item.key }} (keyserver)" + apt_key: + id: "{{ item.value.key_id }}" + keyserver: "{{ item.value.keyserver }}" + state: "{{ state }}" + when: item.value.keyserver is defined and item.value.key_id is defined + +- name: "add repo {{ item.key }}" + when: item.value.url is defined and state == "present" + copy: + dest: "/etc/apt/sources.list.d/{{ item.key }}.list" + content: | + deb {{ item.value.url }} {{ item.value.distro }} {{ item.value.sections }} + notify: apt update + +- name: "remove repo {{ item.key }}" + when: state == "absent" + file: + path: "/etc/apt/sources.list.d/{{ item.key }}.list" + state: absent + notify: apt update |