rolle: docker-compose-deploy (#155)
git stash doku vars aufgeteilt doku aufgeräumt no log doku vars passwort entfernt und neu gesetzt keepass: gitea_mg_https_password angelegt dependencies vars auskommentiert readme vars wip ordnernamen als var basisrolle steht basis musterrolle geklont Co-authored-by: Michael Grote <michael.grote@posteo.de> Reviewed-on: mg/ansible#155 Co-Authored-By: mg <mg@noreply.git.mgrote.net> Co-Committed-By: mg <mg@noreply.git.mgrote.net>
This commit is contained in:
parent
89ceefa1d3
commit
68d9bd0dbd
10 changed files with 127 additions and 2 deletions
|
@ -14,8 +14,6 @@
|
||||||
**/**AppData***/**
|
**/**AppData***/**
|
||||||
/var/lib/docker/volumes/***Musik***
|
/var/lib/docker/volumes/***Musik***
|
||||||
/var/lib/docker/volumes/***musik***
|
/var/lib/docker/volumes/***musik***
|
||||||
/var/lib/docker/volumes/***musik***
|
|
||||||
/var/lib/docker/volumes/***musik***
|
|
||||||
/var/lib/docker/volumes/docker-photoprism_pp_smb_bilder***/**
|
/var/lib/docker/volumes/docker-photoprism_pp_smb_bilder***/**
|
||||||
# https://github.com/restic/restic/issues/1005
|
# https://github.com/restic/restic/issues/1005
|
||||||
# https://forum.restic.net/t/exclude-syntax-confusion/1531/12
|
# https://forum.restic.net/t/exclude-syntax-confusion/1531/12
|
||||||
|
|
9
host_vars/docker-test.grote.lan.yml
Normal file
9
host_vars/docker-test.grote.lan.yml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
### mgrote.docker-compose-deploy
|
||||||
|
docker_compose_base_dir: /home/mg/docker
|
||||||
|
docker_compose_projects:
|
||||||
|
- name: homer
|
||||||
|
dir_name: docker-homer
|
||||||
|
repository_url: git.mgrote.net/mg/docker-homer
|
||||||
|
repository_user: mg
|
||||||
|
repository_user_password: "{{ lookup('keepass', 'gitea_mg_https_password', 'password') }}"
|
49
host_vars/docker.grote.lan.yml
Normal file
49
host_vars/docker.grote.lan.yml
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
---
|
||||||
|
### mgrote.docker-compose-deploy
|
||||||
|
docker_compose_base_dir: /home/mg/docker
|
||||||
|
docker_compose_projects:
|
||||||
|
- name: homer
|
||||||
|
dir_name: docker-homer
|
||||||
|
repository_url: git.mgrote.net/mg/docker-homer
|
||||||
|
repository_user: mg
|
||||||
|
repository_user_password: "{{ lookup('keepass', 'gitea_mg_https_password', 'password') }}"
|
||||||
|
- name: miniflux
|
||||||
|
dir_name: docker-miniflux
|
||||||
|
repository_url: git.mgrote.net/mg/docker-miniflux
|
||||||
|
repository_user: mg
|
||||||
|
repository_user_password: "{{ lookup('keepass', 'gitea_mg_https_password', 'password') }}"
|
||||||
|
- name: munin-master
|
||||||
|
dir_name: docker-munin-master
|
||||||
|
repository_url: git.mgrote.net/mg/docker-munin-master
|
||||||
|
repository_user: mg
|
||||||
|
repository_user_password: "{{ lookup('keepass', 'gitea_mg_https_password', 'password') }}"
|
||||||
|
- name: navidrome-mg
|
||||||
|
dir_name: docker-navidrome-mg
|
||||||
|
repository_url: git.mgrote.net/mg/docker-navidrome-mg
|
||||||
|
repository_user: mg
|
||||||
|
repository_user_password: "{{ lookup('keepass', 'gitea_mg_https_password', 'password') }}"
|
||||||
|
- name: nightscout
|
||||||
|
dir_name: docker-nightscout
|
||||||
|
repository_url: git.mgrote.net/mg/docker-nightscout
|
||||||
|
repository_user: mg
|
||||||
|
repository_user_password: "{{ lookup('keepass', 'gitea_mg_https_password', 'password') }}"
|
||||||
|
- name: photoprism
|
||||||
|
dir_name: docker-photoprism
|
||||||
|
repository_url: git.mgrote.net/mg/docker-photoprism
|
||||||
|
repository_user: mg
|
||||||
|
repository_user_password: "{{ lookup('keepass', 'gitea_mg_https_password', 'password') }}"
|
||||||
|
- name: traefik
|
||||||
|
dir_name: docker-traefik
|
||||||
|
repository_url: git.mgrote.net/mg/docker-traefik
|
||||||
|
repository_user: mg
|
||||||
|
repository_user_password: "{{ lookup('keepass', 'gitea_mg_https_password', 'password') }}"
|
||||||
|
- name: unifi-controller
|
||||||
|
dir_name: docker-unifi-controller
|
||||||
|
repository_url: git.mgrote.net/mg/docker-unifi-controller
|
||||||
|
repository_user: mg
|
||||||
|
repository_user_password: "{{ lookup('keepass', 'gitea_mg_https_password', 'password') }}"
|
||||||
|
- name: watchtower
|
||||||
|
dir_name: docker-watchtower
|
||||||
|
repository_url: git.mgrote.net/mg/docker-watchtower
|
||||||
|
repository_user: mg
|
||||||
|
repository_user_password: "{{ lookup('keepass', 'gitea_mg_https_password', 'password') }}"
|
BIN
keepass_db.kdbx
BIN
keepass_db.kdbx
Binary file not shown.
|
@ -4,3 +4,4 @@
|
||||||
- { role: geerlingguy.pip, tags: "pip", become: true }
|
- { role: geerlingguy.pip, tags: "pip", become: true }
|
||||||
- { role: geerlingguy.docker, tags: "docker", become: true }
|
- { role: geerlingguy.docker, tags: "docker", become: true }
|
||||||
- { role: gantsign.ctop, tags: "ctop", become: true }
|
- { role: gantsign.ctop, tags: "ctop", become: true }
|
||||||
|
- { role: mgrote.docker-compose-deploy, tags: "compose", become: true }
|
||||||
|
|
16
roles/mgrote.docker-compose-deploy/README.md
Normal file
16
roles/mgrote.docker-compose-deploy/README.md
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
## mgrote.docker-compose-deploy
|
||||||
|
|
||||||
|
### Beschreibung
|
||||||
|
Klont Repositories und startet dir darin enthaltenen `docker-compose`-Projekte.
|
||||||
|
Abhängigkeiten werden nicht aufgelöst, z.B. fehlende Netze(`docker network create nw_proxy_traefik`)
|
||||||
|
Die `docker-compose.yml` mit im Repository-Root liegen.
|
||||||
|
|
||||||
|
### Getestet auf
|
||||||
|
- [x] Ubuntu (>=20.04)
|
||||||
|
|
||||||
|
### Variablen + Defaults
|
||||||
|
see [defaults](./defaults/main.yml)
|
||||||
|
|
||||||
|
|
||||||
|
### Benötigt
|
||||||
|
- `geerlingguy.docker`
|
9
roles/mgrote.docker-compose-deploy/defaults/main.yml
Normal file
9
roles/mgrote.docker-compose-deploy/defaults/main.yml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
# docker_compose_base_dir: /home/mg/docker # Directory where all Repos get saved
|
||||||
|
|
||||||
|
# docker_compose_projects: # Dictionary of Repositories
|
||||||
|
# - name: homer # Name
|
||||||
|
# dir_name: docker-homer # DirectoryNAME where the repo is saved
|
||||||
|
# repository_url: git.mgrote.net/mg/docker-homer.git #URL to repository, WITHOUT protocol; only https supported
|
||||||
|
# repository_user: mg # git user
|
||||||
|
# repository_user_password: k1BvXXXXXXXrbg #git user password
|
3
roles/mgrote.docker-compose-deploy/meta/main.yml
Normal file
3
roles/mgrote.docker-compose-deploy/meta/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
dependencies:
|
||||||
|
- role: geerlingguy.docker
|
32
roles/mgrote.docker-compose-deploy/tasks/dockercompose.yml
Normal file
32
roles/mgrote.docker-compose-deploy/tasks/dockercompose.yml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
---
|
||||||
|
- name: check if repo exists
|
||||||
|
stat:
|
||||||
|
path: "{{ docker_compose_base_dir }}/{{ item.dir_name }}"
|
||||||
|
register: repo_exists
|
||||||
|
|
||||||
|
- name: stash changes
|
||||||
|
ansible.builtin.shell: git stash
|
||||||
|
args:
|
||||||
|
chdir: "{{ docker_compose_base_dir }}/{{ item.dir_name }}"
|
||||||
|
changed_when: false
|
||||||
|
when: repo_exists.stat.exists == true
|
||||||
|
register: stashed
|
||||||
|
|
||||||
|
- name: clone public repository - "{{ item.name }}"
|
||||||
|
ansible.builtin.git:
|
||||||
|
repo: "https://{{ item.repository_user }}:{{ item.repository_user_password }}@{{ item.repository_url }}"
|
||||||
|
dest: "{{ docker_compose_base_dir }}/{{ item.dir_name }}"
|
||||||
|
register: repo
|
||||||
|
|
||||||
|
- name: pop stashed changes
|
||||||
|
ansible.builtin.shell: git stash pop
|
||||||
|
args:
|
||||||
|
chdir: "{{ docker_compose_base_dir }}/{{ item.dir_name }}"
|
||||||
|
changed_when: false
|
||||||
|
when: stashed.changed
|
||||||
|
|
||||||
|
- name: (re)start container - "{{ item.name }}"
|
||||||
|
ansible.builtin.shell: docker-compose down && docker-compose up -d
|
||||||
|
args:
|
||||||
|
chdir: "{{ docker_compose_base_dir }}/{{ item.dir_name }}"
|
||||||
|
when: repo.changed
|
8
roles/mgrote.docker-compose-deploy/tasks/main.yml
Normal file
8
roles/mgrote.docker-compose-deploy/tasks/main.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
- name: loop docker tasks
|
||||||
|
include_tasks: dockercompose.yml
|
||||||
|
loop: "{{ docker_compose_projects }}"
|
||||||
|
when:
|
||||||
|
- docker_compose_base_dir is defined
|
||||||
|
- docker_compose_projects is defined
|
||||||
|
no_log: true
|
Loading…
Reference in a new issue