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:
dogeystamp 2023-08-27 17:39:08 -04:00
parent d6a1876fe8
commit 0288cea768
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
4 changed files with 27 additions and 6 deletions

View File

@ -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"

View File

@ -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

View 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

View File

@ -19,7 +19,6 @@ services:
- gitea
volumes:
- {{ dataroot }}/gitea:/data
- {{ }}
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports: