docker_systemd_service/tasks/install.yml

37 lines
1.2 KiB
YAML
Raw Normal View History

2023-12-03 21:56:21 +00:00
---
# task/install file for docker_systemd_service
2023-12-04 22:10:02 +00:00
- name: "Create ENV file(s) for docker service(s)"
ansible.builtin.template:
src: env.j2
dest: "{{ docker_systemd_service_sysconf_dir }}/{{ docker_systemd_service_container_name }}"
2023-12-03 21:56:21 +00:00
owner: root
group: root
mode: '0600'
2023-12-04 22:10:02 +00:00
notify: systemctl-restart-service
2023-12-03 21:56:21 +00:00
2023-12-04 22:10:02 +00:00
- name: "Pull docker image(s)"
community.docker.docker_image:
name: "{{ docker_systemd_service_image }}"
force_source: "{{ docker_systemd_service_container_pull_force_source | bool }}"
2023-12-03 21:56:21 +00:00
source: pull
2023-12-04 22:10:02 +00:00
when: docker_systemd_service_container_pull_image
notify: systemctl-restart-service
2023-12-03 21:56:21 +00:00
2023-12-04 22:10:02 +00:00
- name: "Create unit file(s) for service(s)"
ansible.builtin.template:
src: unit.j2
dest: "/etc/systemd/system/{{ docker_systemd_service_name }}.service"
2023-12-03 21:56:21 +00:00
owner: root
group: root
mode: '0644'
2023-12-04 22:10:02 +00:00
notify: systemctl-restart-service
2023-12-03 21:56:21 +00:00
2023-12-04 22:10:02 +00:00
- name: "Enable and start service(s)"
ansible.builtin.systemd:
name: '{{ docker_systemd_service_name }}.service'
2023-12-03 21:56:21 +00:00
daemon_reload: true
2023-12-04 22:10:02 +00:00
enabled: "{{ docker_systemd_service_enabled }}"
masked: "{{ docker_systemd_service_masked }}"
state: "{{ docker_systemd_service_state }}"
register: _enable_and_start