feat: replace docker_service module by systemd unit
This commit is contained in:
parent
71e4cbd246
commit
19a6c5baf1
3 changed files with 20 additions and 10 deletions
|
@ -3,9 +3,10 @@ Description= Docker compose for %i
|
|||
After=network.target docker.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/docker-compose up -d -f /etc/docker/compose/%i/docker-compose.yml
|
||||
ExecStop=/usr/bin/docker-compose down -f /etc/docker/compose/%i/docker-compose.yml
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/docker-compose -f /etc/docker/compose/%i/docker-compose.yml up
|
||||
ExecReload=/usr/bin/docker-compose -f /etc/docker/compose/%i/docker-compose.yml up --no-recreate -d
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
5
handlers/main.yml
Normal file
5
handlers/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- name: reload docker-compose
|
||||
systemd:
|
||||
name: 'docker-compose@*'
|
||||
state: reloaded
|
|
@ -11,24 +11,28 @@
|
|||
|
||||
- name: copy docker-compose configuration
|
||||
copy:
|
||||
content: '{{ item.value|to_yaml }}'
|
||||
content: '{{ item.value|to_nice_yaml }}'
|
||||
dest: '/etc/docker/compose/{{ item.key }}/docker-compose.yml'
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0640
|
||||
loop: '{{ docker_services|dict2items }}'
|
||||
notify: reload docker-compose
|
||||
no_log: true
|
||||
tags: docker
|
||||
|
||||
- name: apply docker-compose configuration
|
||||
docker_service:
|
||||
project_src: '/etc/docker/compose/{{ item }}'
|
||||
loop: '{{ docker_services|list }}'
|
||||
tags: docker
|
||||
|
||||
- name: enable and start docker-compose
|
||||
systemd:
|
||||
name: 'docker-compose@{{ item }}'
|
||||
state: started
|
||||
enabled: yes
|
||||
loop: '{{ docker_services|list }}'
|
||||
tags: docker
|
||||
|
||||
#- name: apply docker-compose configuration
|
||||
# systemd:
|
||||
# name: 'docker-compose@{{ item.item.key }}'
|
||||
# state: reloaded
|
||||
# loop: '{{ config.results }}'
|
||||
# when: item.changed
|
||||
# tags: docker
|
||||
|
|
Loading…
Reference in a new issue