container: Allow custom ip addresses for more than one network
This commit is contained in:
@@ -22,14 +22,21 @@ _service_additional_container_wants: >-
|
||||
|
||||
_service_additional_container_networks: >-
|
||||
{{
|
||||
[service_name]
|
||||
+ service_container_additional_networks
|
||||
[{
|
||||
'name': service_name,
|
||||
'ip':
|
||||
service_container_ip | ansible.utils.ipmath(20 + _service_additional_container_index)
|
||||
if _service_static_ip else ''
|
||||
}]
|
||||
+ (
|
||||
_service_additional_container_publish_socket_ports
|
||||
| map(attribute='name')
|
||||
| map('regex_replace', '^', service_name ~ '-')
|
||||
| map('regex_replace', '$', '-socat')
|
||||
)
|
||||
service_container_additional_networks
|
||||
+ (
|
||||
_service_additional_container_publish_socket_ports
|
||||
| map(attribute='name')
|
||||
| map('regex_replace', '^', service_name ~ '-')
|
||||
| map('regex_replace', '$', '-socat')
|
||||
)
|
||||
) | map('community.general.dict_kv', 'name')
|
||||
}}
|
||||
|
||||
_service_additional_container_secrets: >-
|
||||
@@ -50,13 +57,6 @@ _service_additional_container_secrets: >-
|
||||
else _service_container_secrets
|
||||
}}
|
||||
|
||||
_service_additional_container_ip: >-
|
||||
{{
|
||||
service_container_ip |
|
||||
ansible.utils.ipmath(20 + _service_additional_container_index)
|
||||
if _service_static_ip else ''
|
||||
}}
|
||||
|
||||
_service_additional_container_publish_ports_with_defaults: >-
|
||||
{{
|
||||
([{ 'type': 'port', 'host_address': '0.0.0.0' }] * _service_additional_container.publish_ports | length)
|
||||
|
||||
@@ -3,8 +3,11 @@ _service_setup_database: "{{ service_database_type != 'none' }}"
|
||||
_service_database_name: "{{ service_name }}-{{ service_database_type }}"
|
||||
_service_database_networks: >-
|
||||
{{
|
||||
[service_name] +
|
||||
service_database_additional_networks
|
||||
[{
|
||||
'name': service_name,
|
||||
'ip': service_container_ip | ansible.utils.ipmath(1) if _service_static_ip else ''
|
||||
}]
|
||||
+ service_database_additional_networks | map('community.general.dict_kv', 'name')
|
||||
}}
|
||||
|
||||
_service_database_secret:
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
---
|
||||
_service_container_networks: >-
|
||||
{{
|
||||
[service_name]
|
||||
+ service_container_additional_networks
|
||||
+ ([service_name ~ '-socat'] if service_container_http_port > 0 else [])
|
||||
+ (_service_container_publish_socket_ports | map(attribute='name') | map('regex_replace', '^', service_name ~ '-'))
|
||||
[{
|
||||
'name': service_name,
|
||||
'ip': service_container_ip
|
||||
}]
|
||||
+ (
|
||||
[{
|
||||
'name': service_name ~ '-socat',
|
||||
'ip': service_container_ip | ansible.utils.ipmath(256) if _service_static_ip else ''
|
||||
}] if service_container_http_port > 0 else []
|
||||
)
|
||||
+ (
|
||||
service_container_additional_networks
|
||||
+ (_service_container_publish_socket_ports | map(attribute='name') | map('regex_replace', '^', service_name ~ '-'))
|
||||
) | map('community.general.dict_kv', 'name')
|
||||
}}
|
||||
_service_static_ip: "{{ service_container_ip | length > 0 }}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user