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>
pull/51488/head
Nilashish Chakraborty 6 years ago committed by GitHub
parent f0f23378db
commit 2f0c666b5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -83,6 +83,14 @@ options:
`admin` user and the current defined set of users. `admin` user and the current defined set of users.
type: bool type: bool
default: false 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: state:
description: description:
- Configures the state of the username definition - Configures the state of the username definition
@ -123,6 +131,12 @@ EXAMPLES = """
name: ansible name: ansible
configured_password: mypassword configured_password: mypassword
state: present 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 - name: remove all users except admin
iosxr_user: iosxr_user:
purge: True purge: True
@ -478,7 +492,8 @@ class CliConfiguration(ConfigBase):
self._result['commands'] = [] self._result['commands'] = []
if commands: if commands:
commit = not self._module.check_mode 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: if diff:
self._result['diff'] = dict(prepared=diff) self._result['diff'] = dict(prepared=diff)
@ -638,6 +653,8 @@ def main():
configured_password=dict(no_log=True), configured_password=dict(no_log=True),
update_password=dict(default='always', choices=['on_create', 'always']), update_password=dict(default='always', choices=['on_create', 'always']),
admin=dict(type='bool', default=False),
public_key=dict(), public_key=dict(),
public_key_contents=dict(), public_key_contents=dict(),

@ -87,3 +87,8 @@ class TestIosxrUserModule(TestIosxrModule):
set_module_args(dict(name='ansible', configured_password='test', update_password='always')) set_module_args(dict(name='ansible', configured_password='test', update_password='always'))
result = self.execute_module(changed=True) result = self.execute_module(changed=True)
self.assertEqual(result['commands'], ['username ansible secret test']) 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'])

Loading…
Cancel
Save