network: Add support for setting static IP on RedHat
This commit is contained in:
parent
1a0a8ac1d2
commit
f87df3b96d
3 changed files with 56 additions and 0 deletions
35
roles/network/templates/ifcfg-eth.j2
Normal file
35
roles/network/templates/ifcfg-eth.j2
Normal file
|
@ -0,0 +1,35 @@
|
|||
DEVICE="{{ item.device }}"
|
||||
{% for line in interface_uuid.stdout_lines %}
|
||||
{% if line.split()[0] == item.device %}
|
||||
UUID="{{ line.split()[1] }}"
|
||||
{% elif line.split()[2] == item.device %}
|
||||
UUID="{{ line.split()[1] }}"
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if item.mac is defined %}
|
||||
HWADDR="{{ item.mac }}"
|
||||
{% elif lookup('vars', 'ansible_' + item.device, default=undefined) is undefined %}
|
||||
HWADDR="{{ lookup('vars', 'ansible_' + item.device + '["macaddress"]') }}
|
||||
{% endif %}
|
||||
ONBOOT=yes
|
||||
{% if item.proto is not defined or item.proto == 'dhcp' %}
|
||||
NETBOOT=yes
|
||||
BOOTPROTO=dhcp
|
||||
{% elif item.proto == 'static' %}
|
||||
IPADDR="{{ item.ipaddr }}"
|
||||
NETMASK="{{ item.netmask }}"
|
||||
{% if item.gateway is defined %}
|
||||
GATEWAY="{{ item.gateway }}"
|
||||
{% endif %}
|
||||
{% elif proto == 'none' %}
|
||||
BOOTPROTO=none
|
||||
{% endif %}
|
||||
{% if item.ip6addr is defined and item.ip6addr != 'none' %}
|
||||
IPV6INIT=yes
|
||||
{% if item.ip6addr != 'auto' %}
|
||||
IPV6ADDR="{{ item.ip6addr }}"
|
||||
{% endif %}
|
||||
{% else %}
|
||||
IPV6INIT=no
|
||||
{% endif %}
|
||||
TYPE=Ethernet
|
Loading…
Add table
Add a link
Reference in a new issue