homeserver-iac/roles/containers/tasks/main.yml

101 lines
2.0 KiB
YAML
Raw Normal View History

---
- name: Install Docker packages
community.general.pacman:
name:
- docker
- docker-compose
- name: Create docker user
user:
name: docker
group: docker
2023-09-02 18:20:46 -04:00
- name: Create Gitea user
user:
name: gitea
register: user_gitea
when: '"gitea" in groups'
2023-09-04 18:27:08 -04:00
- name: Create Navidrome user
user:
name: navidrome
register: user_navidrome
when: '"navidrome" in groups'
- name: Create Navidrome directories
file:
path: "{{ item }}"
state: directory
owner: navidrome
group: navidrome
mode: "u=rwX,g=rwX,o="
with_items:
- "{{ music_path }}"
- "{{ dataroot }}/navidrome"
- name: Create Syncthing group
group:
name: vault
state: present
when: '"syncthing" in groups'
- name: Create Syncthing user
user:
name: syncthing
group: vault
register: user_syncthing
when: '"syncthing" in groups'
- name: Create Syncthing vault directories
file:
path: "{{ item }}"
state: directory
owner: syncthing
group: vault
mode: "u=rwX,g=rwX,o="
with_items:
- "{{ vault_path }}"
- "{{ archive_path }}"
- name: Create Syncthing config directory
file:
path: "{{ syncthing_conf_dir }}"
state: directory
owner: syncthing
group: vault
mode: "u=rwX,g=,o="
- name: Add unpriviledged user to file management group
user:
name: "{{ username }}"
append: yes
groups: vault
when: '"syncthing" in groups'
- name: Create docker-compose directory
ansible.builtin.file:
path: "{{ docker_compose_dir }}"
owner: "{{ admin_username }}"
group: "{{ admin_username }}"
state: directory
- name: Generate docker-compose.yml
template:
src: "docker-compose.yml.j2"
dest: "{{ docker_compose_dir }}/docker-compose.yml"
lstrip_blocks: true
register: generateComp
- name: Create systemd unit file
template:
src: "docker-compose.service.j2"
dest: "/etc/systemd/system/docker-compose.service"
- name: Compose up (update images if necessary)
systemd:
name: docker-compose
state: reloaded
enabled: true
register: compUp