From 592be65638236b81dd1c30391d97febb7d946a7b Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Wed, 25 Jun 2025 09:45:17 +0300 Subject: Persist jail ip aliases --- playbook.yml | 1 + tasks/network.yml | 13 +++++++++++-- templates/etc_jail.conf.j2 | 1 - 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/playbook.yml b/playbook.yml index da225c2..91c5334 100644 --- a/playbook.yml +++ b/playbook.yml @@ -22,6 +22,7 @@ jail_userland_version: 14.3-RELEASE jails: - { name: nginx_test, ip: "192.168.2.1" } + - { name: postgres, ip: "192.168.2.2" } tasks: - name: Run network tasks diff --git a/tasks/network.yml b/tasks/network.yml index 0f713a0..8824501 100644 --- a/tasks/network.yml +++ b/tasks/network.yml @@ -12,11 +12,20 @@ - { name: "ifconfig_wan0", value: "DHCP" } - { name: "ifconfig_lan0_ipv6", value: "inet6 accept_rtadv" } - { name: "ifconfig_wan0_ipv6", value: "inet6 accept_rtadv" } - register: ifconfig_sysrc + register: ifconfig_base_sysrc + +- name: Set up jail aliases on lan0 + community.general.sysrc: + name: "ifconfig_lan0_alias{{ index }}" + value: "inet {{ item.ip }}/32" + loop: "{{ jails }}" + loop_control: + index_var: index + register: ifconfig_jail_sysrc - name: Restart networking if interface configuration changed shell: service netif restart - when: ifconfig_sysrc.changed + when: ifconfig_base_sysrc.changed or ifconfig_jail_sysrc.changed - name: Update facts setup: diff --git a/templates/etc_jail.conf.j2 b/templates/etc_jail.conf.j2 index bcfcef0..eb6d128 100644 --- a/templates/etc_jail.conf.j2 +++ b/templates/etc_jail.conf.j2 @@ -16,7 +16,6 @@ path = "/usr/local/jails/containers/${name}"; {% for jail in jails %} {{ jail.name }} { ip4.addr = {{ jail.ip }}; - interface = lan0; } {% endfor %} -- cgit v1.3