mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
THE HUGE REFACTORING CALENDER WEEK 33; Optimized Matrix and during this updated variables, and implemented better reset and cleanup mode handling, also solved some initial setup bugs
This commit is contained in:
16
roles/docker-compose/tasks/01_core.yml
Normal file
16
roles/docker-compose/tasks/01_core.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
- name: "Load docker container role"
|
||||
include_role:
|
||||
name: docker-container
|
||||
|
||||
when: run_once_docker_container is not defined
|
||||
- name: "reset (if enabled)"
|
||||
include_tasks: 02_reset.yml
|
||||
when: MODE_RESET | bool
|
||||
|
||||
- name: "create {{ PATH_DOCKER_COMPOSE_INSTANCES }}"
|
||||
file:
|
||||
path: "{{ PATH_DOCKER_COMPOSE_INSTANCES }}"
|
||||
state: directory
|
||||
mode: 0700
|
||||
owner: root
|
||||
group: root
|
@@ -1,11 +0,0 @@
|
||||
# It is necessary to shut the projects down, when reset is activated.
|
||||
# Otherwise it can lead to this bug:
|
||||
# https://github.com/ansible/ansible/issues/10244
|
||||
- name: shut down docker compose project
|
||||
command:
|
||||
cmd: "docker-compose -p {{ application_id }} down"
|
||||
|
||||
- name: "Remove {{ docker_compose.directories.instance }} and all its contents"
|
||||
file:
|
||||
path: "{{ docker_compose.directories.instance }}"
|
||||
state: absent
|
16
roles/docker-compose/tasks/02_reset.yml
Normal file
16
roles/docker-compose/tasks/02_reset.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
# It is necessary to shut the projects down, when reset is activated.
|
||||
# Otherwise it can lead to this bug:
|
||||
# https://github.com/ansible/ansible/issues/10244
|
||||
- name: "pkgmgr install '{{ DOCKER_COMPOSE_DOWN_ALL_PACKAGE }}'"
|
||||
include_role:
|
||||
name: pkgmgr-install
|
||||
vars:
|
||||
package_name: "{{ DOCKER_COMPOSE_DOWN_ALL_PACKAGE }}"
|
||||
|
||||
- name: Shutdown all docker compose instances in '{{ PATH_DOCKER_COMPOSE_INSTANCES }}' with '{{ DOCKER_COMPOSE_DOWN_ALL_PACKAGE }}'
|
||||
command: "{{ DOCKER_COMPOSE_DOWN_ALL_PACKAGE }} {{ PATH_DOCKER_COMPOSE_INSTANCES }}"
|
||||
|
||||
- name: "Remove directory '{{ PATH_DOCKER_COMPOSE_INSTANCES }}' and all its contents"
|
||||
file:
|
||||
path: "{{ PATH_DOCKER_COMPOSE_INSTANCES }}"
|
||||
state: absent
|
@@ -1,16 +1,10 @@
|
||||
- block:
|
||||
- include_role:
|
||||
name: docker-container
|
||||
when: run_once_docker_container is not defined
|
||||
- include_tasks: 01_core.yml
|
||||
- include_tasks: utils/run_once.yml
|
||||
when: run_once_docker_compose is not defined
|
||||
|
||||
- name: "Load variables from {{ docker_compose_variable_file }} for whole play"
|
||||
include_vars: "{{ docker_compose_variable_file }}"
|
||||
|
||||
- name: "reset (if enabled)"
|
||||
include_tasks: 01_reset.yml
|
||||
when: MODE_RESET | bool
|
||||
- name: "Load variables from {{ DOCKER_COMPOSE_VARIABLE_FILE }} for whole play"
|
||||
include_vars: "{{ DOCKER_COMPOSE_VARIABLE_FILE }}"
|
||||
|
||||
# This could lead to problems in docker-compose directories which are based on a git repository
|
||||
# @todo Verify that this isn't the case. E.g. in accounting
|
||||
@@ -21,15 +15,15 @@
|
||||
mode: '0755'
|
||||
with_dict: "{{ docker_compose.directories }}"
|
||||
|
||||
- name: "Include routines to set up a git repository based installation for '{{application_id}}'."
|
||||
include_tasks: "02_repository.yml"
|
||||
- name: "Include routines to set up a git repository based installation for '{{ application_id }}'."
|
||||
include_tasks: "03_repository.yml"
|
||||
when: docker_pull_git_repository | bool
|
||||
|
||||
- block:
|
||||
- name: "Include file management routines for '{{application_id}}'."
|
||||
include_tasks: "03_files.yml"
|
||||
- name: "Include file management routines for '{{ application_id }}'."
|
||||
include_tasks: "04_files.yml"
|
||||
- name: "Ensure that {{ docker_compose.directories.instance }} is up"
|
||||
include_tasks: "04_ensure_up.yml"
|
||||
include_tasks: "05_ensure_up.yml"
|
||||
when: not docker_compose_skipp_file_creation | bool
|
||||
|
||||
- name: "flush docker compose for '{{ application_id }}'"
|
||||
|
@@ -1,2 +1,2 @@
|
||||
# @See https://chatgpt.com/share/67a23d18-fb54-800f-983c-d6d00752b0b4
|
||||
docker_compose: "{{ application_id | get_docker_paths(path_docker_compose_instances) }}"
|
||||
docker_compose: "{{ application_id | get_docker_paths(PATH_DOCKER_COMPOSE_INSTANCES) }}"
|
@@ -1 +1,2 @@
|
||||
docker_compose_variable_file: "{{ role_path }}/vars/docker-compose.yml"
|
||||
DOCKER_COMPOSE_VARIABLE_FILE: "{{ role_path }}/vars/docker-compose.yml"
|
||||
DOCKER_COMPOSE_DOWN_ALL_PACKAGE: "docodol"
|
Reference in New Issue
Block a user