Compare commits
4 Commits
b333bbebbd
...
597faa3fd5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
597faa3fd5 | ||
|
|
16babfd5ed | ||
|
|
d3542993dd | ||
|
|
a93c26864d |
@@ -15,11 +15,8 @@
|
|||||||
name: network
|
name: network
|
||||||
vars:
|
vars:
|
||||||
network_name: "{{ network }}"
|
network_name: "{{ network }}"
|
||||||
network_subnet: >-
|
network_subnet: "{{ _container_network_subnet if network_index == 0 else '' }}"
|
||||||
{{
|
network_range: "{{ _container_network_range if network_index == 0 else '' }}"
|
||||||
container_ip | ansible.utils.ipsubnet(24)
|
|
||||||
if (container_ip | length > 0 and network_index == 0) else ''
|
|
||||||
}}
|
|
||||||
when: network_created_networks is not defined or network not in network_created_networks
|
when: network_created_networks is not defined or network not in network_created_networks
|
||||||
loop: "{{ container_networks }}"
|
loop: "{{ container_networks }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
|
|||||||
@@ -11,6 +11,22 @@ _container_networks_with_ip: >-
|
|||||||
]
|
]
|
||||||
+ _container_networks[1:]
|
+ _container_networks[1:]
|
||||||
}}
|
}}
|
||||||
|
_container_network_subnet: >-
|
||||||
|
{{ container_ip | ansible.utils.ipsubnet(24) if container_ip | length > 0 else '' }}
|
||||||
|
_container_network_subnet_ranges: >-
|
||||||
|
{{
|
||||||
|
[
|
||||||
|
_container_network_subnet | ansible.utils.ipsubnet(25, 0),
|
||||||
|
_container_network_subnet | ansible.utils.ipsubnet(25, 1)
|
||||||
|
] if container_ip | length > 0 else ''
|
||||||
|
}}
|
||||||
|
_container_network_range: >-
|
||||||
|
{{
|
||||||
|
_container_network_subnet_ranges |
|
||||||
|
reject('ansible.utils.supernet_of', container_ip) |
|
||||||
|
first
|
||||||
|
if container_ip | length > 0 else ''
|
||||||
|
}}
|
||||||
|
|
||||||
_container_volumes: "{{ container_mounts | selectattr('type', '==', 'volume') }}"
|
_container_volumes: "{{ container_mounts | selectattr('type', '==', 'volume') }}"
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
---
|
---
|
||||||
network_driver: bridge
|
network_driver: bridge
|
||||||
network_subnet: ""
|
network_subnet: ""
|
||||||
|
network_range: ""
|
||||||
|
|||||||
@@ -20,3 +20,8 @@ argument_specs:
|
|||||||
type: str
|
type: str
|
||||||
required: false
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
|
network_range:
|
||||||
|
description: Range to allocate ip addresses from
|
||||||
|
type: str
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
quadlet_file_mode: "0644"
|
quadlet_file_mode: "0644"
|
||||||
driver: "{{ network_driver }}"
|
driver: "{{ network_driver }}"
|
||||||
subnet: "{{ network_subnet if network_subnet | length > 0 else omit }}"
|
subnet: "{{ network_subnet if network_subnet | length > 0 else omit }}"
|
||||||
|
ip_range: "{{ network_range if network_range | length > 0 else omit }}"
|
||||||
quadlet_options: >-
|
quadlet_options: >-
|
||||||
{{
|
{{
|
||||||
['Options=parent=' ~ ansible_default_ipv4.interface]
|
['Options=parent=' ~ ansible_default_ipv4.interface]
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
container_mounts: "{{ _service_additional_container_mounts }}"
|
container_mounts: "{{ _service_additional_container_mounts }}"
|
||||||
container_publish_ports: "{{ _service_additional_container.publish_ports | default([]) }}"
|
container_publish_ports: "{{ _service_additional_container.publish_ports | default([]) }}"
|
||||||
container_networks: "{{ _service_container_networks }}"
|
container_networks: "{{ _service_container_networks }}"
|
||||||
|
container_ip: "{{ _service_additional_container_ip }}"
|
||||||
container_secrets: "{{ _service_additional_container.secrets | default(_service_container_secrets) }}"
|
container_secrets: "{{ _service_additional_container.secrets | default(_service_container_secrets) }}"
|
||||||
container_env: "{{ _service_additional_container.env | default(service_container_env) }}"
|
container_env: "{{ _service_additional_container.env | default(service_container_env) }}"
|
||||||
container_requires: "{{ _service_container_requires }}"
|
container_requires: "{{ _service_container_requires }}"
|
||||||
@@ -19,3 +20,4 @@
|
|||||||
loop: "{{ _service_additional_containers }}"
|
loop: "{{ _service_additional_containers }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: _service_additional_container
|
loop_var: _service_additional_container
|
||||||
|
index_var: _service_additional_container_index
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
source: "{{ _service_database_name }}"
|
source: "{{ _service_database_name }}"
|
||||||
destination: /var/lib/postgresql/data
|
destination: /var/lib/postgresql/data
|
||||||
container_networks: "{{ _service_database_networks }}"
|
container_networks: "{{ _service_database_networks }}"
|
||||||
|
container_ip: >-
|
||||||
|
{{ service_container_ip | ansible.utils.ipmath(1) if _service_static_ip else '' }}
|
||||||
container_secrets:
|
container_secrets:
|
||||||
- name: "{{ _service_database_name }}"
|
- name: "{{ _service_database_name }}"
|
||||||
target: "{{ service_database_type }}"
|
target: "{{ service_database_type }}"
|
||||||
|
|||||||
@@ -47,6 +47,8 @@
|
|||||||
vars:
|
vars:
|
||||||
socat_service_name: "{{ service_name }}"
|
socat_service_name: "{{ service_name }}"
|
||||||
socat_target_http_port: "{{ service_container_http_port }}"
|
socat_target_http_port: "{{ service_container_http_port }}"
|
||||||
|
socat_container_ip: >-
|
||||||
|
{{ service_container_ip | ansible.utils.ipmath(3) if _service_static_ip else '' }}
|
||||||
|
|
||||||
- name: Reverse proxy for {{ service_name }}
|
- name: Reverse proxy for {{ service_name }}
|
||||||
ansible.builtin.include_tasks: proxy.yaml
|
ansible.builtin.include_tasks: proxy.yaml
|
||||||
|
|||||||
@@ -34,3 +34,4 @@
|
|||||||
vars:
|
vars:
|
||||||
socat_service_name: "{{ service_name }}-oauth2-proxy"
|
socat_service_name: "{{ service_name }}-oauth2-proxy"
|
||||||
socat_target_http_port: 4180
|
socat_target_http_port: 4180
|
||||||
|
socat_container_ip: ""
|
||||||
|
|||||||
@@ -7,4 +7,6 @@
|
|||||||
container_image: docker.io/valkey/valkey:alpine
|
container_image: docker.io/valkey/valkey:alpine
|
||||||
container_networks:
|
container_networks:
|
||||||
- "{{ service_name }}"
|
- "{{ service_name }}"
|
||||||
|
container_ip: >-
|
||||||
|
{{ service_container_ip | ansible.utils.ipmath(2) if _service_static_ip else '' }}
|
||||||
container_auto_update: "{{ service_auto_update }}"
|
container_auto_update: "{{ service_auto_update }}"
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
container_user: nobody
|
container_user: nobody
|
||||||
container_networks:
|
container_networks:
|
||||||
- "{{ socat_service_name }}"
|
- "{{ socat_service_name }}"
|
||||||
|
container_ip: "{{ socat_container_ip }}"
|
||||||
container_requires:
|
container_requires:
|
||||||
- "{{ socat_service_name }}-socat.socket"
|
- "{{ socat_service_name }}-socat.socket"
|
||||||
- "{{ socat_service_name }}.service"
|
- "{{ socat_service_name }}.service"
|
||||||
|
|||||||
@@ -11,6 +11,13 @@ _service_additional_containers: >-
|
|||||||
| map('combine')
|
| map('combine')
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
_service_additional_container_ip: >-
|
||||||
|
{{
|
||||||
|
service_container_ip |
|
||||||
|
ansible.utils.ipmath(20 + _service_additional_container_index)
|
||||||
|
if _service_static_ip else ''
|
||||||
|
}}
|
||||||
|
|
||||||
|
|
||||||
_service_additional_volume_mounts: "{{ _service_additional_container.mounts | selectattr('type', '==', 'volume') }}"
|
_service_additional_volume_mounts: "{{ _service_additional_container.mounts | selectattr('type', '==', 'volume') }}"
|
||||||
_service_additional_template_mounts: "{{ _service_additional_container.mounts | selectattr('type', '==', 'template') }}"
|
_service_additional_template_mounts: "{{ _service_additional_container.mounts | selectattr('type', '==', 'template') }}"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
_service_container_networks: "{{ [service_name] + service_container_additional_networks }}"
|
_service_container_networks: "{{ [service_name] + service_container_additional_networks }}"
|
||||||
|
_service_static_ip: "{{ service_container_ip | length > 0 }}"
|
||||||
|
|
||||||
_service_container_requires: >-
|
_service_container_requires: >-
|
||||||
{{
|
{{
|
||||||
@@ -11,6 +12,7 @@ _service_container_wants: >-
|
|||||||
{{
|
{{
|
||||||
service_wants
|
service_wants
|
||||||
+ ([service_name + '-socat.socket'] if service_container_http_port > 0 else [])
|
+ ([service_name + '-socat.socket'] if service_container_http_port > 0 else [])
|
||||||
|
+ ([service_name + '-oauth2-proxy-socat.socket'] if _service_oauth2_proxy else [])
|
||||||
+ _service_additional_containers
|
+ _service_additional_containers
|
||||||
| map(attribute='name')
|
| map(attribute='name')
|
||||||
| map('regex_replace', '$', '.service')
|
| map('regex_replace', '$', '.service')
|
||||||
|
|||||||
Reference in New Issue
Block a user