ansible/roles/apt_cacher_ng/tasks/main.yml

64 lines
1.4 KiB
YAML

---
- name: Install apt-cacher-ng
apt:
name:
- apt-cacher-ng
state: latest
update_cache: true
register: apt_result
retries: 3
until: apt_result is succeeded
- name: Create config files
template:
src: "acng.conf.j2"
dest: "/etc/apt-cacher-ng/acng.conf"
owner: root
group: root
mode: '644'
notify: Restart apt-cacher-ng
- name: Set admin auth
template:
src: "security.conf.j2"
dest: "/etc/apt-cacher-ng/security.conf"
owner: root
group: apt-cacher-ng
mode: '640'
notify: Restart apt-cacher-ng
no_log: true
# This is uggly, and overkill
- name: Set cron job to clear the cache
template:
src: "clear-apt-cache_cron.j2"
dest: "/etc/cron.daily/clear-apt-cache"
owner: root
group: root
mode: '755'
- name: Edit the clients allowed to use the proxy
lineinfile:
path: /etc/hosts.allow
regexp: '^apt-cacher-ng'
line: "apt-cacher-ng: 127.0.0.1 {{ apt_proxy_allowed_clients | join(' ') }}"
owner: root
group: root
mode: '644'
notify: Restart apt-cacher-ng
- name: Block everyone else
lineinfile:
path: /etc/hosts.deny
regexp: '^apt-cacher-ng'
line: "apt-cacher-ng: ALL"
owner: root
group: root
mode: '644'
notify: Restart apt-cacher-ng
- name: Enable apt-cacher-ng
systemd:
name: "apt-cacher-ng"
state: started
enabled: yes