homelab/roles/docker/tasks/main.yml
2022-05-27 23:14:06 -04:00

36 lines
792 B
YAML

- name: Install Docker
apt:
name: ['docker.io', 'docker-compose']
state: present
update_cache: true
- name: Create docker-compose root
file:
path: "{{ docker_compose_root }}"
state: directory
- name: Install docker-compose systemd service
template:
src: docker-compose.service.j2
dest: "/etc/systemd/system/{{ docker_compose_service }}@.service"
register: compose_systemd
- name: Reload systemd manager configuration
systemd:
daemon_reload: true
when: compose_systemd.changed
- name: Add users to docker group
user:
name: "{{ item }}"
groups: docker
append: true
loop: "{{ docker_users }}"
when: docker_users is defined
- name: Start Docker and enable on boot
service:
name: docker
state: started
enabled: true