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,3 @@
|
||||
- Implement this role
|
||||
# Todo
|
||||
- Implement this role
|
||||
- refactore main.yml
|
@@ -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
|
@@ -68,5 +68,5 @@ docker exec -i ldap \
|
||||
-D "$LDAP_ADMIN_DN" \
|
||||
-w "$LDAP_ADMIN_PASSWORD" \
|
||||
-c \
|
||||
-f "/tmp/ldif/data/01_rbac_roles.ldif"
|
||||
-f "/tmp/ldif/data/01_rbac.ldif"
|
||||
```
|
@@ -23,10 +23,6 @@
|
||||
notify:
|
||||
- docker compose up
|
||||
|
||||
- name: "include role docker-repository-setup for {{application_id}}"
|
||||
include_role:
|
||||
name: docker-repository-setup
|
||||
|
||||
- name: "create {{dummy_volume}}"
|
||||
file:
|
||||
path: "{{dummy_volume}}"
|
||||
|
@@ -1,6 +1,7 @@
|
||||
application_id: "openproject"
|
||||
docker_repository_address: "https://github.com/opf/openproject-deploy"
|
||||
database_type: "postgres"
|
||||
docker_repository: true
|
||||
|
||||
openproject_plugins_folder: "{{docker_compose.directories.volumes}}plugins/"
|
||||
|
||||
|
@@ -12,11 +12,6 @@
|
||||
http_port: "{{ ports.localhost.http[application_id] }}"
|
||||
when: run_once_docker_portfolio is not defined
|
||||
|
||||
- name: "include role docker-repository-setup for {{application_id}}"
|
||||
include_role:
|
||||
name: docker-repository-setup
|
||||
when: run_once_docker_portfolio is not defined
|
||||
|
||||
- name: "Check if host-specific config.yaml exists in {{ config_inventory_path }}"
|
||||
stat:
|
||||
path: "{{ config_inventory_path }}"
|
||||
|
@@ -1,3 +1,4 @@
|
||||
application_id: "portfolio"
|
||||
docker_repository_address: "https://github.com/kevinveenbirkenbach/portfolio"
|
||||
config_inventory_path: "{{ inventory_dir }}/files/{{ inventory_hostname }}/docker/portfolio/config.yaml.j2"
|
||||
config_inventory_path: "{{ inventory_dir }}/files/{{ inventory_hostname }}/docker/portfolio/config.yaml.j2"
|
||||
docker_repository: true
|
@@ -1,44 +0,0 @@
|
||||
# Docker Repository Setup
|
||||
|
||||
This Ansible role sets up and manages your Docker repository. It ensures that the repository is pulled from your remote Git source, and it automatically triggers a rebuild of your Docker images using Docker Compose.
|
||||
|
||||
## Features 🔧
|
||||
|
||||
- **Default Path Setup:**
|
||||
Automatically sets a default `docker_repository_path`
|
||||
|
||||
- **Repository Management:**
|
||||
Clones or updates your Docker repository from a specified Git repository.
|
||||
|
||||
- **Automated Build Trigger:**
|
||||
Notifies handlers to rebuild the Docker repository using Docker Compose with extended timeouts.
|
||||
|
||||
## Role Structure 📂
|
||||
|
||||
- **Handlers:**
|
||||
- `rebuild docker repository`: Runs `docker compose build` in the designated repository directory with custom timeout settings.
|
||||
|
||||
- **Tasks:**
|
||||
- Sets the default repository path if undefined.
|
||||
- Pulls the latest code from the Docker repository.
|
||||
- Notifies the Docker Compose project setup and triggers a repository rebuild.
|
||||
|
||||
- **Meta:**
|
||||
- Declares a dependency on the `docker-compose` role to ensure that handlers and related dependencies are loaded.
|
||||
|
||||
## Usage ⚙️
|
||||
|
||||
Ensure that you have set the following variables (either via your inventory, `group_vars`, or `host_vars`):
|
||||
|
||||
- `docker_repository_address`: The Git repository URL of your Docker repository.
|
||||
- `docker_compose.directories.services`: The base directory where your Docker services are stored.
|
||||
The role will append `repository/` to this path to form `docker_repository_path`.
|
||||
|
||||
## Author
|
||||
|
||||
Kevin Veen-Birkenbach
|
||||
[https://www.veen.world](https://www.veen.world)
|
||||
|
||||
---
|
||||
|
||||
Happy deploying! 🚀🐳
|
@@ -1,7 +0,0 @@
|
||||
- name: rebuild docker repository
|
||||
command:
|
||||
cmd: docker compose build
|
||||
chdir: "{{docker_repository_path}}"
|
||||
environment:
|
||||
COMPOSE_HTTP_TIMEOUT: 600
|
||||
DOCKER_CLIENT_TIMEOUT: 600
|
@@ -1,2 +0,0 @@
|
||||
dependencies:
|
||||
- docker-compose # To load handlers and make dependencies visible
|
@@ -10,10 +10,6 @@
|
||||
domain: "{{ domains | get_domain(application_id) }}"
|
||||
http_port: "{{ ports.localhost.http[application_id] }}"
|
||||
|
||||
- name: "include role docker-repository-setup for {{application_id}}"
|
||||
include_role:
|
||||
name: docker-repository-setup
|
||||
|
||||
- name: "copy templates {{ settings_files }} for taiga-contrib-oidc-auth"
|
||||
template:
|
||||
src: "taiga/{{item}}.py.j2"
|
||||
|
@@ -10,7 +10,7 @@ taiga_image_frontend: >-
|
||||
{{ 'robrotheram/taiga-front-openid' if applications[application_id].features.oidc and applications[application_id].oidc.flavor == 'robrotheram'
|
||||
else 'taigaio/taiga-front' }}
|
||||
taiga_frontend_conf_path: "{{docker_compose.directories.config}}conf.json"
|
||||
|
||||
docker_repository: true
|
||||
settings_files:
|
||||
- urls
|
||||
- local
|
||||
|
@@ -1,2 +0,0 @@
|
||||
# Docker Role Template
|
||||
This folder contains a template to setup docker roles
|
@@ -1 +0,0 @@
|
||||
application_id: template
|
Reference in New Issue
Block a user