roles/containers: use systemd instead of docker module
arch doesn't package python-docker-compose so just docker compose up via systemd instead of ansible
This commit is contained in:
parent
d6a1876fe8
commit
0288cea768
@ -3,4 +3,4 @@
|
||||
# these are defaults
|
||||
# change these in group/host vars
|
||||
|
||||
docker_compose_dir: "/home/{{ ansible_user }}/services"
|
||||
docker_compose_dir: "/opts/services"
|
||||
|
@ -15,9 +15,16 @@
|
||||
|
||||
- name: Generate docker-compose.yml
|
||||
template:
|
||||
src: "docker-compose.yml"
|
||||
src: "docker-compose.yml.j2"
|
||||
dest: "{{ docker_compose_dir }}/docker-compose.yml"
|
||||
|
||||
- name: Docker compose up
|
||||
community.docker.docker_compose:
|
||||
project_src: "{{ docker_compose_dir }}"
|
||||
- name: Create systemd unit file
|
||||
template:
|
||||
src: "docker-compose.service.j2"
|
||||
dest: "/etc/systemd/system/docker-compose.service"
|
||||
|
||||
- name: Compose up
|
||||
systemd:
|
||||
name: docker-compose
|
||||
state: started
|
||||
enabled: true
|
||||
|
15
roles/containers/templates/docker-compose.service.j2
Normal file
15
roles/containers/templates/docker-compose.service.j2
Normal file
@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Services manager with docker-compose
|
||||
Requires=docker.service
|
||||
After=docker.service
|
||||
|
||||
[Service]
|
||||
WorkingDirectory={{ docker_compose_dir }}
|
||||
ExecStartPre=-/usr/bin/docker compose pull
|
||||
ExecStart=/usr/bin/docker compose up --remove-orphans
|
||||
ExecStop=/usr/bin/docker compose down
|
||||
ExecReload=/usr/bin/docker compose pull
|
||||
ExecReload=/usr/bin/docker compose up --remove-orphans
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -19,7 +19,6 @@ services:
|
||||
- gitea
|
||||
volumes:
|
||||
- {{ dataroot }}/gitea:/data
|
||||
- {{ }}
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
ports:
|
||||
|
Loading…
Reference in New Issue
Block a user