diff --git a/roles/core/network/files/netif.rc b/roles/core/network/files/netif.rc index 01a5532..e604033 100644 --- a/roles/core/network/files/netif.rc +++ b/roles/core/network/files/netif.rc @@ -1,26 +1,23 @@ # ------------------------------------------------------------- # Network — rc configuration # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Project: Nasqueron # License: Trivial work, not eligible to copyright # Source file: roles/core/network/files/netif.rc # ------------------------------------------------------------- # # # This file is managed by our rOPS SaltStack repository. # # Changes to this file may cause incorrect behavior # and will be lost if the state is redeployed. # {% if dhcp_required %} ifconfig_{{ interface }}="DHCP" {% else %} ifconfig_{{ interface }}="inet {{ ipv4_address }} netmask {{ ipv4_netmask }}" {% endif %} {% for ip in ipv4_aliases %} ifconfig_{{ interface }}_alias{{ loop.index0 }}="inet {{ ip }} netmask 255.255.255.255" {% endfor %} -{% if has_native_ipv6 %} -ifconfig_{{ ipv6_interface }}_ipv6="inet6 accept_rtadv" -{% endif %} diff --git a/roles/core/network/files/netif.rc b/roles/core/network/files/netif_ipv6.rc similarity index 55% copy from roles/core/network/files/netif.rc copy to roles/core/network/files/netif_ipv6.rc index 01a5532..600f62c 100644 --- a/roles/core/network/files/netif.rc +++ b/roles/core/network/files/netif_ipv6.rc @@ -1,26 +1,16 @@ # ------------------------------------------------------------- # Network — rc configuration # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Project: Nasqueron # License: Trivial work, not eligible to copyright -# Source file: roles/core/network/files/netif.rc +# Source file: roles/core/network/files/netif_ipv6.rc # ------------------------------------------------------------- # # # This file is managed by our rOPS SaltStack repository. # # Changes to this file may cause incorrect behavior # and will be lost if the state is redeployed. # -{% if dhcp_required %} -ifconfig_{{ interface }}="DHCP" -{% else %} -ifconfig_{{ interface }}="inet {{ ipv4_address }} netmask {{ ipv4_netmask }}" -{% endif %} -{% for ip in ipv4_aliases %} -ifconfig_{{ interface }}_alias{{ loop.index0 }}="inet {{ ip }} netmask 255.255.255.255" -{% endfor %} -{% if has_native_ipv6 %} -ifconfig_{{ ipv6_interface }}_ipv6="inet6 accept_rtadv" -{% endif %} +ifconfig_{{ interface }}_ipv6="inet6 accept_rtadv" diff --git a/roles/core/network/init.sls b/roles/core/network/init.sls index 724fbbf..a48fe24 100644 --- a/roles/core/network/init.sls +++ b/roles/core/network/init.sls @@ -1,52 +1,67 @@ # ------------------------------------------------------------- # Salt — Network # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Project: Nasqueron # Created: 2016-06-15 # License: Trivial work, not eligible to copyright # ------------------------------------------------------------- {% from "map.jinja" import dirs with context %} {% set network = salt['node.get']('network') %} # ------------------------------------------------------------- # IPv4 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {% if grains['os'] == 'FreeBSD' %} /etc/rc.conf.d/netif/ipv4_{{ network['ipv4_interface'] }}: file.managed: - source: salt://roles/core/network/files/netif.rc - makedirs: True - template: jinja - context: interface: {{ network['ipv4_interface'] }} ipv4_address: {{ network['ipv4_address'] }} ipv4_netmask: {{ network['ipv4_netmask'] | default('255.255.255.0') }} ipv4_aliases: {{ salt['node.get_list']('network:ipv4_aliases') }} dhcp_required: {{ salt['node.has']('network:dhcp_required') }} ipv6_interface: {{ network['ipv6_interface'] }} has_native_ipv6: {{ salt['node.has']('network:ipv6_native') }} /etc/rc.conf.d/routing: file.managed: - source: salt://roles/core/network/files/routing.rc - template: jinja - context: ipv4_gateway: {{ network['ipv4_gateway'] }} ipv6_gateway: {{ network['ipv6_gateway'] | default('') }} {% endif %} # ------------------------------------------------------------- # IPv6 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +{% if salt['node.has']('network:ipv6_native') %} +{% if grains['os'] == 'FreeBSD' %} +/etc/rc.conf.d/netif/ipv6_{{ network['ipv6_interface'] }}: + file.managed: + - source: salt://roles/core/network/files/netif_ipv6.rc + - makedirs: True + - template: jinja + - context: + interface: {{ network['ipv6_interface'] }} + ipv6_address: {{ network['ipv6_address'] }} + ipv6_prefix: {{ network['ipv6_prefix'] | default(64) }} + has_native_ipv6: True +{% endif %} +{% endif %} + {% if salt['node.has']('network:ipv6_tunnel') %} network_ipv6: file.managed: - name : {{ dirs.sbin }}/ipv6-setup-tunnel - source: salt://roles/core/network/files/{{ grains['id'] }}_ipv6.sh.jinja - template: jinja - mode: 755 {% endif %}