diff --git a/README.md b/README.md
index 18c333bd91..b0207c9e46 100644
--- a/README.md
+++ b/README.md
@@ -69,6 +69,7 @@ Name | Description
[cisco.ios.ios_static_routes](https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_static_routes_module.rst)|Resource module to configure static routes.
[cisco.ios.ios_system](https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_system_module.rst)|Module to manage the system attributes.
[cisco.ios.ios_user](https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_user_module.rst)|Module to manage the aggregates of local users.
+[cisco.ios.ios_user_global](https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_user_global_module.rst)|Resource module to configure user and enable
[cisco.ios.ios_vlans](https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_vlans_module.rst)|Resource module to configure VLANs.
[cisco.ios.ios_vrf](https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_vrf_module.rst)|Module to configure VRF definitions.
diff --git a/docs/cisco.ios.ios_facts_module.rst b/docs/cisco.ios.ios_facts_module.rst
index 39b210f19d..debb908930 100644
--- a/docs/cisco.ios.ios_facts_module.rst
+++ b/docs/cisco.ios.ios_facts_module.rst
@@ -65,7 +65,7 @@ Parameters
|
- When supplied, this argument will restrict the facts collected to a given subset. Possible values for this argument include all and the resources like interfaces, vlans etc. Can specify a list of values to include a larger subset. Values can also be used with an initial ! to specify that a specific subset should not be collected. Valid subsets are 'bgp_global', 'l3_interfaces', 'lag_interfaces', 'ntp_global', 'acls', 'hostname', 'interfaces', 'lldp_interfaces', 'logging_global', 'ospf_interfaces', 'ospfv2', 'prefix_lists', 'static_routes', 'acl_interfaces', 'all', 'bgp_address_family', 'l2_interfaces', 'lacp', 'lacp_interfaces', 'lldp_global', 'ospfv3', 'snmp_server', 'vlans', 'service'.
+ When supplied, this argument will restrict the facts collected to a given subset. Possible values for this argument include all and the resources like interfaces, vlans etc. Can specify a list of values to include a larger subset. Values can also be used with an initial ! to specify that a specific subset should not be collected. Valid subsets are 'bgp_global', 'l3_interfaces', 'lag_interfaces', 'ntp_global', 'acls', 'hostname', 'interfaces', 'lldp_interfaces', 'logging_global', 'ospf_interfaces', 'ospfv2', 'prefix_lists', 'static_routes', 'acl_interfaces', 'all', 'bgp_address_family', 'l2_interfaces', 'lacp', 'lacp_interfaces', 'lldp_global', 'ospfv3', 'snmp_server', 'vlans', 'service', 'user_global'.
|
diff --git a/plugins/module_utils/network/ios/argspec/user_global/user_global.py b/plugins/module_utils/network/ios/argspec/user_global/user_global.py
index e537a95347..c66f6078ab 100644
--- a/plugins/module_utils/network/ios/argspec/user_global/user_global.py
+++ b/plugins/module_utils/network/ios/argspec/user_global/user_global.py
@@ -5,6 +5,7 @@
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
#############################################
@@ -18,10 +19,10 @@
#
# To update the argspec make the desired changes
# in the documentation in the module file and re-run
-# ansible.content_builder commenting out
+# ansible.content_builder commenting out
# the path to external 'docstring' in build.yaml.
#
-##############################################
+##############################################
"""
The arg spec for the ios_user_global module
@@ -29,8 +30,7 @@
class User_globalArgs(object): # pylint: disable=R0903
- """The arg spec for the ios_user_global module
- """
+ """The arg spec for the ios_user_global module"""
argument_spec = {
"config": {
diff --git a/plugins/module_utils/network/ios/config/user_global/user_global.py b/plugins/module_utils/network/ios/config/user_global/user_global.py
index b7fb88039d..7cada66fc1 100644
--- a/plugins/module_utils/network/ios/config/user_global/user_global.py
+++ b/plugins/module_utils/network/ios/config/user_global/user_global.py
@@ -7,6 +7,7 @@
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
"""
@@ -17,25 +18,27 @@
created.
"""
+import pprint
+
from copy import deepcopy
from ansible.module_utils.six import iteritems
-from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import (
- dict_merge,
-)
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import (
ResourceModule,
)
-from ansible_collections.cisco.ios.plugins.module_utils.network.ios.facts.facts import (
- Facts,
+from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import (
+ dict_merge,
)
+
+from ansible_collections.cisco.ios.plugins.module_utils.network.ios.facts.facts import Facts
from ansible_collections.cisco.ios.plugins.module_utils.network.ios.rm_templates.user_global import (
User_globalTemplate,
)
-import pprint
+
pp = pprint.PrettyPrinter(indent=4)
+
class User_global(ResourceModule):
"""
The ios_user_global config class
@@ -56,7 +59,7 @@ def __init__(self, module):
]
def execute_module(self):
- """ Execute the module
+ """Execute the module
:rtype: A dictionary
:returns: The result from module execution
@@ -67,13 +70,13 @@ def execute_module(self):
return self.result
def generate_commands(self):
- """ Generate configuration commands to send based on
- want, have and desired state.
+ """Generate configuration commands to send based on
+ want, have and desired state.
"""
wantd = self._users_list_to_dict(self.want)
haved = self._users_list_to_dict(self.have)
- pp.pprint([wantd,haved])
+ pp.pprint([wantd, haved])
# if state is merged, merge want onto have and then compare
if self.state == "merged":
@@ -87,9 +90,9 @@ def generate_commands(self):
def _compare(self, want, have):
"""Leverages the base class `compare()` method and
- populates the list of commands to be run by comparing
- the `want` and `have` data with the `parsers` defined
- for the User_global network resource.
+ populates the list of commands to be run by comparing
+ the `want` and `have` data with the `parsers` defined
+ for the User_global network resource.
"""
self.compare(parsers=self.parsers, want=want, have=have)
self._compare_lists_attrs(want, have)
@@ -118,7 +121,7 @@ def _users_list_to_dict(self, data):
for k, _v in p_key.items():
if k in tmp_data:
if k == "enable":
- tmp_data[k] = {str(i.get(_v,15)) : i for i in tmp_data[k]}
+ tmp_data[k] = {str(i.get(_v, 15)): i for i in tmp_data[k]}
else:
tmp_data[k] = {str(i[_v]): i for i in tmp_data[k]}
return tmp_data
diff --git a/plugins/module_utils/network/ios/facts/user_global/user_global.py b/plugins/module_utils/network/ios/facts/user_global/user_global.py
index 15df23a0e4..71e1669e95 100644
--- a/plugins/module_utils/network/ios/facts/user_global/user_global.py
+++ b/plugins/module_utils/network/ios/facts/user_global/user_global.py
@@ -26,11 +26,11 @@
User_globalTemplate,
)
+
class User_globalFacts(object):
- """ The ios user_global facts class
- """
+ """The ios user_global facts class"""
- def __init__(self, module, subspec='config', options='options'):
+ def __init__(self, module, subspec="config", options="options"):
self._module = module
self.argument_spec = User_globalArgs.argument_spec
@@ -45,13 +45,13 @@ def sort_list_dicts(self, objs):
for k, _v in p_key.items():
if k in objs:
if k == "enable":
- objs[k] = sorted(objs[k], key=lambda _k: str(_k.get(_v,15)))
+ objs[k] = sorted(objs[k], key=lambda _k: str(_k.get(_v, 15)))
else:
objs[k] = sorted(objs[k], key=lambda _k: str(_k[_v]))
return objs
def populate_facts(self, connection, ansible_facts, data=None):
- """ Populate the facts for User_global network resource
+ """Populate the facts for User_global network resource
:param connection: the device connection
:param ansible_facts: Facts dictionary
@@ -74,13 +74,13 @@ def populate_facts(self, connection, ansible_facts, data=None):
if objs:
self.sort_list_dicts(objs)
- ansible_facts['ansible_network_resources'].pop('user_global', None)
+ ansible_facts["ansible_network_resources"].pop("user_global", None)
params = utils.remove_empties(
- user_global_parser.validate_config(self.argument_spec, {"config": objs}, redact=True)
+ user_global_parser.validate_config(self.argument_spec, {"config": objs}, redact=True),
)
- facts['user_global'] = params['config']
- ansible_facts['ansible_network_resources'].update(facts)
+ facts["user_global"] = params["config"]
+ ansible_facts["ansible_network_resources"].update(facts)
return ansible_facts
diff --git a/plugins/module_utils/network/ios/rm_templates/user_global.py b/plugins/module_utils/network/ios/rm_templates/user_global.py
index 9c50bd1fbe..5177e708c7 100644
--- a/plugins/module_utils/network/ios/rm_templates/user_global.py
+++ b/plugins/module_utils/network/ios/rm_templates/user_global.py
@@ -21,6 +21,7 @@
NetworkTemplate,
)
+
class User_globalTemplate(NetworkTemplate):
def __init__(self, lines=None, module=None):
super(User_globalTemplate, self).__init__(lines=lines, tmplt=self, module=module)
@@ -36,7 +37,8 @@ def __init__(self, lines=None, module=None):
(\slevel\s(?P\d+))?
(\s(?P[56789]))?
(\s(?P\S+))?
- """, re.VERBOSE),
+ """, re.VERBOSE,
+ ),
"setval": "enable"
"{% if 'type' in password and password.type == 'password' %}"
"{{ ' password' }}"
@@ -72,7 +74,8 @@ def __init__(self, lines=None, module=None):
(\s(?Ppassword|secret))?
(\s(?P[56789]))?
(\s(?P\S+))?
- """, re.VERBOSE),
+ """, re.VERBOSE,
+ ),
"setval": "username {{ name }}"
"{{ ' privilege ' + privilege|string if privilege is defined and 0 <= privilege|int <= 15 and privilege|int != 1 else '' }}"
"{% if 'type' in password and password.type == 'password' %}"
diff --git a/plugins/modules/ios_user_global.py b/plugins/modules/ios_user_global.py
index 41fb0ff77f..6d1023730e 100644
--- a/plugins/modules/ios_user_global.py
+++ b/plugins/modules/ios_user_global.py
@@ -10,6 +10,7 @@
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
DOCUMENTATION = """
@@ -158,7 +159,7 @@
transforms it into JSON format as per the resource module parameters and the
value is returned in the I(parsed) key within the result. The value of C(running_config)
option should be the same format as the output of command
- I(show running-config | section ^username|^enable) executed on device. For state I(parsed)
+ I(show running-config | section ^username|^enable) executed on device. For state I(parsed)
active connection to remote host is not required.
type: str
"""
@@ -369,7 +370,7 @@
# "parsed": {
# "enable": [
-# {
+# {
# "password": {
# "type": "secret",
# "hash": 9,
@@ -439,6 +440,7 @@
"""
from ansible.module_utils.basic import AnsibleModule
+
from ansible_collections.cisco.ios.plugins.module_utils.network.ios.argspec.user_global.user_global import (
User_globalArgs,
)
diff --git a/tests/unit/modules/network/ios/test_ios_user_global.py b/tests/unit/modules/network/ios/test_ios_user_global.py
index 02713da8a0..bab36a3d52 100644
--- a/tests/unit/modules/network/ios/test_ios_user_global.py
+++ b/tests/unit/modules/network/ios/test_ios_user_global.py
@@ -8,7 +8,7 @@
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
@@ -21,6 +21,8 @@
__metaclass__ = type
+import pprint
+
from textwrap import dedent
from ansible_collections.cisco.ios.plugins.modules import ios_user_global
@@ -29,9 +31,10 @@
from .ios_module import TestIosModule
-import pprint
+
pp = pprint.PrettyPrinter(indent=4)
+
class TestIosUserGlobalModule(TestIosModule):
module = ios_user_global
@@ -195,7 +198,7 @@ def test_ios_user_global_overridden_idempotent(self):
"""\
enable secret 9 $9$q3zuC3f3vjWnWk$4BwPgPt25AUkm8Gts6aqW.NLK/90zBDnmWtOeMQqoDo
username admin secret 9 $9$oV7t.SyAkhiemE$D7GYIpVS/IOc0c15ev/n3p4Wo509XwQpPfyL1fuC5Dg
- """
+ """,
)
playbook = {
@@ -238,7 +241,7 @@ def test_ios_user_global_parsed(self):
""",
),
state="parsed",
- )
+ ),
)
parsed = {
"enable": [
@@ -270,7 +273,7 @@ def test_ios_user_global_gathered(self):
"""\
enable secret 9 $9$q3zuC3f3vjWnWk$4BwPgPt25AUkm8Gts6aqW.NLK/90zBDnmWtOeMQqoDo
username admin secret 9 $9$oV7t.SyAkhiemE$D7GYIpVS/IOc0c15ev/n3p4Wo509XwQpPfyL1fuC5Dg
- """
+ """,
)
set_module_args(dict(state="gathered"))
gathered = {