diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d20b64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc diff --git a/TEST/README.md b/TEST/README.md index cc2d02f..5e29947 100644 --- a/TEST/README.md +++ b/TEST/README.md @@ -11,11 +11,11 @@ cd ./ansible-network-role/ cat < ./TEST/inventory [network-test] -v-rhel6-1 ansible_user=root -v-rhel7-b ansible_user=root +v-rhel6 ansible_user=root network_iphost=196 network_mac=52:54:00:44:9f:ba +v-rhel7 ansible_user=root network_iphost=97 network_mac=52:54:00:05:f5:b3 EOF ../ansible/hacking/test-module -m ./library/network_connections.py -a 'provider=nm name=t-eth0 state=present type=ethernet' --check -ansible-playbook -i ./TEST/inventory ./TEST/test-playbook.yml --verbose --check +ansible-playbook -i ./TEST/inventory -l '*rhel*' ./TEST/test-playbook-3.yml --verbose --check ``` diff --git a/TEST/test-playbook-3.yml b/TEST/test-playbook-3.yml index 0dd2141..3931f4c 100644 --- a/TEST/test-playbook-3.yml +++ b/TEST/test-playbook-3.yml @@ -14,11 +14,12 @@ autoconnect: no interface_name: eth0 type: ethernet + mac: "{{ network_mac | default(omit) }}" ip: dhcp4: no gateway4: 192.168.122.1 address: - - 192.168.122.97/24 + - "192.168.122.{{ network_iphost }}/24" - name: p-3-manual diff --git a/library/network_connections.py b/library/network_connections.py index 6603e67..40377fa 100755 --- a/library/network_connections.py +++ b/library/network_connections.py @@ -856,12 +856,15 @@ class NMCmd: s_con.set_property(NM.SETTING_CONNECTION_INTERFACE_NAME, args['interface_name']) if args['type'] == 'ethernet': + s_con.set_property(NM.SETTING_CONNECTION_TYPE, '802-3-ethernet') s_wired = NM.SettingWired.new() connection.add_setting(s_wired) - s_con.set_property(NM.SETTING_CONNECTION_TYPE, '802-3-ethernet') s_wired.set_property(NM.SETTING_WIRED_MAC_ADDRESS, args['mac']) elif args['type'] == 'bridge': s_con.set_property(NM.SETTING_CONNECTION_TYPE, 'bridge') + s_bridge = NM.SettingBridge.new() + connection.add_setting(s_bridge) + s_bridge.set_property(NM.SETTING_BRIDGE_STP, False) elif args['type'] == 'bond': s_con.set_property(NM.SETTING_CONNECTION_TYPE, 'bond') elif args['type'] == 'team':