diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2025-06-25 09:45:17 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2025-06-25 09:46:16 +0300 |
| commit | 592be65638236b81dd1c30391d97febb7d946a7b (patch) | |
| tree | 7e8df82984d0096f1dbe922007707bb245a1ba5b | |
| parent | ca1ee4f5ee0458e69cd871518dfc00569fa7e2d4 (diff) | |
Persist jail ip aliases
| -rw-r--r-- | playbook.yml | 1 | ||||
| -rw-r--r-- | tasks/network.yml | 13 | ||||
| -rw-r--r-- | 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 %} |
