summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNilashish Chakraborty <nilashishchakraborty8@gmail.com>2019-01-30 15:37:28 +0530
committerGitHub <noreply@github.com>2019-01-30 15:37:28 +0530
commit2f0c666b5b3a7449047d2f76695b9a10e402f518 (patch)
tree8731d8f3bd95d009368fc5e72e6c9a582991ecf1
parentf0f23378dbb74b707d3ac30fbe2aed4b68e0d28d (diff)
downloadansible-2f0c666b5b3a7449047d2f76695b9a10e402f518.tar.gz
Add option to enter admin configuration mode in iosxr_user (#51430)
* Add admin mode to iosxr_user Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com> * Update docs for admin option Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com> * Fix review comment Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>
-rw-r--r--lib/ansible/modules/network/iosxr/iosxr_user.py19
-rw-r--r--test/units/modules/network/iosxr/test_iosxr_user.py5
2 files changed, 23 insertions, 1 deletions
diff --git a/lib/ansible/modules/network/iosxr/iosxr_user.py b/lib/ansible/modules/network/iosxr/iosxr_user.py
index 30205f4df5..9e4b8356e8 100644
--- a/lib/ansible/modules/network/iosxr/iosxr_user.py
+++ b/lib/ansible/modules/network/iosxr/iosxr_user.py
@@ -83,6 +83,14 @@ options:
`admin` user and the current defined set of users.
type: bool
default: false
+ admin:
+ description:
+ - Enters into administration configuration mode for making config
+ changes to the device.
+ - Applicable only when using network_cli transport
+ type: bool
+ default: false
+ version_added: "2.8"
state:
description:
- Configures the state of the username definition
@@ -123,6 +131,12 @@ EXAMPLES = """
name: ansible
configured_password: mypassword
state: present
+- name: create a new user in admin configuration mode
+ iosxr_user:
+ name: ansible
+ configured_password: mypassword
+ admin: True
+ state: present
- name: remove all users except admin
iosxr_user:
purge: True
@@ -478,7 +492,8 @@ class CliConfiguration(ConfigBase):
self._result['commands'] = []
if commands:
commit = not self._module.check_mode
- diff = load_config(self._module, commands, commit=commit)
+ admin = self._module.params['admin']
+ diff = load_config(self._module, commands, commit=commit, admin=admin)
if diff:
self._result['diff'] = dict(prepared=diff)
@@ -638,6 +653,8 @@ def main():
configured_password=dict(no_log=True),
update_password=dict(default='always', choices=['on_create', 'always']),
+ admin=dict(type='bool', default=False),
+
public_key=dict(),
public_key_contents=dict(),
diff --git a/test/units/modules/network/iosxr/test_iosxr_user.py b/test/units/modules/network/iosxr/test_iosxr_user.py
index 3c07f89680..755520fffd 100644
--- a/test/units/modules/network/iosxr/test_iosxr_user.py
+++ b/test/units/modules/network/iosxr/test_iosxr_user.py
@@ -87,3 +87,8 @@ class TestIosxrUserModule(TestIosxrModule):
set_module_args(dict(name='ansible', configured_password='test', update_password='always'))
result = self.execute_module(changed=True)
self.assertEqual(result['commands'], ['username ansible secret test'])
+
+ def test_iosxr_user_admin_mode(self):
+ set_module_args(dict(name='ansible-2', configured_password='test-2', admin=True))
+ result = self.execute_module(changed=True)
+ self.assertEqual(result['commands'], ['username ansible-2', 'username ansible-2 secret test-2'])