From a5b7a9ab5b64c4579a0a873cdf43729e9d4d89aa Mon Sep 17 00:00:00 2001 From: Blallo Date: Sun, 21 Feb 2021 00:44:04 +0100 Subject: [PATCH] Init --- handlers/main.yml | 5 +++++ tasks/cacher.yml | 25 +++++++++++++++++++++++++ tasks/client.yml | 8 ++++++++ tasks/main.yml | 5 +++++ templates/aptproxy.conf.j2 | 1 + 5 files changed, 44 insertions(+) create mode 100644 handlers/main.yml create mode 100644 tasks/cacher.yml create mode 100644 tasks/client.yml create mode 100644 tasks/main.yml create mode 100644 templates/aptproxy.conf.j2 diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..a7bf28f --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,5 @@ +--- +- name: restart apt-cacher-ng + systemd: + name: apt-cacher-ng + state: restarted diff --git a/tasks/cacher.yml b/tasks/cacher.yml new file mode 100644 index 0000000..ef2a5b1 --- /dev/null +++ b/tasks/cacher.yml @@ -0,0 +1,25 @@ +--- +- name: Ensure apt-cacher-ng is present + apt: + name: apt-cacher-ng + state: present + +- name: Allow to proxy every domain + lineinfile: + path: /etc/apt-cacher-ng/acng.conf + insertafter: EOF + line: "PassThroughPattern: .*" + notify: restart apt-cacher-ng + +- name: Ensure apt-cacher-ng listens on all addresses + lineinfile: + path: /etc/apt-cacher-ng/acng.conf + insertafter: EOF + line: "BindAddress: 0.0.0.0" + notify: restart apt-cacher-ng + +- name: Ensure apt-cacher-ng is started and enabled + systemd: + name: apt-cacher-ng + enabled: yes + state: started diff --git a/tasks/client.yml b/tasks/client.yml new file mode 100644 index 0000000..e0caa66 --- /dev/null +++ b/tasks/client.yml @@ -0,0 +1,8 @@ +--- +- name: Ensure the client uses the cacher + template: + src: aptproxy.conf.j2 + dest: /etc/apt/apt.conf.d/02proxy + owner: root + group: root + mode: 0644 diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..4adda74 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,5 @@ +--- +- include_tasks: cacher.yml + when: apt_cacher_ng_is_cacher is defined and apt_cacher_ng_is_cacher + +- include_tasks: client.yml diff --git a/templates/aptproxy.conf.j2 b/templates/aptproxy.conf.j2 new file mode 100644 index 0000000..25dcd6e --- /dev/null +++ b/templates/aptproxy.conf.j2 @@ -0,0 +1 @@ +Acquire::http { Proxy "http://{{ apt_cacher_ng_cacher_ip }}:3142"; };