homelab/roles/docker/tasks/main.yml

33 lines
789 B
YAML
Raw Normal View History

2022-05-20 01:06:34 +00:00
- name: Install Docker
2023-05-04 03:42:55 +00:00
ansible.builtin.apt:
2022-05-20 01:06:34 +00:00
name: ['docker.io', 'docker-compose']
state: present
update_cache: true
- name: Create docker-compose root
2023-05-04 03:42:55 +00:00
ansible.builtin.file:
2022-05-28 03:14:06 +00:00
path: "{{ docker_compose_root }}"
state: directory
2023-05-04 05:20:22 +00:00
mode: 0500
- name: Install docker-compose systemd service
2023-05-04 03:42:55 +00:00
ansible.builtin.template:
src: docker-compose.service.j2
dest: "/etc/systemd/system/{{ docker_compose_service }}@.service"
2023-05-04 05:20:22 +00:00
mode: 0400
register: compose_systemd
- name: Add users to docker group
2023-05-04 03:42:55 +00:00
ansible.builtin.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
2023-05-04 03:42:55 +00:00
ansible.builtin.service:
2020-08-01 00:52:57 +00:00
name: docker
state: started
enabled: true