container: Support static ip for container

This commit is contained in:
uumas
2025-09-14 03:08:24 +03:00
parent ad50e05ee9
commit 0b73582f36
4 changed files with 24 additions and 1 deletions

View File

@@ -15,10 +15,16 @@
name: network
vars:
network_name: "{{ network }}"
network_subnet: >-
{{
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
loop: "{{ container_networks }}"
loop_control:
loop_var: network
index_var: network_index
- name: Create volumes for container {{ container_name }}
ansible.builtin.include_role:
@@ -45,7 +51,7 @@
command: "{{ container_command or omit }}"
user: "{{ container_user or omit }}"
mount: "{{ _container_mounts | map('items') | map('map', 'join', '=') | map('join', ',') }}"
network: "{{ container_networks | map('regex_replace', '$', '.network') }}"
network: "{{ _container_networks_with_ip }}"
publish: "{{ container_publish_ports }}"
secrets: "{{ _container_secrets }}"
env: "{{ container_env }}"