roles/containers: got gitea container up

This commit is contained in:
dogeystamp 2023-08-27 20:33:18 -04:00
parent 9b4e047171
commit dd0de3139e
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
4 changed files with 18 additions and 3 deletions

View File

@ -3,4 +3,4 @@
# these are defaults
# change these in group/host vars
docker_compose_dir: "/opts/services"
docker_compose_dir: "/opt/services"

View File

@ -6,6 +6,11 @@
- docker
- docker-compose
- name: Create docker user
user:
name: docker
group: docker
- name: Create docker-compose directory
ansible.builtin.file:
path: "{{ docker_compose_dir }}"
@ -17,6 +22,7 @@
template:
src: "docker-compose.yml.j2"
dest: "{{ docker_compose_dir }}/docker-compose.yml"
register: docker-comp
- name: Create systemd unit file
template:
@ -26,5 +32,12 @@
- name: Compose up
systemd:
name: docker-compose
state: started
state: "{{ 'restarted' if docker-comp.changed else 'started' }}"
enabled: true
# for some reason port mappings don't work without this?
- name: Restart docker for good measure
systemd:
name: docker
state: restarted
when: docker-comp.changed

View File

@ -4,6 +4,8 @@ Requires=docker.service
After=docker.service
[Service]
User=docker
Group=docker
WorkingDirectory={{ docker_compose_dir }}
ExecStartPre=-/usr/bin/docker compose pull
ExecStart=/usr/bin/docker compose up --remove-orphans

View File

@ -23,6 +23,6 @@ services:
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
- "222:22"
- "2499:22"
{% endif %}