Fixed descriptions to all be lists

replaced enabled with autoconnect - refactored code to reflect update.
removed ansible syslog entry.
reviewable/pr18780/r1
Chris Long 9 years ago committed by Greg DeKoenigsberg
parent 2856116162
commit 389c40033b

@ -31,25 +31,24 @@ options:
state: state:
required: True required: True
choices: [ present, absent ] choices: [ present, absent ]
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.
enabled: autoconnect:
required: False required: False
default: "yes" default: "yes"
choices: [ "yes", "no" ] choices: [ "yes", "no" ]
description: description:
- Whether the service should start on boot. B(At least one of state and enabled are required.) - Whether the connection should start on boot.
- Whether the connection profile can be automatically activated ( default: yes) - Whether the connection profile can be automatically activated ( default: yes)
conn_name: conn_name:
required: True required: True
default: None
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>]
ifname: ifname:
required: False required: False
default: conn_name default: conn_name
description: description:
- Where INAME will be the what we call the interface name. Required with 'up', 'down' modifiers. - Where IFNAME will be the what we call the interface name.
- interface to bind the connection to. The connection will only be applicable to this interface name. - interface to bind the connection to. 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 "*" 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.
@ -72,14 +71,17 @@ options:
ip4: ip4:
required: False required: False
default: None default: None
description: The IPv4 address to this interface using this format ie: "192.168.1.24/24" description:
- The IPv4 address to this interface using this format ie: "192.168.1.24/24"
gw4: gw4:
required: False required: False
description: The IPv4 gateway for this interface using this format ie: "192.168.100.1" description:
- The IPv4 gateway for this interface using this format ie: "192.168.100.1"
dns4: dns4:
required: False required: False
default: None default: None
description: A list of upto 3 dns servers, ipv4 format e.g. To add two IPv4 DNS server addresses: ['"8.8.8.8 8.8.4.4"'] description:
- A list of upto 3 dns servers, ipv4 format e.g. To add two IPv4 DNS server addresses: ['"8.8.8.8 8.8.4.4"']
ip6: ip6:
required: False required: False
default: None default: None
@ -88,10 +90,12 @@ options:
gw6: gw6:
required: False required: False
default: None default: None
description: The IPv6 gateway for this interface using this format ie: "2001:db8::1" description:
- The IPv6 gateway for this interface using this format ie: "2001:db8::1"
dns6: dns6:
required: False required: False
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"'] 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"']
mtu: mtu:
required: False required: False
default: None default: None
@ -343,7 +347,7 @@ tenant_ip: "192.168.200.21/23"
- nmcli: conn_name=my-eth1 ifname=eth1 type=ethernet ip4=192.168.100.100/24 gw4=192.168.100.1 state=present - nmcli: conn_name=my-eth1 ifname=eth1 type=ethernet ip4=192.168.100.100/24 gw4=192.168.100.1 state=present
# To add an Team connection with static IP configuration, issue a command as follows # To add an Team connection with static IP configuration, issue a command as follows
- nmcli: conn_name=my-team1 ifname=my-team1 type=team ip4=192.168.100.100/24 gw4=192.168.100.1 state=present enabled=yes - nmcli: conn_name=my-team1 ifname=my-team1 type=team ip4=192.168.100.100/24 gw4=192.168.100.1 state=present autoconnect=yes
# Optionally, at the same time specify IPv6 addresses for the device as follows: # Optionally, at the same time specify IPv6 addresses for the device as follows:
- nmcli: conn_name=my-eth1 ifname=eth1 type=ethernet ip4=192.168.100.100/24 gw4=192.168.100.1 ip6=abbe::cafe gw6=2001:db8::1 state=present - nmcli: conn_name=my-eth1 ifname=eth1 type=ethernet ip4=192.168.100.100/24 gw4=192.168.100.1 ip6=abbe::cafe gw6=2001:db8::1 state=present
@ -430,10 +434,9 @@ class Nmcli(object):
def __init__(self, module): def __init__(self, module):
self.module=module self.module=module
self.state=module.params['state'] self.state=module.params['state']
self.enabled=module.params['enabled'] self.autoconnect=module.params['autoconnect']
self.conn_name=module.params['conn_name'] self.conn_name=module.params['conn_name']
self.master=module.params['master'] self.master=module.params['master']
self.autoconnect=module.params['autoconnect']
self.ifname=module.params['ifname'] self.ifname=module.params['ifname']
self.type=module.params['type'] self.type=module.params['type']
self.ip4=module.params['ip4'] self.ip4=module.params['ip4']
@ -602,9 +605,9 @@ class Nmcli(object):
if self.gw6 is not None: if self.gw6 is not None:
cmd.append('gw6') cmd.append('gw6')
cmd.append(self.gw6) cmd.append(self.gw6)
if self.enabled is not None: if self.autoconnect is not None:
cmd.append('autoconnect') cmd.append('autoconnect')
cmd.append(self.enabled) cmd.append(self.autoconnect)
return cmd return cmd
def modify_connection_team(self): def modify_connection_team(self):
@ -631,9 +634,9 @@ class Nmcli(object):
if self.dns6 is not None: if self.dns6 is not None:
cmd.append('ipv6.dns') cmd.append('ipv6.dns')
cmd.append(self.dns6) cmd.append(self.dns6)
if self.enabled is not None: if self.autoconnect is not None:
cmd.append('autoconnect') cmd.append('autoconnect')
cmd.append(self.enabled) cmd.append(self.autoconnect)
# Can't use MTU with team # Can't use MTU with team
return cmd return cmd
@ -704,9 +707,9 @@ class Nmcli(object):
if self.gw6 is not None: if self.gw6 is not None:
cmd.append('gw6') cmd.append('gw6')
cmd.append(self.gw6) cmd.append(self.gw6)
if self.enabled is not None: if self.autoconnect is not None:
cmd.append('autoconnect') cmd.append('autoconnect')
cmd.append(self.enabled) cmd.append(self.autoconnect)
if self.mode is not None: if self.mode is not None:
cmd.append('mode') cmd.append('mode')
cmd.append(self.mode) cmd.append(self.mode)
@ -751,9 +754,9 @@ class Nmcli(object):
if self.dns6 is not None: if self.dns6 is not None:
cmd.append('ipv6.dns') cmd.append('ipv6.dns')
cmd.append(self.dns6) cmd.append(self.dns6)
if self.enabled is not None: if self.autoconnect is not None:
cmd.append('autoconnect') cmd.append('autoconnect')
cmd.append(self.enabled) cmd.append(self.autoconnect)
return cmd return cmd
def create_connection_bond_slave(self): def create_connection_bond_slave(self):
@ -820,9 +823,9 @@ class Nmcli(object):
if self.gw6 is not None: if self.gw6 is not None:
cmd.append('gw6') cmd.append('gw6')
cmd.append(self.gw6) cmd.append(self.gw6)
if self.enabled is not None: if self.autoconnect is not None:
cmd.append('autoconnect') cmd.append('autoconnect')
cmd.append(self.enabled) cmd.append(self.autoconnect)
return cmd return cmd
def modify_connection_ethernet(self): def modify_connection_ethernet(self):
@ -855,9 +858,9 @@ class Nmcli(object):
if self.mtu is not None: if self.mtu is not None:
cmd.append('802-3-ethernet.mtu') cmd.append('802-3-ethernet.mtu')
cmd.append(self.mtu) cmd.append(self.mtu)
if self.enabled is not None: if self.autoconnect is not None:
cmd.append('autoconnect') cmd.append('autoconnect')
cmd.append(self.enabled) cmd.append(self.autoconnect)
return cmd return cmd
def create_connection_bridge(self): def create_connection_bridge(self):
@ -966,11 +969,10 @@ def main():
# Parsing argument file # Parsing argument file
module=AnsibleModule( module=AnsibleModule(
argument_spec=dict( argument_spec=dict(
enabled=dict(required=False, default=None, choices=['yes', 'no'], type='str'), autoconnect=dict(required=False, default=None, choices=['yes', 'no'], type='str'),
state=dict(required=True, choices=['present', 'absent'], type='str'), state=dict(required=True, choices=['present', 'absent'], type='str'),
conn_name=dict(required=False, type='str'), conn_name=dict(required=True, type='str'),
master=dict(required=False, default=None, type='str'), master=dict(required=False, default=None, type='str'),
autoconnect=dict(required=False, default=None, choices=['yes', 'no'], type='str'),
ifname=dict(required=False, default=None, type='str'), ifname=dict(required=False, default=None, type='str'),
type=dict(required=False, default=None, choices=['ethernet', 'team', 'team-slave', 'bond', 'bond-slave', 'bridge', 'vlan'], type='str'), type=dict(required=False, default=None, choices=['ethernet', 'team', 'team-slave', 'bond', 'bond-slave', 'bridge', 'vlan'], type='str'),
ip4=dict(required=False, default=None, type='str'), ip4=dict(required=False, default=None, type='str'),
@ -1009,12 +1011,6 @@ def main():
nmcli=Nmcli(module) nmcli=Nmcli(module)
if nmcli.syslogging:
syslog.openlog('ansible-%s' % os.path.basename(__file__))
syslog.syslog(syslog.LOG_NOTICE, 'Nmcli instantiated - platform %s' % nmcli.platform)
if nmcli.distribution:
syslog.syslog(syslog.LOG_NOTICE, 'Nuser instantiated - distribution %s' % nmcli.distribution)
rc=None rc=None
out='' out=''
err='' err=''

Loading…
Cancel
Save