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

44 lines
920 B
YAML

---
- name: Install Docker packages
community.general.pacman:
name:
- docker
- docker-compose
- name: Create docker user
user:
name: docker
group: docker
- name: Create Gitea user
user:
name: gitea
register: user_gitea
when: '"gitea" 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"
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