diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2019-07-23 13:17:56 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2019-07-23 13:17:56 +0200 |
commit | 67f5d1008eef96f13dbf8910092155b7aa1bcee4 (patch) | |
tree | 00901863a6ab5c24c3e5616a9d4308499810c568 /terraform/ansible/roles/apt-repos | |
parent | ba76764c198e9232b3152568008d5aa5199a1fd0 (diff) | |
download | k8s-sandbox-67f5d1008eef96f13dbf8910092155b7aa1bcee4.tar.gz k8s-sandbox-67f5d1008eef96f13dbf8910092155b7aa1bcee4.tar.bz2 k8s-sandbox-67f5d1008eef96f13dbf8910092155b7aa1bcee4.tar.xz k8s-sandbox-67f5d1008eef96f13dbf8910092155b7aa1bcee4.zip |
o Merging in Terraform setup.
Diffstat (limited to 'terraform/ansible/roles/apt-repos')
4 files changed, 42 insertions, 0 deletions
diff --git a/terraform/ansible/roles/apt-repos/defaults/main.yml b/terraform/ansible/roles/apt-repos/defaults/main.yml new file mode 100644 index 0000000..80975f0 --- /dev/null +++ b/terraform/ansible/roles/apt-repos/defaults/main.yml @@ -0,0 +1 @@ +apt_repos: diff --git a/terraform/ansible/roles/apt-repos/handlers/main.yml b/terraform/ansible/roles/apt-repos/handlers/main.yml new file mode 100644 index 0000000..2401293 --- /dev/null +++ b/terraform/ansible/roles/apt-repos/handlers/main.yml @@ -0,0 +1,3 @@ +- name: apt update + apt: + update_cache: true diff --git a/terraform/ansible/roles/apt-repos/tasks/main.yml b/terraform/ansible/roles/apt-repos/tasks/main.yml new file mode 100644 index 0000000..de51cb3 --- /dev/null +++ b/terraform/ansible/roles/apt-repos/tasks/main.yml @@ -0,0 +1,10 @@ +- apt: + name: + - apt-transport-https + install_recommends: no + +- with_dict: "{{ apt_repos|default('[]') }}" + include_tasks: repo.yml + vars: + state: "{{ item.value.state | default('present') }}" + diff --git a/terraform/ansible/roles/apt-repos/tasks/repo.yml b/terraform/ansible/roles/apt-repos/tasks/repo.yml new file mode 100644 index 0000000..135aeac --- /dev/null +++ b/terraform/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 |