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
|
# these are defaults
|
||||||
# change these in group/host vars
|
# 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
|
- name: Generate docker-compose.yml
|
||||||
template:
|
template:
|
||||||
src: "docker-compose.yml"
|
src: "docker-compose.yml.j2"
|
||||||
dest: "{{ docker_compose_dir }}/docker-compose.yml"
|
dest: "{{ docker_compose_dir }}/docker-compose.yml"
|
||||||
|
|
||||||
- name: Docker compose up
|
- name: Create systemd unit file
|
||||||
community.docker.docker_compose:
|
template:
|
||||||
project_src: "{{ docker_compose_dir }}"
|
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
|
- gitea
|
||||||
volumes:
|
volumes:
|
||||||
- {{ dataroot }}/gitea:/data
|
- {{ dataroot }}/gitea:/data
|
||||||
- {{ }}
|
|
||||||
- /etc/timezone:/etc/timezone:ro
|
- /etc/timezone:/etc/timezone:ro
|
||||||
- /etc/localtime:/etc/localtime:ro
|
- /etc/localtime:/etc/localtime:ro
|
||||||
ports:
|
ports:
|
||||||
|
Loading…
Reference in New Issue
Block a user