container: Set network ip range when using a static container ip
This commit is contained in:
@@ -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') }}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user