forked from michaelrigart/ansible-role-interfaces
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ethernet template for network manager
- Loading branch information
Showing
5 changed files
with
99 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,9 @@ | |
- name: Create the network configuration file for ethernet devices | ||
become: true | ||
template: | ||
src: 'ethernet_{{ ansible_facts.os_family }}.j2' | ||
src: 'ethernet_{{ ansible_facts.os_family }}{% if interfaces_use_networkmanager | bool %}_nm{% endif %}.j2' | ||
This comment has been minimized.
Sorry, something went wrong.
eb4x
|
||
dest: '{{ interfaces_net_path[ansible_facts.os_family|lower] }}/ifcfg-{{ item.device }}' | ||
mode: '0600' | ||
with_items: '{{ interfaces_ether_interfaces }}' | ||
register: ether_result | ||
notify: | ||
|
@@ -28,7 +29,10 @@ | |
src: 'route_{{ ansible_facts.os_family }}.j2' | ||
dest: '{{ interfaces_net_path[ansible_facts.os_family|lower] }}/route-{{ item.device }}' | ||
with_items: '{{ interfaces_ether_interfaces }}' | ||
when: item.route is defined and ansible_facts.os_family == 'RedHat' | ||
when: | ||
- item.route is defined | ||
- ansible_facts.os_family == 'RedHat' | ||
- not interfaces_use_networkmanager | ||
register: ether_route_add_result | ||
notify: | ||
- Bounce network devices | ||
|
@@ -39,7 +43,11 @@ | |
src: 'route6_{{ ansible_facts.os_family }}.j2' | ||
dest: '{{ interfaces_net_path[ansible_facts.os_family|lower] }}/route6-{{ item.device }}' | ||
with_items: '{{ interfaces_ether_interfaces }}' | ||
when: item.ip6 is defined and item.ip6.route is defined and ansible_facts.os_family == 'RedHat' | ||
when: | ||
- item.ip6 is defined | ||
- item.ip6.route is defined | ||
- ansible_facts.os_family == 'RedHat' | ||
- not interfaces_use_networkmanager | ||
register: ether_route6_add_result | ||
notify: | ||
- Bounce network devices | ||
|
@@ -50,7 +58,10 @@ | |
path: '{{ interfaces_net_path[ansible_facts.os_family|lower] }}/route-{{ item.device }}' | ||
state: absent | ||
with_items: '{{ interfaces_ether_interfaces }}' | ||
when: item.route is not defined and ansible_facts.os_family == 'RedHat' | ||
when: | ||
- item.route is not defined | ||
- ansible_facts.os_family == 'RedHat' | ||
- not interfaces_use_networkmanager | ||
register: ether_route_del_result | ||
notify: | ||
- Bounce network devices | ||
|
@@ -61,7 +72,10 @@ | |
path: '{{ interfaces_net_path[ansible_facts.os_family|lower] }}/route6-{{ item.device }}' | ||
state: absent | ||
with_items: '{{ interfaces_ether_interfaces }}' | ||
when: item.ip6 is not defined and ansible_facts.os_family == 'RedHat' | ||
when: | ||
- item.ip6 is not defined | ||
- ansible_facts.os_family == 'RedHat' | ||
- not interfaces_use_networkmanager | ||
register: ether_route6_del_result | ||
notify: | ||
- Bounce network devices | ||
|
@@ -72,7 +86,10 @@ | |
src: 'rule_{{ ansible_facts.os_family }}.j2' | ||
dest: '{{ interfaces_net_path[ansible_facts.os_family|lower] }}/rule-{{ item.device }}' | ||
with_items: '{{ interfaces_ether_interfaces }}' | ||
when: item.rules is defined and ansible_facts.os_family == 'RedHat' | ||
when: | ||
- item.rules is defined | ||
- ansible_facts.os_family == 'RedHat' | ||
- not interfaces_use_networkmanager | ||
register: ether_rule_add_result | ||
notify: | ||
- Bounce network devices | ||
|
@@ -83,7 +100,10 @@ | |
path: '{{ interfaces_net_path[ansible_facts.os_family|lower] }}/rule-{{ item.device }}' | ||
state: absent | ||
with_items: '{{ interfaces_ether_interfaces }}' | ||
when: item.rules is not defined and ansible_facts.os_family == 'RedHat' | ||
when: | ||
- item.rules is not defined | ||
- ansible_facts.os_family == 'RedHat' | ||
- not interfaces_use_networkmanager | ||
register: ether_rule_del_result | ||
notify: | ||
- Bounce network devices | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# {{ ansible_managed }} | ||
|
||
[connection] | ||
id={{ item.device }} | ||
type={{ (item.device is match(vlan_interface_regex)) | ternary('vlan', 'ethernet') }} | ||
interface-name={{ item.device }} | ||
{% if item.onboot is defined %} | ||
autoconnect={{ item.onboot | bool | ternary('yes', 'no') }} | ||
{% endif %} | ||
{% if item.zone is defined %} | ||
zone={{ item.zone }} | ||
{% endif %} | ||
|
||
[ethernet] | ||
{% if item.hwaddr is defined %} | ||
mac-address={{ item.hwaddr }} | ||
{% endif %} | ||
{% if item.mtu is defined %} | ||
mtu={{ item.mtu }} | ||
{% endif %} | ||
|
||
{% if item.device is match(vlan_interface_regex) %} | ||
[vlan] | ||
parent={{ item.device | regex_replace(vlan_interface_suffix_regex, '') }} | ||
## FIXME(bbezak) - get vlanid from name | ||
id= | ||
{% endif %} | ||
|
||
[ipv4] | ||
{% if item.bootproto == 'static' %} | ||
method=manual | ||
{% if item.address is defined %} | ||
{% if item.netmask is defined %} | ||
{% set network_prefix = (item.address ~ item.netmask) | ipaddr('network/prefix') %} | ||
addresses={{ network_prefix }} | ||
{% endif %} | ||
{% endif %} | ||
{% if item.gateway is defined %} | ||
gateway={{ item.gateway }} | ||
{% endif %} | ||
{% if item.dnsnameservers is defined %} | ||
dns={{ item.dnsnameservers|replace(" ",";") ~ ';' }} | ||
{% endif %} | ||
{% if item.dnssearch is defined %} | ||
dns-search={{ item.dnssearch ~ ';' }} | ||
{% endif %} | ||
{% endif %} | ||
{% if item.bootproto == 'dhcp' %} | ||
method=auto | ||
{% endif %} | ||
{# FIXME(bbezak) Defroute has opposite value from never-default setting #} | ||
{% if item.defroute is defined %} | ||
never-default={{ item.defroute | bool | ternary('yes', 'no') }} | ||
{% endif %} | ||
{# TODO(bbezak) Add ethtool-opts #} | ||
|
||
{% if item.bootproto == 'static' %} | ||
{% if item.ip6 is defined %} | ||
[ipv6] | ||
method=manual | ||
addresses={{ item.ip6.address ~ '/' ~ item.ip6.prefix }} | ||
{% if item.ip6.gateway is defined %} | ||
gateway={{ item.ip6.gateway }} | ||
{# TODO(bbezak) No IPV6_DEFAULTDEV equivalent in NM?? #} | ||
{% endif %} | ||
{% endif %} | ||
{% endif %} | ||
|
||
{# TODO(bbezak) Add routing configuration here for NM #} |
Suggest a separate flag
interfaces_use_nmconnection
or something to that effect, for using these new file types, so we can introduce networkmanager with network-scripts, and introduce nmconnections as an experimental feature.