aboutsummaryrefslogtreecommitdiff
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
parent030305fc22b16851935de4dc52f912c550bdbd09 (diff)
downloadinfra-09ce67dfcb447aaff46a507e5107c036dc5acd29.tar.gz
infra-09ce67dfcb447aaff46a507e5107c036dc5acd29.tar.bz2
infra-09ce67dfcb447aaff46a507e5107c036dc5acd29.tar.xz
infra-09ce67dfcb447aaff46a507e5107c036dc5acd29.zip
o Better apt-repos.
-rw-r--r--ansible/all.yml3
-rw-r--r--ansible/group_vars/workstation/apt-repos.yml104
-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
6 files changed, 144 insertions, 0 deletions
diff --git a/ansible/all.yml b/ansible/all.yml
index fdb8116..e1de9be 100644
--- a/ansible/all.yml
+++ b/ansible/all.yml
@@ -7,6 +7,9 @@
tags: packages
become: yes
- trygvis-base
+ - role: apt-repos
+ tags: apt-repos
+ become: yes
# - ufw
- hosts:
diff --git a/ansible/group_vars/workstation/apt-repos.yml b/ansible/group_vars/workstation/apt-repos.yml
new file mode 100644
index 0000000..454a616
--- /dev/null
+++ b/ansible/group_vars/workstation/apt-repos.yml
@@ -0,0 +1,104 @@
+# Use "gpp foo.gpg" to show the fingerprints
+apt_repos:
+ google:
+ key_id: EB4C1BFD4F042F6DDDCCEC917721F63BD38B4796
+ key_url: https://dl.google.com/linux/linux_signing_key.pub
+
+ google-cloud-sdk:
+ url: http://packages.cloud.google.com/apt
+ distro: cloud-sdk-sid-unstable
+ sections: main
+ key_id: 54A647F9048D5688D7DA2ABE6A030B21BA07F4FB
+ key_url: https://packages.cloud.google.com/apt/doc/apt-key.gpg
+
+ openmodelica:
+ url: http://build.openmodelica.org/apt
+ distro: jessie
+ sections: release
+ key_id: D229AF1CE5AED74E5F59DF303A59B53664970947
+ key_url: http://build.openmodelica.org/apt/openmodelica.asc
+
+ dropbox:
+ url: http://linux.dropbox.com/debian
+ distro: sid
+ sections: main
+ key_id: FC918B335044912E
+ keyserver: keyserver.ubuntu.com
+
+ docker:
+ url: "[arch=amd64] https://download.docker.com/linux/debian"
+ distro: stretch
+ sections: stable
+ key_id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88
+ key_url: https://download.docker.com/linux/debian/gpg
+
+ picoscope:
+ url: http://labs.picotech.com/debian/
+ distro: picoscope
+ sections: main
+ key_id: 790128FE0D37172A2C56ACB16964D13AA2A43CCE
+ key_url: http://labs.picotech.com/debian/dists/picoscope/Release.gpg.key
+
+ skype:
+ state: absent
+ distro: stretch
+ sections: main
+ key_id: 1F3045A5DF7587C3
+ keyserver: hkp://keyserver.ubuntu.com:80
+
+ signal:
+ url: "[arch=amd64] https://updates.signal.org/desktop/apt"
+ distro: xenial
+ sections: main
+ key_id: DBA36B5181D0C816F630E889D980A17457F6FB06
+ key_url: https://updates.signal.org/desktop/apt/keys.asc
+
+ spotify:
+ url: http://repository.spotify.com
+ distro: stable
+ sections: non-free
+ key_id: A87FF9DF48BF1C90
+ keyserver: hkp://keyserver.ubuntu.com:80
+
+ nodesource:
+ state: absent
+ url: https://deb.nodesource.com/node_8.x
+ distro: sid
+ sections: main
+ key_id: 1655A0AB68576280
+ keyserver: hkp://keyserver.ubuntu.com:80
+
+ nextcloud:
+ url: http://ppa.launchpad.net/nextcloud-devs/client/ubuntu
+ distro: cosmic
+ sections: main
+ key_id: 1FCD77DD0DBEF5699AD2610160EE47FBAD3DD469
+ keyserver: hkp://keyserver.ubuntu.com:80
+
+ heroku:
+ url: http://toolbelt.heroku.com/ubuntu
+ distro: ./
+ sections: ''
+ key_id: C927EBE00F1B0520
+ keyserver: hkp://keyserver.ubuntu.com:80
+
+ atom:
+ url: "[arch=amd64] https://packagecloud.io/AtomEditor/atom/any/"
+ distro: any
+ sections: main
+ key_id: 0A0FAB860D48560332EFB581B75442BBDE9E3B09
+ key_url: https://packagecloud.io/AtomEditor/atom/gpgkey
+
+ souffle:
+ url: https://dl.bintray.com/souffle-lang/deb-unstable
+ distro: stretch
+ sections: main
+ key_id: 379CE192D401AB61
+ keyserver: hkp://keyserver.ubuntu.com:80
+
+ slack:
+ url: https://packagecloud.io/slacktechnologies/slack/debian/
+ distro: jessie
+ sections: main
+ key_id: C6ABDCF64DB9A0B2
+ keyserver: hkp://keyserver.ubuntu.com:80
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