network: Playbook to configure networking
The `network.yml` playbook is used to configure the network interfaces on a managed node. Currently, it only supports the Red Hat configuration style (i.e. `/etc/sysconfig/network-scripts/ifcfg-*` files).
This commit is contained in:
59
roles/rhel-network/templates/ifcfg.j2
Normal file
59
roles/rhel-network/templates/ifcfg.j2
Normal file
@@ -0,0 +1,59 @@
|
||||
{#- vim: set ft=jinja : -#}
|
||||
DEVICE="{{ item.ifname }}"
|
||||
{% if item.enabled %}
|
||||
ONBOOT="yes"
|
||||
{% else %}
|
||||
ONBOOT="no"
|
||||
{% endif %}
|
||||
|
||||
{% if item.mode == "auto" %}
|
||||
BOOTPROTO="dhcp"
|
||||
{% elif item.mode == "manual" %}
|
||||
BOOTPROTO="none"
|
||||
IPADDR="{{ item.addr }}"
|
||||
{% if item.mask is defined %}
|
||||
NETMASK="{{ item.mask }}"
|
||||
{% else %}
|
||||
PREFIX={{ item.prefix|d(24) }}
|
||||
{% endif %}
|
||||
{% if item.gateway is defined %}
|
||||
GATEWAY="{{ item.gateway }}"
|
||||
{% endif %}
|
||||
{% for dns in item.dns|d(()) %}
|
||||
DNS{{ loop.index }}="{{ dns }}"
|
||||
{% endfor %}
|
||||
{% if item.addr6 is defined %}
|
||||
IPV6ADDR="{{ item.addr6 }}"
|
||||
{% endif %}
|
||||
{% else %}
|
||||
BOOTPROTO="none"
|
||||
{% endif %}
|
||||
{% if item.dhcpv6 is defined %}
|
||||
{% if item.dhcpv6.enabled|d(True) %}
|
||||
DHCPV6C="yes"
|
||||
{% if item.dhcpv6.stateless|d(False) %}
|
||||
DHCPV6C_OPTIONS="-S"
|
||||
{% elif item.dhcpv6.temporary|d(False) %}
|
||||
DHCPV6C_OPTIONS="-T"
|
||||
{% elif item.dhcpv6.pd|d(False) %}
|
||||
DHCPV6C_OPTIONS="-P"
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if item.master|d %}
|
||||
|
||||
SLAVE=yes
|
||||
MASTER={{ item.master }}
|
||||
{% endif %}
|
||||
{% if item.bond_opts|d %}
|
||||
|
||||
BONDING_OPTS="{% for key, value in default_bond_opts|combine(item.bond_opts)|dictsort %}{{ key }}={{ value }}{% if not loop.last %} {% endif %}{% endfor %}"
|
||||
{% endif %}
|
||||
{% if item.vlan_id|d %}
|
||||
|
||||
VLAN=yes
|
||||
VID={{ item.vlan_id }}
|
||||
{% if item.physdev|d %}
|
||||
PHYSDEV={{ item.physdev }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
Reference in New Issue
Block a user