mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-10 03:01:29 -07:00
nmcli: Fix known validate-modules issues (#52493)
This PR includes: - Adding parameter types - Fix validate-modules issue - Improve parameter types and resulting changes This PR needs to be verified and tested by maintainer(s).
This commit is contained in:
parent
1f9da61bce
commit
365ded2df6
3 changed files with 184 additions and 139 deletions
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright: (c) 2015, Chris Long <alcamie@gmail.com> <chlong@redhat.com>
|
# Copyright: (c) 2015, Chris Long <alcamie@gmail.com> <chlong@redhat.com>
|
||||||
# Copyright: (c) 2017, Ansible Project
|
# Copyright: (c) 2017, Ansible Project
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
@ -7,20 +8,22 @@
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
ANSIBLE_METADATA = {
|
ANSIBLE_METADATA = {
|
||||||
'metadata_version': '1.1',
|
'metadata_version': '1.1',
|
||||||
'status': ['preview'],
|
'status': ['preview'],
|
||||||
'supported_by': 'community'
|
'supported_by': 'community'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DOCUMENTATION = r'''
|
||||||
DOCUMENTATION = '''
|
|
||||||
---
|
---
|
||||||
module: nmcli
|
module: nmcli
|
||||||
author: "Chris Long (@alcamie101)"
|
author:
|
||||||
|
- Chris Long (@alcamie101)
|
||||||
short_description: Manage Networking
|
short_description: Manage Networking
|
||||||
requirements: [ nmcli, dbus, NetworkManager-glib ]
|
requirements:
|
||||||
|
- dbus
|
||||||
|
- NetworkManager-glib
|
||||||
|
- nmcli
|
||||||
version_added: "2.0"
|
version_added: "2.0"
|
||||||
description:
|
description:
|
||||||
- Manage the network devices. Create, modify and manage various connection and device type e.g., ethernet, teams, bonds, vlans etc.
|
- Manage the network devices. Create, modify and manage various connection and device type e.g., ethernet, teams, bonds, vlans etc.
|
||||||
|
@ -32,177 +35,223 @@ options:
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Whether the device should exist or not, taking action if the state is different from what is stated.
|
- Whether the device should exist or not, taking action if the state is different from what is stated.
|
||||||
required: True
|
type: str
|
||||||
choices: [ present, absent ]
|
required: true
|
||||||
|
choices: [ absent, present ]
|
||||||
autoconnect:
|
autoconnect:
|
||||||
description:
|
description:
|
||||||
- Whether the connection should start on boot.
|
- Whether the connection should start on boot.
|
||||||
- Whether the connection profile can be automatically activated
|
- Whether the connection profile can be automatically activated
|
||||||
type: bool
|
type: bool
|
||||||
default: True
|
default: yes
|
||||||
conn_name:
|
conn_name:
|
||||||
description:
|
description:
|
||||||
- 'Where conn_name will be the name used to call the connection. when not provided a default name is generated: <type>[-<ifname>][-<num>]'
|
- 'Where conn_name will be the name used to call the connection. when not provided a default name is generated: <type>[-<ifname>][-<num>]'
|
||||||
required: True
|
type: str
|
||||||
|
required: true
|
||||||
ifname:
|
ifname:
|
||||||
description:
|
description:
|
||||||
- Where IFNAME will be the what we call the interface name.
|
- The interface to bind the connection to.
|
||||||
- interface to bind the connection to. The connection will only be applicable to this interface name.
|
- The connection will only be applicable to this interface name.
|
||||||
- A special value of "*" can be used for interface-independent connections.
|
- A special value of C('*') can be used for interface-independent connections.
|
||||||
- The ifname argument is mandatory for all connection types except bond, team, bridge and vlan.
|
- The ifname argument is mandatory for all connection types except bond, team, bridge and vlan.
|
||||||
default: conn_name
|
- This parameter defaults to C(conn_name) when left unset.
|
||||||
|
type: str
|
||||||
type:
|
type:
|
||||||
description:
|
description:
|
||||||
- This is the type of device or network connection that you wish to create or modify.
|
- This is the type of device or network connection that you wish to create or modify.
|
||||||
- "type C(generic) is added in version 2.5."
|
- Type C(generic) is added in Ansible 2.5.
|
||||||
choices: [ ethernet, team, team-slave, bond, bond-slave, bridge, bridge-slave, vlan, vxlan, ipip, sit, generic ]
|
type: str
|
||||||
|
choices: [ bond, bond-slave, bridge, bridge-slave, ethernet, generic, ipip, sit, team, team-slave, vlan, vxlan ]
|
||||||
mode:
|
mode:
|
||||||
description:
|
description:
|
||||||
- This is the type of device or network connection that you wish to create for a bond, team or bridge.
|
- This is the type of device or network connection that you wish to create for a bond, team or bridge.
|
||||||
choices: [ "balance-rr", "active-backup", "balance-xor", "broadcast", "802.3ad", "balance-tlb", "balance-alb" ]
|
type: str
|
||||||
|
choices: [ 802.3ad, active-backup, balance-alb, balance-rr, balance-tlb, balance-xor, broadcast ]
|
||||||
default: balance-rr
|
default: balance-rr
|
||||||
master:
|
master:
|
||||||
description:
|
description:
|
||||||
- master <master (ifname, or connection UUID or conn_name) of bridge, team, bond master connection profile.
|
- Master <master (ifname, or connection UUID or conn_name) of bridge, team, bond master connection profile.
|
||||||
|
type: str
|
||||||
ip4:
|
ip4:
|
||||||
description:
|
description:
|
||||||
- 'The IPv4 address to this interface using this format ie: "192.0.2.24/24"'
|
- The IPv4 address to this interface.
|
||||||
|
- Use the format C(192.0.2.24/24).
|
||||||
|
type: str
|
||||||
gw4:
|
gw4:
|
||||||
description:
|
description:
|
||||||
- 'The IPv4 gateway for this interface using this format ie: "192.0.2.1"'
|
- The IPv4 gateway for this interface.
|
||||||
|
- Use the format C(192.0.2.1).
|
||||||
|
type: str
|
||||||
dns4:
|
dns4:
|
||||||
description:
|
description:
|
||||||
- 'A list of upto 3 dns servers, ipv4 format e.g. To add two IPv4 DNS server addresses: "192.0.2.53 198.51.100.53"'
|
- A list of up to 3 dns servers.
|
||||||
|
- IPv4 format e.g. to add two IPv4 DNS server addresses, use C(192.0.2.53 198.51.100.53).
|
||||||
|
type: list
|
||||||
dns4_search:
|
dns4_search:
|
||||||
description:
|
description:
|
||||||
- 'A list of DNS search domains.'
|
- A list of DNS search domains.
|
||||||
version_added: 2.5
|
type: list
|
||||||
|
version_added: '2.5'
|
||||||
ip6:
|
ip6:
|
||||||
description:
|
description:
|
||||||
- 'The IPv6 address to this interface using this format ie: "abbe::cafe"'
|
- The IPv6 address to this interface.
|
||||||
|
- Use the format C(abbe::cafe).
|
||||||
|
type: str
|
||||||
gw6:
|
gw6:
|
||||||
description:
|
description:
|
||||||
- 'The IPv6 gateway for this interface using this format ie: "2001:db8::1"'
|
- The IPv6 gateway for this interface.
|
||||||
|
- Use the format C(2001:db8::1).
|
||||||
|
type: str
|
||||||
dns6:
|
dns6:
|
||||||
description:
|
description:
|
||||||
- 'A list of upto 3 dns servers, ipv6 format e.g. To add two IPv6 DNS server addresses: "2001:4860:4860::8888 2001:4860:4860::8844"'
|
- A list of up to 3 dns servers.
|
||||||
|
- IPv6 format e.g. to add two IPv6 DNS server addresses, use C(2001:4860:4860::8888 2001:4860:4860::8844).
|
||||||
|
type: list
|
||||||
dns6_search:
|
dns6_search:
|
||||||
description:
|
description:
|
||||||
- 'A list of DNS search domains.'
|
- A list of DNS search domains.
|
||||||
version_added: 2.5
|
type: list
|
||||||
|
version_added: '2.5'
|
||||||
mtu:
|
mtu:
|
||||||
description:
|
description:
|
||||||
- The connection MTU, e.g. 9000. This can't be applied when creating the interface and is done once the interface has been created.
|
- The connection MTU, e.g. 9000. This can't be applied when creating the interface and is done once the interface has been created.
|
||||||
- Can be used when modifying Team, VLAN, Ethernet (Future plans to implement wifi, pppoe, infiniband)
|
- Can be used when modifying Team, VLAN, Ethernet (Future plans to implement wifi, pppoe, infiniband)
|
||||||
default: 1500
|
- This parameter defaults to C(1500) when unset.
|
||||||
|
type: int
|
||||||
dhcp_client_id:
|
dhcp_client_id:
|
||||||
description:
|
description:
|
||||||
- DHCP Client Identifier sent to the DHCP server.
|
- DHCP Client Identifier sent to the DHCP server.
|
||||||
|
type: str
|
||||||
version_added: "2.5"
|
version_added: "2.5"
|
||||||
primary:
|
primary:
|
||||||
description:
|
description:
|
||||||
- This is only used with bond and is the primary interface name (for "active-backup" mode), this is the usually the 'ifname'
|
- This is only used with bond and is the primary interface name (for "active-backup" mode), this is the usually the 'ifname'.
|
||||||
|
type: str
|
||||||
miimon:
|
miimon:
|
||||||
description:
|
description:
|
||||||
- This is only used with bond - miimon
|
- This is only used with bond - miimon.
|
||||||
default: 100
|
- This parameter defaults to C(100) when unset.
|
||||||
|
type: int
|
||||||
downdelay:
|
downdelay:
|
||||||
description:
|
description:
|
||||||
- This is only used with bond - downdelay
|
- This is only used with bond - downdelay.
|
||||||
|
type: int
|
||||||
updelay:
|
updelay:
|
||||||
description:
|
description:
|
||||||
- This is only used with bond - updelay
|
- This is only used with bond - updelay.
|
||||||
|
type: int
|
||||||
arp_interval:
|
arp_interval:
|
||||||
description:
|
description:
|
||||||
- This is only used with bond - ARP interval
|
- This is only used with bond - ARP interval.
|
||||||
|
type: int
|
||||||
arp_ip_target:
|
arp_ip_target:
|
||||||
description:
|
description:
|
||||||
- This is only used with bond - ARP IP target
|
- This is only used with bond - ARP IP target.
|
||||||
|
type: str
|
||||||
stp:
|
stp:
|
||||||
description:
|
description:
|
||||||
- This is only used with bridge and controls whether Spanning Tree Protocol (STP) is enabled for this bridge
|
- This is only used with bridge and controls whether Spanning Tree Protocol (STP) is enabled for this bridge.
|
||||||
type: bool
|
type: bool
|
||||||
|
default: yes
|
||||||
priority:
|
priority:
|
||||||
description:
|
description:
|
||||||
- This is only used with 'bridge' - sets STP priority
|
- This is only used with 'bridge' - sets STP priority.
|
||||||
|
type: int
|
||||||
default: 128
|
default: 128
|
||||||
forwarddelay:
|
forwarddelay:
|
||||||
description:
|
description:
|
||||||
- This is only used with bridge - [forward-delay <2-30>] STP forwarding delay, in seconds
|
- This is only used with bridge - [forward-delay <2-30>] STP forwarding delay, in seconds.
|
||||||
|
type: int
|
||||||
default: 15
|
default: 15
|
||||||
hellotime:
|
hellotime:
|
||||||
description:
|
description:
|
||||||
- This is only used with bridge - [hello-time <1-10>] STP hello time, in seconds
|
- This is only used with bridge - [hello-time <1-10>] STP hello time, in seconds.
|
||||||
|
type: int
|
||||||
default: 2
|
default: 2
|
||||||
maxage:
|
maxage:
|
||||||
description:
|
description:
|
||||||
- This is only used with bridge - [max-age <6-42>] STP maximum message age, in seconds
|
- This is only used with bridge - [max-age <6-42>] STP maximum message age, in seconds.
|
||||||
|
type: int
|
||||||
default: 20
|
default: 20
|
||||||
ageingtime:
|
ageingtime:
|
||||||
description:
|
description:
|
||||||
- This is only used with bridge - [ageing-time <0-1000000>] the Ethernet MAC address aging time, in seconds
|
- This is only used with bridge - [ageing-time <0-1000000>] the Ethernet MAC address aging time, in seconds.
|
||||||
|
type: int
|
||||||
default: 300
|
default: 300
|
||||||
mac:
|
mac:
|
||||||
description:
|
description:
|
||||||
- >
|
- This is only used with bridge - MAC address of the bridge.
|
||||||
This is only used with bridge - MAC address of the bridge
|
- Note this requires a recent kernel feature, originally introduced in 3.15 upstream kernel.
|
||||||
(note: this requires a recent kernel feature, originally introduced in 3.15 upstream kernel)
|
|
||||||
slavepriority:
|
slavepriority:
|
||||||
description:
|
description:
|
||||||
- This is only used with 'bridge-slave' - [<0-63>] - STP priority of this slave
|
- This is only used with 'bridge-slave' - [<0-63>] - STP priority of this slave.
|
||||||
|
type: int
|
||||||
default: 32
|
default: 32
|
||||||
path_cost:
|
path_cost:
|
||||||
description:
|
description:
|
||||||
- This is only used with 'bridge-slave' - [<1-65535>] - STP port cost for destinations via this slave
|
- This is only used with 'bridge-slave' - [<1-65535>] - STP port cost for destinations via this slave.
|
||||||
|
type: int
|
||||||
default: 100
|
default: 100
|
||||||
hairpin:
|
hairpin:
|
||||||
description:
|
description:
|
||||||
- This is only used with 'bridge-slave' - 'hairpin mode' for the slave, which allows frames to be sent back out through the slave the
|
- This is only used with 'bridge-slave' - 'hairpin mode' for the slave, which allows frames to be sent back out through the slave the
|
||||||
frame was received on.
|
frame was received on.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'yes'
|
default: yes
|
||||||
vlanid:
|
vlanid:
|
||||||
description:
|
description:
|
||||||
- This is only used with VLAN - VLAN ID in range <0-4095>
|
- This is only used with VLAN - VLAN ID in range <0-4095>.
|
||||||
|
type: int
|
||||||
vlandev:
|
vlandev:
|
||||||
description:
|
description:
|
||||||
- This is only used with VLAN - parent device this VLAN is on, can use ifname
|
- This is only used with VLAN - parent device this VLAN is on, can use ifname.
|
||||||
|
type: str
|
||||||
flags:
|
flags:
|
||||||
description:
|
description:
|
||||||
- This is only used with VLAN - flags
|
- This is only used with VLAN - flags.
|
||||||
|
type: str
|
||||||
ingress:
|
ingress:
|
||||||
description:
|
description:
|
||||||
- This is only used with VLAN - VLAN ingress priority mapping
|
- This is only used with VLAN - VLAN ingress priority mapping.
|
||||||
|
type: str
|
||||||
egress:
|
egress:
|
||||||
description:
|
description:
|
||||||
- This is only used with VLAN - VLAN egress priority mapping
|
- This is only used with VLAN - VLAN egress priority mapping.
|
||||||
|
type: str
|
||||||
vxlan_id:
|
vxlan_id:
|
||||||
description:
|
description:
|
||||||
- This is only used with VXLAN - VXLAN ID.
|
- This is only used with VXLAN - VXLAN ID.
|
||||||
|
type: int
|
||||||
version_added: "2.8"
|
version_added: "2.8"
|
||||||
vxlan_remote:
|
vxlan_remote:
|
||||||
description:
|
description:
|
||||||
- This is only used with VXLAN - VXLAN destination IP address.
|
- This is only used with VXLAN - VXLAN destination IP address.
|
||||||
|
type: str
|
||||||
version_added: "2.8"
|
version_added: "2.8"
|
||||||
vxlan_local:
|
vxlan_local:
|
||||||
description:
|
description:
|
||||||
- This is only used with VXLAN - VXLAN local IP address.
|
- This is only used with VXLAN - VXLAN local IP address.
|
||||||
|
type: str
|
||||||
version_added: "2.8"
|
version_added: "2.8"
|
||||||
ip_tunnel_dev:
|
ip_tunnel_dev:
|
||||||
description:
|
description:
|
||||||
- This is used with IPIP/SIT - parent device this IPIP/SIT tunnel, can use ifname.
|
- This is used with IPIP/SIT - parent device this IPIP/SIT tunnel, can use ifname.
|
||||||
|
type: str
|
||||||
version_added: "2.8"
|
version_added: "2.8"
|
||||||
ip_tunnel_remote:
|
ip_tunnel_remote:
|
||||||
description:
|
description:
|
||||||
- This is used with IPIP/SIT - IPIP/SIT destination IP address.
|
- This is used with IPIP/SIT - IPIP/SIT destination IP address.
|
||||||
|
type: str
|
||||||
version_added: "2.8"
|
version_added: "2.8"
|
||||||
ip_tunnel_local:
|
ip_tunnel_local:
|
||||||
description:
|
description:
|
||||||
- This is used with IPIP/SIT - IPIP/SIT local IP address.
|
- This is used with IPIP/SIT - IPIP/SIT local IP address.
|
||||||
|
type: str
|
||||||
version_added: "2.8"
|
version_added: "2.8"
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = r'''
|
||||||
# These examples are using the following inventory:
|
# These examples are using the following inventory:
|
||||||
#
|
#
|
||||||
# ## Directory layout:
|
# ## Directory layout:
|
||||||
|
@ -325,7 +374,7 @@ EXAMPLES = '''
|
||||||
state: installed
|
state: installed
|
||||||
|
|
||||||
##### Working with all cloud nodes - Teaming
|
##### Working with all cloud nodes - Teaming
|
||||||
- name: try nmcli add team - conn_name only & ip4 gw4
|
- name: Try nmcli add team - conn_name only & ip4 gw4
|
||||||
nmcli:
|
nmcli:
|
||||||
type: team
|
type: team
|
||||||
conn_name: '{{ item.conn_name }}'
|
conn_name: '{{ item.conn_name }}'
|
||||||
|
@ -335,7 +384,7 @@ EXAMPLES = '''
|
||||||
with_items:
|
with_items:
|
||||||
- '{{ nmcli_team }}'
|
- '{{ nmcli_team }}'
|
||||||
|
|
||||||
- name: try nmcli add teams-slave
|
- name: Try nmcli add teams-slave
|
||||||
nmcli:
|
nmcli:
|
||||||
type: team-slave
|
type: team-slave
|
||||||
conn_name: '{{ item.conn_name }}'
|
conn_name: '{{ item.conn_name }}'
|
||||||
|
@ -346,7 +395,7 @@ EXAMPLES = '''
|
||||||
- '{{ nmcli_team_slave }}'
|
- '{{ nmcli_team_slave }}'
|
||||||
|
|
||||||
###### Working with all cloud nodes - Bonding
|
###### Working with all cloud nodes - Bonding
|
||||||
- name: try nmcli add bond - conn_name only & ip4 gw4 mode
|
- name: Try nmcli add bond - conn_name only & ip4 gw4 mode
|
||||||
nmcli:
|
nmcli:
|
||||||
type: bond
|
type: bond
|
||||||
conn_name: '{{ item.conn_name }}'
|
conn_name: '{{ item.conn_name }}'
|
||||||
|
@ -357,7 +406,7 @@ EXAMPLES = '''
|
||||||
with_items:
|
with_items:
|
||||||
- '{{ nmcli_bond }}'
|
- '{{ nmcli_bond }}'
|
||||||
|
|
||||||
- name: try nmcli add bond-slave
|
- name: Try nmcli add bond-slave
|
||||||
nmcli:
|
nmcli:
|
||||||
type: bond-slave
|
type: bond-slave
|
||||||
conn_name: '{{ item.conn_name }}'
|
conn_name: '{{ item.conn_name }}'
|
||||||
|
@ -368,7 +417,7 @@ EXAMPLES = '''
|
||||||
- '{{ nmcli_bond_slave }}'
|
- '{{ nmcli_bond_slave }}'
|
||||||
|
|
||||||
##### Working with all cloud nodes - Ethernet
|
##### Working with all cloud nodes - Ethernet
|
||||||
- name: nmcli add Ethernet - conn_name only & ip4 gw4
|
- name: Try nmcli add Ethernet - conn_name only & ip4 gw4
|
||||||
nmcli:
|
nmcli:
|
||||||
type: ethernet
|
type: ethernet
|
||||||
conn_name: '{{ item.conn_name }}'
|
conn_name: '{{ item.conn_name }}'
|
||||||
|
@ -383,7 +432,7 @@ EXAMPLES = '''
|
||||||
remote_user: root
|
remote_user: root
|
||||||
tasks:
|
tasks:
|
||||||
|
|
||||||
- name: try nmcli del team - multiple
|
- name: Try nmcli del team - multiple
|
||||||
nmcli:
|
nmcli:
|
||||||
conn_name: '{{ item.conn_name }}'
|
conn_name: '{{ item.conn_name }}'
|
||||||
state: absent
|
state: absent
|
||||||
|
@ -404,8 +453,8 @@ EXAMPLES = '''
|
||||||
- conn_name: team-p2p1
|
- conn_name: team-p2p1
|
||||||
- conn_name: team-p2p2
|
- conn_name: team-p2p2
|
||||||
|
|
||||||
# To add an Ethernet connection with static IP configuration, issue a command as follows
|
- name: Add an Ethernet connection with static IP configuration
|
||||||
- nmcli:
|
nmcli:
|
||||||
conn_name: my-eth1
|
conn_name: my-eth1
|
||||||
ifname: eth1
|
ifname: eth1
|
||||||
type: ethernet
|
type: ethernet
|
||||||
|
@ -413,8 +462,8 @@ EXAMPLES = '''
|
||||||
gw4: 192.0.2.1
|
gw4: 192.0.2.1
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
# To add an Team connection with static IP configuration, issue a command as follows
|
- name: Add an Team connection with static IP configuration
|
||||||
- nmcli:
|
nmcli:
|
||||||
conn_name: my-team1
|
conn_name: my-team1
|
||||||
ifname: my-team1
|
ifname: my-team1
|
||||||
type: team
|
type: team
|
||||||
|
@ -423,19 +472,19 @@ EXAMPLES = '''
|
||||||
state: present
|
state: present
|
||||||
autoconnect: yes
|
autoconnect: yes
|
||||||
|
|
||||||
# Optionally, at the same time specify IPv6 addresses for the device as follows:
|
- name: Optionally, at the same time specify IPv6 addresses for the device
|
||||||
- nmcli:
|
nmcli:
|
||||||
conn_name: my-eth1
|
conn_name: my-eth1
|
||||||
ifname: eth1
|
ifname: eth1
|
||||||
type: ethernet
|
type: ethernet
|
||||||
ip4: 192.0.2.100/24
|
ip4: 192.0.2.100/24
|
||||||
gw4: 192.0.2.1
|
gw4: 192.0.2.1
|
||||||
ip6: '2001:db8::cafe'
|
ip6: 2001:db8::cafe
|
||||||
gw6: '2001:db8::1'
|
gw6: 2001:db8::1
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
# To add two IPv4 DNS server addresses:
|
- name: Add two IPv4 DNS server addresses
|
||||||
- nmcli:
|
nmcli:
|
||||||
conn_name: my-eth1
|
conn_name: my-eth1
|
||||||
type: ethernet
|
type: ethernet
|
||||||
dns4:
|
dns4:
|
||||||
|
@ -443,38 +492,38 @@ EXAMPLES = '''
|
||||||
- 198.51.100.53
|
- 198.51.100.53
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
# To make a profile usable for all compatible Ethernet interfaces, issue a command as follows
|
- name: Make a profile usable for all compatible Ethernet interfaces
|
||||||
- nmcli:
|
nmcli:
|
||||||
ctype: ethernet
|
ctype: ethernet
|
||||||
name: my-eth1
|
name: my-eth1
|
||||||
ifname: '*'
|
ifname: '*'
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
# To change the property of a setting e.g. MTU, issue a command as follows:
|
- name: Change the property of a setting e.g. MTU
|
||||||
- nmcli:
|
nmcli:
|
||||||
conn_name: my-eth1
|
conn_name: my-eth1
|
||||||
mtu: 9000
|
mtu: 9000
|
||||||
type: ethernet
|
type: ethernet
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
# To add VxLan, issue a command as follows:
|
- name: Add VxLan
|
||||||
- nmcli:
|
nmcli:
|
||||||
type: vxlan
|
type: vxlan
|
||||||
conn_name: vxlan_test1
|
conn_name: vxlan_test1
|
||||||
vxlan_id: 16
|
vxlan_id: 16
|
||||||
vxlan_local: 192.168.1.2
|
vxlan_local: 192.168.1.2
|
||||||
vxlan_remote: 192.168.1.5
|
vxlan_remote: 192.168.1.5
|
||||||
|
|
||||||
# To add ipip, issue a command as follows:
|
- name: Add ipip
|
||||||
- nmcli:
|
nmcli:
|
||||||
type: ipip
|
type: ipip
|
||||||
conn_name: ipip_test1
|
conn_name: ipip_test1
|
||||||
ip_tunnel_dev: eth0
|
ip_tunnel_dev: eth0
|
||||||
ip_tunnel_local: 192.168.1.2
|
ip_tunnel_local: 192.168.1.2
|
||||||
ip_tunnel_remote: 192.168.1.5
|
ip_tunnel_remote: 192.168.1.5
|
||||||
|
|
||||||
# To add sit, issue a command as follows:
|
- name: Add sit
|
||||||
- nmcli:
|
nmcli:
|
||||||
type: sit
|
type: sit
|
||||||
conn_name: sit_test1
|
conn_name: sit_test1
|
||||||
ip_tunnel_dev: eth0
|
ip_tunnel_dev: eth0
|
||||||
|
@ -593,7 +642,7 @@ class Nmcli(object):
|
||||||
self.dns4_search = ' '.join(module.params['dns4_search']) if module.params.get('dns4_search') else None
|
self.dns4_search = ' '.join(module.params['dns4_search']) if module.params.get('dns4_search') else None
|
||||||
self.ip6 = module.params['ip6']
|
self.ip6 = module.params['ip6']
|
||||||
self.gw6 = module.params['gw6']
|
self.gw6 = module.params['gw6']
|
||||||
self.dns6 = module.params['dns6']
|
self.dns6 = ' '.join(module.params['dns6']) if module.params.get('dns6') else None
|
||||||
self.dns6_search = ' '.join(module.params['dns6_search']) if module.params.get('dns6_search') else None
|
self.dns6_search = ' '.join(module.params['dns6_search']) if module.params.get('dns6_search') else None
|
||||||
self.mtu = module.params['mtu']
|
self.mtu = module.params['mtu']
|
||||||
self.stp = module.params['stp']
|
self.stp = module.params['stp']
|
||||||
|
@ -1381,63 +1430,60 @@ def main():
|
||||||
# Parsing argument file
|
# Parsing argument file
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
autoconnect=dict(required=False, default=True, type='bool'),
|
autoconnect=dict(type='bool', default=True),
|
||||||
state=dict(required=True, choices=['present', 'absent'], type='str'),
|
state=dict(type='str', required=True, choices=['absent', 'present']),
|
||||||
conn_name=dict(required=True, type='str'),
|
conn_name=dict(type='str', required=True),
|
||||||
master=dict(required=False, default=None, type='str'),
|
master=dict(type='str'),
|
||||||
ifname=dict(required=False, default=None, type='str'),
|
ifname=dict(type='str'),
|
||||||
type=dict(required=False, default=None,
|
type=dict(type='str',
|
||||||
choices=['ethernet', 'team', 'team-slave', 'bond',
|
choices=['bond', 'bond-slave', 'bridge', 'bridge-slave', 'ethernet', 'generic', 'ipip', 'sit', 'team', 'team-slave', 'vlan', 'vxlan']),
|
||||||
'bond-slave', 'bridge', 'bridge-slave',
|
ip4=dict(type='str'),
|
||||||
'vlan', 'vxlan', 'ipip', 'sit', 'generic'],
|
gw4=dict(type='str'),
|
||||||
type='str'),
|
dns4=dict(type='list'),
|
||||||
ip4=dict(required=False, default=None, type='str'),
|
|
||||||
gw4=dict(required=False, default=None, type='str'),
|
|
||||||
dns4=dict(required=False, default=None, type='list'),
|
|
||||||
dns4_search=dict(type='list'),
|
dns4_search=dict(type='list'),
|
||||||
dhcp_client_id=dict(required=False, default=None, type='str'),
|
dhcp_client_id=dict(type='str'),
|
||||||
ip6=dict(required=False, default=None, type='str'),
|
ip6=dict(type='str'),
|
||||||
gw6=dict(required=False, default=None, type='str'),
|
gw6=dict(type='str'),
|
||||||
dns6=dict(required=False, default=None, type='str'),
|
dns6=dict(type='list'),
|
||||||
dns6_search=dict(type='list'),
|
dns6_search=dict(type='list'),
|
||||||
# Bond Specific vars
|
# Bond Specific vars
|
||||||
mode=dict(require=False, default="balance-rr", type='str', choices=["balance-rr", "active-backup", "balance-xor", "broadcast", "802.3ad",
|
mode=dict(type='str', default='balance-rr',
|
||||||
"balance-tlb", "balance-alb"]),
|
choices=['802.3ad', 'active-backup', 'balance-alb', 'balance-rr', 'balance-tlb', 'balance-xor', 'broadcast']),
|
||||||
miimon=dict(required=False, default=None, type='str'),
|
miimon=dict(type='int'),
|
||||||
downdelay=dict(required=False, default=None, type='str'),
|
downdelay=dict(type='int'),
|
||||||
updelay=dict(required=False, default=None, type='str'),
|
updelay=dict(type='int'),
|
||||||
arp_interval=dict(required=False, default=None, type='str'),
|
arp_interval=dict(type='int'),
|
||||||
arp_ip_target=dict(required=False, default=None, type='str'),
|
arp_ip_target=dict(type='str'),
|
||||||
primary=dict(required=False, default=None, type='str'),
|
primary=dict(type='str'),
|
||||||
# general usage
|
# general usage
|
||||||
mtu=dict(required=False, default=None, type='str'),
|
mtu=dict(type='int'),
|
||||||
mac=dict(required=False, default=None, type='str'),
|
mac=dict(type='str'),
|
||||||
# bridge specific vars
|
# bridge specific vars
|
||||||
stp=dict(required=False, default=True, type='bool'),
|
stp=dict(type='bool', default=True),
|
||||||
priority=dict(required=False, default="128", type='str'),
|
priority=dict(type='int', default=128),
|
||||||
slavepriority=dict(required=False, default="32", type='str'),
|
slavepriority=dict(type='int', default=32),
|
||||||
forwarddelay=dict(required=False, default="15", type='str'),
|
forwarddelay=dict(type='int', default=15),
|
||||||
hellotime=dict(required=False, default="2", type='str'),
|
hellotime=dict(type='int', default=2),
|
||||||
maxage=dict(required=False, default="20", type='str'),
|
maxage=dict(type='int', default=20),
|
||||||
ageingtime=dict(required=False, default="300", type='str'),
|
ageingtime=dict(type='int', default=300),
|
||||||
hairpin=dict(required=False, default=True, type='bool'),
|
hairpin=dict(type='bool', default=True),
|
||||||
path_cost=dict(required=False, default="100", type='str'),
|
path_cost=dict(type='int', default=100),
|
||||||
# vlan specific vars
|
# vlan specific vars
|
||||||
vlanid=dict(required=False, default=None, type='str'),
|
vlanid=dict(type='int'),
|
||||||
vlandev=dict(required=False, default=None, type='str'),
|
vlandev=dict(type='str'),
|
||||||
flags=dict(required=False, default=None, type='str'),
|
flags=dict(type='str'),
|
||||||
ingress=dict(required=False, default=None, type='str'),
|
ingress=dict(type='str'),
|
||||||
egress=dict(required=False, default=None, type='str'),
|
egress=dict(type='str'),
|
||||||
# vxlan specific vars
|
# vxlan specific vars
|
||||||
vxlan_id=dict(required=False, default=None, type='str'),
|
vxlan_id=dict(type='int'),
|
||||||
vxlan_local=dict(required=False, default=None, type='str'),
|
vxlan_local=dict(type='str'),
|
||||||
vxlan_remote=dict(required=False, default=None, type='str'),
|
vxlan_remote=dict(type='str'),
|
||||||
# ip-tunnel specific vars
|
# ip-tunnel specific vars
|
||||||
ip_tunnel_dev=dict(required=False, default=None, type='str'),
|
ip_tunnel_dev=dict(type='str'),
|
||||||
ip_tunnel_local=dict(required=False, default=None, type='str'),
|
ip_tunnel_local=dict(type='str'),
|
||||||
ip_tunnel_remote=dict(required=False, default=None, type='str'),
|
ip_tunnel_remote=dict(type='str'),
|
||||||
),
|
),
|
||||||
supports_check_mode=True
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
if not HAVE_DBUS:
|
if not HAVE_DBUS:
|
||||||
|
|
|
@ -450,7 +450,6 @@ lib/ansible/modules/net_tools/haproxy.py E324
|
||||||
lib/ansible/modules/net_tools/infinity/infinity.py E326
|
lib/ansible/modules/net_tools/infinity/infinity.py E326
|
||||||
lib/ansible/modules/net_tools/ipify_facts.py E324
|
lib/ansible/modules/net_tools/ipify_facts.py E324
|
||||||
lib/ansible/modules/net_tools/ldap/ldap_attr.py E322
|
lib/ansible/modules/net_tools/ldap/ldap_attr.py E322
|
||||||
lib/ansible/modules/net_tools/nmcli.py E324
|
|
||||||
lib/ansible/modules/net_tools/omapi_host.py E317
|
lib/ansible/modules/net_tools/omapi_host.py E317
|
||||||
lib/ansible/modules/net_tools/omapi_host.py E322
|
lib/ansible/modules/net_tools/omapi_host.py E322
|
||||||
lib/ansible/modules/net_tools/snmp_facts.py E322
|
lib/ansible/modules/net_tools/snmp_facts.py E322
|
||||||
|
|
|
@ -119,7 +119,7 @@ TESTCASE_BRIDGE = [
|
||||||
'ifname': 'br0_non_existant',
|
'ifname': 'br0_non_existant',
|
||||||
'ip4': '10.10.10.10',
|
'ip4': '10.10.10.10',
|
||||||
'gw4': '10.10.10.1',
|
'gw4': '10.10.10.1',
|
||||||
'maxage': '100',
|
'maxage': 100,
|
||||||
'stp': True,
|
'stp': True,
|
||||||
'state': 'present',
|
'state': 'present',
|
||||||
'_ansible_check_mode': False,
|
'_ansible_check_mode': False,
|
||||||
|
@ -154,7 +154,7 @@ TESTCASE_VXLAN = [
|
||||||
'type': 'vxlan',
|
'type': 'vxlan',
|
||||||
'conn_name': 'non_existent_nw_device',
|
'conn_name': 'non_existent_nw_device',
|
||||||
'ifname': 'vxlan-existent_nw_device',
|
'ifname': 'vxlan-existent_nw_device',
|
||||||
'vxlan_id': '11',
|
'vxlan_id': 11,
|
||||||
'vxlan_local': '192.168.225.5',
|
'vxlan_local': '192.168.225.5',
|
||||||
'vxlan_remote': '192.168.225.6',
|
'vxlan_remote': '192.168.225.6',
|
||||||
'state': 'present',
|
'state': 'present',
|
||||||
|
@ -373,7 +373,7 @@ def test_create_bridge(mocked_generic_connection_create):
|
||||||
assert args[0][5] == 'con-name'
|
assert args[0][5] == 'con-name'
|
||||||
assert args[0][6] == 'non_existent_nw_device'
|
assert args[0][6] == 'non_existent_nw_device'
|
||||||
|
|
||||||
for param in ['ip4', '10.10.10.10', 'gw4', '10.10.10.1', 'bridge.max-age', '100', 'bridge.stp', 'yes']:
|
for param in ['ip4', '10.10.10.10', 'gw4', '10.10.10.1', 'bridge.max-age', 100, 'bridge.stp', 'yes']:
|
||||||
assert param in args[0]
|
assert param in args[0]
|
||||||
|
|
||||||
|
|
||||||
|
@ -394,7 +394,7 @@ def test_mod_bridge(mocked_generic_connection_modify):
|
||||||
assert args[0][1] == 'con'
|
assert args[0][1] == 'con'
|
||||||
assert args[0][2] == 'mod'
|
assert args[0][2] == 'mod'
|
||||||
assert args[0][3] == 'non_existent_nw_device'
|
assert args[0][3] == 'non_existent_nw_device'
|
||||||
for param in ['ip4', '10.10.10.10', 'gw4', '10.10.10.1', 'bridge.max-age', '100', 'bridge.stp', 'yes']:
|
for param in ['ip4', '10.10.10.10', 'gw4', '10.10.10.1', 'bridge.max-age', 100, 'bridge.stp', 'yes']:
|
||||||
assert param in args[0]
|
assert param in args[0]
|
||||||
|
|
||||||
|
|
||||||
|
@ -419,7 +419,7 @@ def test_create_bridge_slave(mocked_generic_connection_create):
|
||||||
assert args[0][5] == 'con-name'
|
assert args[0][5] == 'con-name'
|
||||||
assert args[0][6] == 'non_existent_nw_device'
|
assert args[0][6] == 'non_existent_nw_device'
|
||||||
|
|
||||||
for param in ['bridge-port.path-cost', '100']:
|
for param in ['bridge-port.path-cost', 100]:
|
||||||
assert param in args[0]
|
assert param in args[0]
|
||||||
|
|
||||||
|
|
||||||
|
@ -441,7 +441,7 @@ def test_mod_bridge_slave(mocked_generic_connection_modify):
|
||||||
assert args[0][2] == 'mod'
|
assert args[0][2] == 'mod'
|
||||||
assert args[0][3] == 'non_existent_nw_device'
|
assert args[0][3] == 'non_existent_nw_device'
|
||||||
|
|
||||||
for param in ['bridge-port.path-cost', '100']:
|
for param in ['bridge-port.path-cost', 100]:
|
||||||
assert param in args[0]
|
assert param in args[0]
|
||||||
|
|
||||||
|
|
||||||
|
@ -513,7 +513,7 @@ def test_create_vxlan(mocked_generic_connection_create):
|
||||||
assert args[0][6] == 'non_existent_nw_device'
|
assert args[0][6] == 'non_existent_nw_device'
|
||||||
assert args[0][7] == 'ifname'
|
assert args[0][7] == 'ifname'
|
||||||
|
|
||||||
for param in ['vxlan.local', '192.168.225.5', 'vxlan.remote', '192.168.225.6', 'vxlan.id', '11']:
|
for param in ['vxlan.local', '192.168.225.5', 'vxlan.remote', '192.168.225.6', 'vxlan.id', 11]:
|
||||||
assert param in args[0]
|
assert param in args[0]
|
||||||
|
|
||||||
|
|
||||||
|
@ -534,7 +534,7 @@ def test_vxlan_mod(mocked_generic_connection_modify):
|
||||||
assert args[0][2] == 'mod'
|
assert args[0][2] == 'mod'
|
||||||
assert args[0][3] == 'non_existent_nw_device'
|
assert args[0][3] == 'non_existent_nw_device'
|
||||||
|
|
||||||
for param in ['vxlan.local', '192.168.225.5', 'vxlan.remote', '192.168.225.6', 'vxlan.id', '11']:
|
for param in ['vxlan.local', '192.168.225.5', 'vxlan.remote', '192.168.225.6', 'vxlan.id', 11]:
|
||||||
assert param in args[0]
|
assert param in args[0]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue