implemented compose by url, parse, local yaml.

This commit is contained in:
boris committed 2026-07-10 13:32:40 +01:00
1 parent 53695f4fff
commit 784fff8faf
218 files changed
+2271 -640

No files matched your search

+4 -2
View File
@@ -1,10 +1,12 @@
# docker_app
Shared implementation role for single-container Docker Compose applications.
Shared adapter role for single-container Docker Compose applications.
Application roles set `docker_app_*` variables and include this role.
`docker_app` validates single-container app inputs and delegates the common
Compose lifecycle to `compose_project`.
It supports direct host-port publishing with UFW rules or Traefik routing via
labels and a shared Docker network.
Tags: `docker_app`, `docker`, `config`, `compose`, `firewall`.
+2
View File
@@ -26,7 +26,9 @@ docker_app_traefik_entrypoint: "{{ nbops_traefik_entrypoint }}"
docker_app_traefik_tls: "{{ nbops_traefik_tls }}"
docker_app_traefik_middlewares: []
docker_app_traefik_rule: "Host(`{{ docker_app_domain }}`)"
docker_app_traefik_file_bind_address: "{{ nbops_traefik_file_bind_address }}"
docker_app_labels: {}
docker_app_ufw_ports: "{{ docker_app_ports }}"
docker_app_env_template_src: env.j2
docker_app_compose_template_src: compose.yaml.j2
docker_app_compose_override_template_src: ""
+1
View File
@@ -0,0 +1 @@
-6
View File
@@ -1,6 +0,0 @@
---
- name: restart docker app
community.docker.docker_compose_v2:
project_src: "{{ docker_app_dir }}"
state: restarted
+14 -54
View File
@@ -5,58 +5,18 @@
- docker_app_image | length > 0
fail_msg: "docker_app_image must be configured for {{ docker_app_name }}."
tags: [docker_app]
- name: Create Docker app directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: root
group: root
mode: "0755"
loop: "{{ docker_app_directories }}"
- name: Deploy Docker app Compose project
ansible.builtin.include_role:
name: compose_project
vars:
compose_project_dir: "{{ docker_app_dir }}"
compose_project_directories: "{{ docker_app_directories }}"
compose_project_env_template_src: "{{ docker_app_env_template_src }}"
compose_project_compose_template_src: "{{ docker_app_compose_template_src }}"
compose_project_override_template_src: "{{ docker_app_compose_override_template_src }}"
compose_project_create_proxy_network: "{{ docker_app_routing_mode == 'traefik' and docker_app_network_mode | length == 0 }}"
compose_project_proxy_network: "{{ docker_app_traefik_network }}"
compose_project_firewall_ports: "{{ docker_app_ufw_ports }}"
compose_project_firewall_enabled: "{{ docker_app_routing_mode in ['host', 'traefik_file'] }}"
compose_project_pull: "{{ docker_app_pull }}"
tags: [docker_app]
- name: Ensure proxy network exists
community.docker.docker_network:
name: "{{ docker_app_traefik_network }}"
state: present
when:
- docker_app_routing_mode == "traefik"
- docker_app_network_mode | length == 0
tags: [docker_app, docker]
- name: Render Docker app environment
ansible.builtin.template:
src: "{{ docker_app_env_template_src }}"
dest: "{{ docker_app_dir }}/.env"
owner: root
group: root
mode: "0600"
no_log: true
tags: [docker_app, config]
- name: Render Docker app Compose file
ansible.builtin.template:
src: "{{ docker_app_compose_template_src }}"
dest: "{{ docker_app_dir }}/compose.yaml"
owner: root
group: root
mode: "0644"
notify: restart docker app
tags: [docker_app, compose]
- name: Allow Docker app host ports
community.general.ufw:
rule: allow
port: "{{ item.host | default(item.container) }}"
proto: "{{ item.protocol | default('tcp') }}"
loop: "{{ docker_app_ufw_ports }}"
when: docker_app_routing_mode == "host"
tags: [docker_app, firewall]
- name: Start Docker app
community.docker.docker_compose_v2:
project_src: "{{ docker_app_dir }}"
state: present
pull: "{{ docker_app_pull }}"
tags: [docker_app, compose]
@@ -0,0 +1,3 @@
services:
{{ docker_app_name }}: {}
+2 -2
View File
@@ -17,10 +17,10 @@ services:
{% if docker_app_env | length > 0 %}
env_file: .env
{% endif %}
{% if docker_app_routing_mode == "host" and docker_app_ports | length > 0 %}
{% if docker_app_routing_mode in ["host", "traefik_file"] and docker_app_ports | length > 0 %}
ports:
{% for port in docker_app_ports %}
- "{{ port.bind | default('0.0.0.0') }}:{{ port.host | default(port.container) }}:{{ port.container }}{% if port.protocol | default('tcp') != 'tcp' %}/{{ port.protocol }}{% endif %}"
- "{{ port.bind | default((docker_app_traefik_file_bind_address if docker_app_routing_mode == 'traefik_file' else '0.0.0.0')) }}:{{ port.host | default(port.container) }}:{{ port.container }}{% if port.protocol | default('tcp') != 'tcp' %}/{{ port.protocol }}{% endif %}"
{% endfor %}
{% endif %}
{% if docker_app_routing_mode == "traefik" and docker_app_service_port %}