docker_systemd_service/tasks/install.yml

37 lines
1.2 KiB
YAML

---
# task/install file for docker_systemd_service
- 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 }}"
owner: root
group: root
mode: '0600'
notify: systemctl-restart-service
- name: "Pull docker image(s)"
community.docker.docker_image:
name: "{{ docker_systemd_service_image }}"
force_source: "{{ docker_systemd_service_container_pull_force_source | bool }}"
source: pull
when: docker_systemd_service_container_pull_image
notify: systemctl-restart-service
- name: "Create unit file(s) for service(s)"
ansible.builtin.template:
src: unit.j2
dest: "/etc/systemd/system/{{ docker_systemd_service_name }}.service"
owner: root
group: root
mode: '0644'
notify: systemctl-restart-service
- name: "Enable and start service(s)"
ansible.builtin.systemd:
name: '{{ docker_systemd_service_name }}.service'
daemon_reload: true
enabled: "{{ docker_systemd_service_enabled }}"
masked: "{{ docker_systemd_service_masked }}"
state: "{{ docker_systemd_service_state }}"
register: _enable_and_start