aboutsummaryrefslogtreecommitdiff
path: root/ansible/roles/apt-repos
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-05-15 20:17:39 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2019-08-08 09:03:13 +0200
commit09ce67dfcb447aaff46a507e5107c036dc5acd29 (patch)
treecff9ffec5945c3f95f348a113ffc1d13e503e7cb /ansible/roles/apt-repos
parent030305fc22b16851935de4dc52f912c550bdbd09 (diff)
downloadinfra-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')
-rw-r--r--ansible/roles/apt-repos/defaults/main.yml1
-rw-r--r--ansible/roles/apt-repos/handlers/main.yml3
-rw-r--r--ansible/roles/apt-repos/tasks/main.yml5
-rw-r--r--ansible/roles/apt-repos/tasks/repo.yml28
4 files changed, 37 insertions, 0 deletions
diff --git a/ansible/roles/apt-repos/defaults/main.yml b/ansible/roles/apt-repos/defaults/main.yml
new file mode 100644
index 0000000..80975f0
--- /dev/null
+++ b/ansible/roles/apt-repos/defaults/main.yml
@@ -0,0 +1 @@
+apt_repos:
diff --git a/ansible/roles/apt-repos/handlers/main.yml b/ansible/roles/apt-repos/handlers/main.yml
new file mode 100644
index 0000000..2401293
--- /dev/null
+++ b/ansible/roles/apt-repos/handlers/main.yml
@@ -0,0 +1,3 @@
+- name: apt update
+ apt:
+ update_cache: true
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