summaryrefslogtreecommitdiff
path: root/roles
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2024-06-04 19:06:12 +0200
committerChristian Pointner <equinox@spreadspace.org>2024-06-04 19:06:12 +0200
commit208dafdbcf5ba5eab47f00dfefad2749bd775faa (patch)
tree6311b39b2dc8902955514fe02082287431b9819e /roles
parentrename ch-apt to ch-repo (diff)
switch form apt-cacher-ng to approx
Diffstat (limited to 'roles')
-rw-r--r--roles/approx/defaults/main.yml12
-rw-r--r--roles/approx/handlers/main.yml5
-rw-r--r--roles/approx/tasks/main.yml85
3 files changed, 102 insertions, 0 deletions
diff --git a/roles/approx/defaults/main.yml b/roles/approx/defaults/main.yml
new file mode 100644
index 00000000..d0894b58
--- /dev/null
+++ b/roles/approx/defaults/main.yml
@@ -0,0 +1,12 @@
+---
+approx_basepath: /srv/approx
+
+# approx_storage:
+# type: ...
+
+# approx_hostname: apt.example.com
+
+# apt_cacher_ng_remaps:
+# debian: http://deb.debian.org/debian
+# debian-security: http://security.debian.org
+# ubuntu: http://archive.ubuntu.com/ubuntu
diff --git a/roles/approx/handlers/main.yml b/roles/approx/handlers/main.yml
new file mode 100644
index 00000000..dfae79a6
--- /dev/null
+++ b/roles/approx/handlers/main.yml
@@ -0,0 +1,5 @@
+---
+- name: restart approx socket
+ systemd:
+ name: approx.socket
+ state: restarted
diff --git a/roles/approx/tasks/main.yml b/roles/approx/tasks/main.yml
new file mode 100644
index 00000000..f913120f
--- /dev/null
+++ b/roles/approx/tasks/main.yml
@@ -0,0 +1,85 @@
+---
+- name: prepare storage volume for approx
+ when: approx_storage is defined
+ vars:
+ storage_volume: "{{ approx_storage | combine({'dest': approx_basepath}) }}"
+ include_role:
+ name: "storage/{{ approx_storage.type }}/volume"
+
+- name: install approx
+ apt:
+ name: approx
+ state: present
+
+- name: make sure cache and tmp directories exist
+ loop:
+ - cache
+ - tmp
+ file:
+ state: directory
+ path: "{{ approx_basepath }}/{{ item }}"
+ mode: 0700
+ owner: approx
+ group: approx
+
+- name: generate approx config
+ copy:
+ content: |
+ # ansible managed
+
+ {% for name, remote in approx_backends.items() %}
+ {{ name }} {{ remote }}
+ {% endfor %}
+
+ $cache {{ approx_basepath }}/cache
+ dest: /etc/approx/approx.conf
+
+- name: create override directories for approx systemd units
+ loop:
+ - approx@.service
+ - approx.socket
+ file:
+ state: directory
+ path: "/etc/systemd/system/{{ item }}.d"
+
+- name: create appprox service override
+ copy:
+ content: |
+ # ansible managed
+ [Unit]
+ CollectMode=inactive-or-failed
+
+ [Service]
+ Environment=TMPDIR="{{ approx_basepath }}/tmp"
+ dest: /etc/systemd/system/approx@.service.d/ansible.conf
+ notify: restart approx socket
+
+- name: create appprox socket override
+ copy:
+ content: |
+ # ansible managed
+ [Socket]
+ ListenStream=
+ ListenStream=127.0.0.1:19999
+ dest: /etc/systemd/system/approx.socket.d/ansible.conf
+ notify: restart approx socket
+
+- name: make sure approx socket is started
+ systemd:
+ daemon_reload: yes
+ name: approx.socket
+ state: started
+
+- name: configure nginx vhost
+ vars:
+ nginx_vhost:
+ default: yes
+ name: approx
+ template: generic
+ hostnames:
+ - "{{ approx_hostname }}"
+ locations:
+ '/':
+ proxy_pass: http://127.0.0.1:19999
+ include_role:
+ name: nginx/vhost