76 lines
1.9 KiB
YAML
76 lines
1.9 KiB
YAML
---
|
|
- name: APT Cache Server
|
|
hosts: apt-cacher-ng
|
|
|
|
vars:
|
|
username: matt
|
|
nas_host: 192.168.1.160
|
|
|
|
mounts:
|
|
apt_cache:
|
|
local: "/var/cache/packages"
|
|
remote: "/var/nfs/shared/apt_cache"
|
|
|
|
docker_add_repo: true
|
|
docker_users:
|
|
- "{{ username }}"
|
|
|
|
roles:
|
|
- role: geerlingguy.git
|
|
become: true
|
|
- role: geerlingguy.docker
|
|
become: true
|
|
|
|
|
|
tasks:
|
|
- name: Create app directory in home
|
|
ansible.builtin.file:
|
|
path: "{{ ansible_env.HOME }}/apt-cacher-ng"
|
|
state: directory
|
|
mode: "0755"
|
|
|
|
- name: Copy the apt-cacher-ng compose file to the host
|
|
ansible.builtin.copy:
|
|
src: apt-cacher-ng/compose.yaml
|
|
dest: "{{ ansible_env.HOME }}/apt-cacher-ng/compose.yaml"
|
|
|
|
- name: Stop apt-cacher-ng services if running
|
|
community.docker.docker_compose_v2:
|
|
project_src: "{{ ansible_env.HOME }}/apt-cacher-ng/"
|
|
state: absent
|
|
ignore_errors: true
|
|
|
|
- name: Unmount NFS volumes before creating mountpoint directories
|
|
ansible.posix.mount:
|
|
path: "{{ item.value.local }}"
|
|
state: unmounted
|
|
loop: "{{ mounts | dict2items }}"
|
|
become: true
|
|
|
|
- name: Create mountpoint directories for apt-cacher-ng
|
|
ansible.builtin.file:
|
|
path: "{{ item.value.local }}"
|
|
state: directory
|
|
mode: "0755"
|
|
loop: "{{mounts | dict2items }}"
|
|
become: true
|
|
|
|
- name: Mount an NFS volume for cache
|
|
ansible.posix.mount:
|
|
src: "{{ nas_host }}:{{ item.value.remote }}"
|
|
path: "{{ item.value.local }}"
|
|
opts: nfsvers=3,proto=tcp,rw
|
|
state: mounted
|
|
fstype: nfs
|
|
loop: "{{ mounts | dict2items }}"
|
|
become: true
|
|
|
|
|
|
- name: Create and start services
|
|
community.docker.docker_compose_v2:
|
|
project_src: "{{ ansible_env.HOME }}/apt-cacher-ng/"
|
|
state: present
|
|
|
|
|
|
|