mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Great docker refactoring
This commit is contained in:
@@ -1 +1,2 @@
|
||||
docker_compose_skipp_file_creation: false # If set to true the file creation will be skipped
|
||||
docker_compose_skipp_file_creation: false # If set to true the file creation will be skipped
|
||||
docker_repository: true # Activates docker repository download and routine
|
@@ -8,6 +8,14 @@
|
||||
# listen: docker compose up
|
||||
# when: mode_reset | bool
|
||||
|
||||
- name: rebuild docker repository
|
||||
command:
|
||||
cmd: docker compose build
|
||||
chdir: "{{docker_repository_path}}"
|
||||
environment:
|
||||
COMPOSE_HTTP_TIMEOUT: 600
|
||||
DOCKER_CLIENT_TIMEOUT: 600
|
||||
|
||||
# default setup for docker compose files
|
||||
- name: docker compose up
|
||||
shell: docker-compose -p {{ application_id }} up -d --force-recreate --remove-orphans --build
|
||||
|
@@ -1,10 +1,10 @@
|
||||
- name: Create (optional) Dockerfile
|
||||
- name: "Create (optional) Dockerfile for {{ application_id }}"
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ docker_compose.files.dockerfile }}"
|
||||
with_first_found:
|
||||
- "{{ playbook_dir }}/roles/{{ role_name }}/templates/Dockerfile.j2"
|
||||
- "{{ playbook_dir }}/roles/{{ role_name }}/files/Dockerfile"
|
||||
loop:
|
||||
- "{{ playbook_dir }}/roles/docker-{{ application_id }}/templates/Dockerfile.j2"
|
||||
- "{{ playbook_dir }}/roles/docker-{{ application_id }}/files/Dockerfile"
|
||||
notify: docker compose up
|
||||
register: create_dockerfile_result
|
||||
failed_when:
|
||||
@@ -19,9 +19,9 @@
|
||||
force: yes
|
||||
notify: docker compose up
|
||||
register: env_template
|
||||
with_first_found:
|
||||
- "{{ playbook_dir }}/roles/{{ role_name }}/templates/env.j2"
|
||||
- "{{ playbook_dir }}/roles/{{ role_name }}/files/env"
|
||||
loop:
|
||||
- "{{ playbook_dir }}/roles/docker-{{ application_id }}/templates/env.j2"
|
||||
- "{{ playbook_dir }}/roles/docker-{{ application_id }}/files/env"
|
||||
failed_when:
|
||||
- env_template is failed
|
||||
- "'Could not find or access' not in env_template.msg"
|
@@ -16,5 +16,8 @@
|
||||
mode: '0755'
|
||||
with_dict: "{{ docker_compose.directories }}"
|
||||
|
||||
- include_tasks: "create-files.yml"
|
||||
- include_tasks: "repository.yml"
|
||||
when: docker_repository | bool
|
||||
|
||||
- include_tasks: "files.yml"
|
||||
when: not docker_compose_skipp_file_creation | bool
|
13
roles/docker-compose/tasks/repository.yml
Normal file
13
roles/docker-compose/tasks/repository.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
- name: Set default docker_repository_path
|
||||
set_fact:
|
||||
docker_repository_path: "{{docker_compose.directories.services}}repository/"
|
||||
|
||||
- name: pull docker repository
|
||||
git:
|
||||
repo: "{{ docker_repository_address }}"
|
||||
dest: "{{ docker_repository_path }}"
|
||||
update: yes
|
||||
notify:
|
||||
- docker compose up
|
||||
- rebuild docker repository
|
||||
become: true
|
Reference in New Issue
Block a user