homelab/roles/docker/tasks/main.yml

36 lines
792 B
YAML
Raw Normal View History

2022-05-20 01:06:34 +00:00
- name: Install Docker
apt:
2022-05-20 01:06:34 +00:00
name: ['docker.io', 'docker-compose']
state: present
update_cache: true
- name: Create docker-compose root
file:
2022-05-28 03:14:06 +00:00
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
2020-08-01 00:52:57 +00:00
append: true
loop: "{{ docker_users }}"
2020-11-22 05:46:08 +00:00
when: docker_users is defined
2020-08-01 00:52:57 +00:00
- name: Start Docker and enable on boot
service:
name: docker
state: started
enabled: true