Debian Codegraph @

ansible_collections/cisco/ios/docs/cisco.ios.ios_user_module.rst

raw
1 .. _cisco.ios.ios_user_module:
2
3
4 ******************
5 cisco.ios.ios_user
6 ******************
7
8 **Module to manage the aggregates of local users.**
9
10
11 Version added: 1.0.0
12
13 .. contents::
14 :local:
15 :depth: 1
16
17
18 Synopsis
19 --------
20 - This module provides declarative management of the local usernames configured on network devices. It allows playbooks to manage either individual usernames or the aggregate of usernames in the current running config. It also supports purging usernames from the configuration that are not explicitly defined.
21
22
23
24
25 Parameters
26 ----------
27
28 .. raw:: html
29
30 <table border=0 cellpadding=0 class="documentation-table">
31 <tr>
32 <th colspan="3">Parameter</th>
33 <th>Choices/<font color="blue">Defaults</font></th>
34 <th width="100%">Comments</th>
35 </tr>
36 <tr>
37 <td colspan="3">
38 <div class="ansibleOptionAnchor" id="parameter-"></div>
39 <b>aggregate</b>
40 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
41 <div style="font-size: small">
42 <span style="color: purple">list</span>
43 / <span style="color: purple">elements=dictionary</span>
44 </div>
45 </td>
46 <td>
47 </td>
48 <td>
49 <div>The set of username objects to be configured on the remote Cisco IOS device. The list entries can either be the username or a hash of username and properties. This argument is mutually exclusive with the <code>name</code> argument.</div>
50 <div style="font-size: small; color: darkgreen"><br/>aliases: users, collection</div>
51 </td>
52 </tr>
53 <tr>
54 <td class="elbow-placeholder"></td>
55 <td colspan="2">
56 <div class="ansibleOptionAnchor" id="parameter-"></div>
57 <b>configured_password</b>
58 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
59 <div style="font-size: small">
60 <span style="color: purple">string</span>
61 </div>
62 </td>
63 <td>
64 </td>
65 <td>
66 <div>The password to be configured on the Cisco IOS device. The password needs to be provided in clear and it will be encrypted on the device. Please note that this option is not same as <code>provider password</code>.</div>
67 </td>
68 </tr>
69 <tr>
70 <td class="elbow-placeholder"></td>
71 <td colspan="2">
72 <div class="ansibleOptionAnchor" id="parameter-"></div>
73 <b>hashed_password</b>
74 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
75 <div style="font-size: small">
76 <span style="color: purple">dictionary</span>
77 </div>
78 </td>
79 <td>
80 </td>
81 <td>
82 <div>This option allows configuring hashed passwords on Cisco IOS devices.</div>
83 </td>
84 </tr>
85 <tr>
86 <td class="elbow-placeholder"></td>
87 <td class="elbow-placeholder"></td>
88 <td colspan="1">
89 <div class="ansibleOptionAnchor" id="parameter-"></div>
90 <b>type</b>
91 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
92 <div style="font-size: small">
93 <span style="color: purple">integer</span>
94 / <span style="color: red">required</span>
95 </div>
96 </td>
97 <td>
98 </td>
99 <td>
100 <div>Specifies the type of hash (e.g., 5 for MD5, 8 for PBKDF2, etc.)</div>
101 <div>For this to work, the device needs to support the desired hash type</div>
102 </td>
103 </tr>
104 <tr>
105 <td class="elbow-placeholder"></td>
106 <td class="elbow-placeholder"></td>
107 <td colspan="1">
108 <div class="ansibleOptionAnchor" id="parameter-"></div>
109 <b>value</b>
110 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
111 <div style="font-size: small">
112 <span style="color: purple">string</span>
113 / <span style="color: red">required</span>
114 </div>
115 </td>
116 <td>
117 </td>
118 <td>
119 <div>The actual hashed password to be configured on the device</div>
120 </td>
121 </tr>
122
123 <tr>
124 <td class="elbow-placeholder"></td>
125 <td colspan="2">
126 <div class="ansibleOptionAnchor" id="parameter-"></div>
127 <b>name</b>
128 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
129 <div style="font-size: small">
130 <span style="color: purple">string</span>
131 / <span style="color: red">required</span>
132 </div>
133 </td>
134 <td>
135 </td>
136 <td>
137 <div>The username to be configured on the Cisco IOS device. This argument accepts a string value and is mutually exclusive with the <code>aggregate</code> argument. Please note that this option is not same as <code>provider username</code>.</div>
138 </td>
139 </tr>
140 <tr>
141 <td class="elbow-placeholder"></td>
142 <td colspan="2">
143 <div class="ansibleOptionAnchor" id="parameter-"></div>
144 <b>nopassword</b>
145 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
146 <div style="font-size: small">
147 <span style="color: purple">boolean</span>
148 </div>
149 </td>
150 <td>
151 <ul style="margin: 0; padding: 0"><b>Choices:</b>
152 <li>no</li>
153 <li>yes</li>
154 </ul>
155 </td>
156 <td>
157 <div>Defines the username without assigning a password. This will allow the user to login to the system without being authenticated by a password.</div>
158 </td>
159 </tr>
160 <tr>
161 <td class="elbow-placeholder"></td>
162 <td colspan="2">
163 <div class="ansibleOptionAnchor" id="parameter-"></div>
164 <b>password_type</b>
165 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
166 <div style="font-size: small">
167 <span style="color: purple">string</span>
168 </div>
169 </td>
170 <td>
171 <ul style="margin: 0; padding: 0"><b>Choices:</b>
172 <li>secret</li>
173 <li>password</li>
174 </ul>
175 </td>
176 <td>
177 <div>This argument determines whether a &#x27;password&#x27; or &#x27;secret&#x27; will be configured.</div>
178 </td>
179 </tr>
180 <tr>
181 <td class="elbow-placeholder"></td>
182 <td colspan="2">
183 <div class="ansibleOptionAnchor" id="parameter-"></div>
184 <b>privilege</b>
185 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
186 <div style="font-size: small">
187 <span style="color: purple">integer</span>
188 </div>
189 </td>
190 <td>
191 </td>
192 <td>
193 <div>The <code>privilege</code> argument configures the privilege level of the user when logged into the system. This argument accepts integer values in the range of 1 to 15.</div>
194 </td>
195 </tr>
196 <tr>
197 <td class="elbow-placeholder"></td>
198 <td colspan="2">
199 <div class="ansibleOptionAnchor" id="parameter-"></div>
200 <b>purge_keys</b>
201 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
202 <div style="font-size: small">
203 <span style="color: purple">boolean</span>
204 </div>
205 </td>
206 <td>
207 <ul style="margin: 0; padding: 0"><b>Choices:</b>
208 <li>no</li>
209 <li>yes</li>
210 </ul>
211 </td>
212 <td>
213 <div>Since cisco.ios devices have a max limit of 2 keys per user, this parameter allows removal of keys that are not passed in sshkey parameter as to write new keys being passed.</div>
214 <div>It will remove any previously configured sshkeys for a user that doesn&#x27;t match with the provided sshkey list, with an exception for the `admin` user.</div>
215 <div>Works only with &#x27;present&#x27; state and when &#x27;sshkey&#x27; is defined</div>
216 </td>
217 </tr>
218 <tr>
219 <td class="elbow-placeholder"></td>
220 <td colspan="2">
221 <div class="ansibleOptionAnchor" id="parameter-"></div>
222 <b>sshkey</b>
223 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
224 <div style="font-size: small">
225 <span style="color: purple">list</span>
226 / <span style="color: purple">elements=string</span>
227 </div>
228 </td>
229 <td>
230 </td>
231 <td>
232 <div>Specifies upto two SSH public key(s) to configure for the given username.</div>
233 <div>This argument accepts a valid SSH key value.</div>
234 </td>
235 </tr>
236 <tr>
237 <td class="elbow-placeholder"></td>
238 <td colspan="2">
239 <div class="ansibleOptionAnchor" id="parameter-"></div>
240 <b>state</b>
241 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
242 <div style="font-size: small">
243 <span style="color: purple">string</span>
244 </div>
245 </td>
246 <td>
247 <ul style="margin: 0; padding: 0"><b>Choices:</b>
248 <li>present</li>
249 <li>absent</li>
250 </ul>
251 </td>
252 <td>
253 <div>Configures the state of the username definition as it relates to the device operational configuration. When set to <em>present</em>, the username(s) should be configured in the device active configuration and when set to <em>absent</em> the username(s) should not be in the device active configuration</div>
254 </td>
255 </tr>
256 <tr>
257 <td class="elbow-placeholder"></td>
258 <td colspan="2">
259 <div class="ansibleOptionAnchor" id="parameter-"></div>
260 <b>update_password</b>
261 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
262 <div style="font-size: small">
263 <span style="color: purple">string</span>
264 </div>
265 </td>
266 <td>
267 <ul style="margin: 0; padding: 0"><b>Choices:</b>
268 <li>on_create</li>
269 <li>always</li>
270 </ul>
271 </td>
272 <td>
273 <div>Since passwords are encrypted in the device running config, this argument will instruct the module when to change the password. When set to <code>always</code>, the password will always be updated in the device and when set to <code>on_create</code> the password will be updated only if the username is created.</div>
274 </td>
275 </tr>
276 <tr>
277 <td class="elbow-placeholder"></td>
278 <td colspan="2">
279 <div class="ansibleOptionAnchor" id="parameter-"></div>
280 <b>view</b>
281 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
282 <div style="font-size: small">
283 <span style="color: purple">string</span>
284 </div>
285 </td>
286 <td>
287 </td>
288 <td>
289 <div>Configures the view for the username in the device running configuration. The argument accepts a string value defining the view name. This argument does not check if the view has been configured on the device.</div>
290 <div style="font-size: small; color: darkgreen"><br/>aliases: role</div>
291 </td>
292 </tr>
293
294 <tr>
295 <td colspan="3">
296 <div class="ansibleOptionAnchor" id="parameter-"></div>
297 <b>configured_password</b>
298 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
299 <div style="font-size: small">
300 <span style="color: purple">string</span>
301 </div>
302 </td>
303 <td>
304 </td>
305 <td>
306 <div>The password to be configured on the Cisco IOS device. The password needs to be provided in clear and it will be encrypted on the device. Please note that this option is not same as <code>provider password</code>.</div>
307 </td>
308 </tr>
309 <tr>
310 <td colspan="3">
311 <div class="ansibleOptionAnchor" id="parameter-"></div>
312 <b>hashed_password</b>
313 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
314 <div style="font-size: small">
315 <span style="color: purple">dictionary</span>
316 </div>
317 </td>
318 <td>
319 </td>
320 <td>
321 <div>This option allows configuring hashed passwords on Cisco IOS devices.</div>
322 </td>
323 </tr>
324 <tr>
325 <td class="elbow-placeholder"></td>
326 <td colspan="2">
327 <div class="ansibleOptionAnchor" id="parameter-"></div>
328 <b>type</b>
329 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
330 <div style="font-size: small">
331 <span style="color: purple">integer</span>
332 / <span style="color: red">required</span>
333 </div>
334 </td>
335 <td>
336 </td>
337 <td>
338 <div>Specifies the type of hash (e.g., 5 for MD5, 8 for PBKDF2, etc.)</div>
339 <div>For this to work, the device needs to support the desired hash type</div>
340 </td>
341 </tr>
342 <tr>
343 <td class="elbow-placeholder"></td>
344 <td colspan="2">
345 <div class="ansibleOptionAnchor" id="parameter-"></div>
346 <b>value</b>
347 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
348 <div style="font-size: small">
349 <span style="color: purple">string</span>
350 / <span style="color: red">required</span>
351 </div>
352 </td>
353 <td>
354 </td>
355 <td>
356 <div>The actual hashed password to be configured on the device</div>
357 </td>
358 </tr>
359
360 <tr>
361 <td colspan="3">
362 <div class="ansibleOptionAnchor" id="parameter-"></div>
363 <b>name</b>
364 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
365 <div style="font-size: small">
366 <span style="color: purple">string</span>
367 </div>
368 </td>
369 <td>
370 </td>
371 <td>
372 <div>The username to be configured on the Cisco IOS device. This argument accepts a string value and is mutually exclusive with the <code>aggregate</code> argument. Please note that this option is not same as <code>provider username</code>.</div>
373 </td>
374 </tr>
375 <tr>
376 <td colspan="3">
377 <div class="ansibleOptionAnchor" id="parameter-"></div>
378 <b>nopassword</b>
379 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
380 <div style="font-size: small">
381 <span style="color: purple">boolean</span>
382 </div>
383 </td>
384 <td>
385 <ul style="margin: 0; padding: 0"><b>Choices:</b>
386 <li>no</li>
387 <li>yes</li>
388 </ul>
389 </td>
390 <td>
391 <div>Defines the username without assigning a password. This will allow the user to login to the system without being authenticated by a password.</div>
392 </td>
393 </tr>
394 <tr>
395 <td colspan="3">
396 <div class="ansibleOptionAnchor" id="parameter-"></div>
397 <b>password_type</b>
398 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
399 <div style="font-size: small">
400 <span style="color: purple">string</span>
401 </div>
402 </td>
403 <td>
404 <ul style="margin: 0; padding: 0"><b>Choices:</b>
405 <li><div style="color: blue"><b>secret</b>&nbsp;&larr;</div></li>
406 <li>password</li>
407 </ul>
408 </td>
409 <td>
410 <div>This argument determines whether a &#x27;password&#x27; or &#x27;secret&#x27; will be configured.</div>
411 </td>
412 </tr>
413 <tr>
414 <td colspan="3">
415 <div class="ansibleOptionAnchor" id="parameter-"></div>
416 <b>privilege</b>
417 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
418 <div style="font-size: small">
419 <span style="color: purple">integer</span>
420 </div>
421 </td>
422 <td>
423 </td>
424 <td>
425 <div>The <code>privilege</code> argument configures the privilege level of the user when logged into the system. This argument accepts integer values in the range of 1 to 15.</div>
426 </td>
427 </tr>
428 <tr>
429 <td colspan="3">
430 <div class="ansibleOptionAnchor" id="parameter-"></div>
431 <b>purge</b>
432 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
433 <div style="font-size: small">
434 <span style="color: purple">boolean</span>
435 </div>
436 </td>
437 <td>
438 <ul style="margin: 0; padding: 0"><b>Choices:</b>
439 <li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
440 <li>yes</li>
441 </ul>
442 </td>
443 <td>
444 <div>Instructs the module to consider the resource definition absolute. It will remove any previously configured usernames on the device with the exception of the `admin` user (the current defined set of users).</div>
445 </td>
446 </tr>
447 <tr>
448 <td colspan="3">
449 <div class="ansibleOptionAnchor" id="parameter-"></div>
450 <b>purge_keys</b>
451 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
452 <div style="font-size: small">
453 <span style="color: purple">boolean</span>
454 </div>
455 </td>
456 <td>
457 <ul style="margin: 0; padding: 0"><b>Choices:</b>
458 <li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
459 <li>yes</li>
460 </ul>
461 </td>
462 <td>
463 <div>Since cisco.ios devices have a max limit of 2 keys per user, this parameter allows removal of keys that are not passed in sshkey parameter as to write new keys being passed.</div>
464 <div>It will remove any previously configured sshkeys for a user that doesn&#x27;t match with the provided sshkey list, with an exception for the `admin` user.</div>
465 <div>Works only with &#x27;present&#x27; state and when &#x27;sshkey&#x27; is defined</div>
466 </td>
467 </tr>
468 <tr>
469 <td colspan="3">
470 <div class="ansibleOptionAnchor" id="parameter-"></div>
471 <b>sshkey</b>
472 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
473 <div style="font-size: small">
474 <span style="color: purple">list</span>
475 / <span style="color: purple">elements=string</span>
476 </div>
477 </td>
478 <td>
479 </td>
480 <td>
481 <div>Specifies upto two SSH public key(s) to configure for the given username.</div>
482 <div>This argument accepts a valid SSH key value.</div>
483 </td>
484 </tr>
485 <tr>
486 <td colspan="3">
487 <div class="ansibleOptionAnchor" id="parameter-"></div>
488 <b>state</b>
489 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
490 <div style="font-size: small">
491 <span style="color: purple">string</span>
492 </div>
493 </td>
494 <td>
495 <ul style="margin: 0; padding: 0"><b>Choices:</b>
496 <li><div style="color: blue"><b>present</b>&nbsp;&larr;</div></li>
497 <li>absent</li>
498 </ul>
499 </td>
500 <td>
501 <div>Configures the state of the username definition as it relates to the device operational configuration. When set to <em>present</em>, the username(s) should be configured in the device active configuration and when set to <em>absent</em> the username(s) should not be in the device active configuration</div>
502 </td>
503 </tr>
504 <tr>
505 <td colspan="3">
506 <div class="ansibleOptionAnchor" id="parameter-"></div>
507 <b>update_password</b>
508 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
509 <div style="font-size: small">
510 <span style="color: purple">string</span>
511 </div>
512 </td>
513 <td>
514 <ul style="margin: 0; padding: 0"><b>Choices:</b>
515 <li>on_create</li>
516 <li><div style="color: blue"><b>always</b>&nbsp;&larr;</div></li>
517 </ul>
518 </td>
519 <td>
520 <div>Since passwords are encrypted in the device running config, this argument will instruct the module when to change the password. When set to <code>always</code>, the password will always be updated in the device and when set to <code>on_create</code> the password will be updated only if the username is created.</div>
521 </td>
522 </tr>
523 <tr>
524 <td colspan="3">
525 <div class="ansibleOptionAnchor" id="parameter-"></div>
526 <b>view</b>
527 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
528 <div style="font-size: small">
529 <span style="color: purple">string</span>
530 </div>
531 </td>
532 <td>
533 </td>
534 <td>
535 <div>Configures the view for the username in the device running configuration. The argument accepts a string value defining the view name. This argument does not check if the view has been configured on the device.</div>
536 <div style="font-size: small; color: darkgreen"><br/>aliases: role</div>
537 </td>
538 </tr>
539 </table>
540 <br/>
541
542
543 Notes
544 -----
545
546 .. note::
547 - Tested against Cisco IOSXE Version 17.3 on CML.
548 - This module works with connection ``network_cli``. See https://docs.ansible.com/ansible/latest/network/user_guide/platform_ios.html
549 - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide <network_guide>`
550 - For more information on using Ansible to manage Cisco devices see the `Cisco integration page <https://www.ansible.com/integrations/networks/cisco>`_.
551
552
553
554 Examples
555 --------
556
557 .. code-block:: yaml
558
559 # Using state: present
560
561 # Before state:
562 # -------------
563
564 # router-ios#show running-config | section ^username
565 # username testuser privilege 15 password 0 password
566
567 # Present state create a new user play:
568 # -------------------------------------
569
570 - name: Create a new user
571 cisco.ios.ios_user:
572 name: ansible
573 nopassword: true
574 sshkey: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
575 state: present
576
577 # Task Output
578 # -----------
579
580 # commands:
581 # - ip ssh pubkey-chain
582 # - username ansible
583 # - key-hash ssh-rsa 2ABB27BBC33ED53EF7D55037952ABB27 test@fedora
584 # - exit
585 # - exit
586 # - username ansible nopassword
587
588 # After state:
589 # ------------
590
591 # router-ios#show running-config | section username
592 # username testuser privilege 15 password 0 password
593 # username ansible nopassword
594 # username ansible
595 # key-hash ssh-rsa 2ABB27BBC33ED53EF7D55037952ABB27 test@fedora
596
597 # Using state: present
598
599 # Before state:
600 # -------------
601
602 # router-ios#show running-config | section ^username
603 # username testuser privilege 15 password 0 password
604
605 # Present state create a new user with multiple keys play:
606 # --------------------------------------------------------
607
608 - name: Create a new user with multiple keys
609 cisco.ios.ios_user:
610 name: ansible
611 sshkey:
612 - "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
613 - "{{ lookup('file', '~/path/to/public_key') }}"
614 state: present
615
616 # Task Output
617 # -----------
618
619 # commands:
620 # - ip ssh pubkey-chain
621 # - username ansible
622 # - key-hash ssh-rsa 2ABB27BBC33ED53EF7D55037952ABB27 test@fedora
623 # - key-hash ssh-rsa 1985673DCF7FA9A0F374BB97DC2ABB27 test@fedora
624 # - exit
625 # - exit
626
627 # After state:
628 # ------------
629
630 # router-ios#show running-config | section username
631 # username testuser privilege 15 password 0 password
632 # username ansible
633 # key-hash ssh-rsa 2ABB27BBC33ED53EF7D55037952ABB27 test@fedora
634 # key-hash ssh-rsa 1985673DCF7FA9A0F374BB97DC2ABB27 test@fedora
635
636 # Using purge_keys: true
637
638 # Before state:
639 # -------------
640
641 # router-ios#show running-config | section ^username
642 # username admin privilege 15 password 0 password
643 # username testuser privilege 15 password 0 password
644 # username ansible nopassword
645 # username ansible
646 # key-hash ssh-rsa 2ABB27BBC33ED53EF7D55037952ABB27 test@fedora
647
648 # Purge existing keys for a user and write new keys:
649 # ----------------------------------
650
651 - name: Update user by adding new key and purging existing keys
652 cisco.ios.ios_user:
653 name: ansible
654 sshkey:
655 - "{{ lookup('file', '~/path/to/public_key') }}"
656 purge_keys: true
657
658 # Task Output
659 # -----------
660
661 # commands:
662 # - ip ssh pubkey-chain
663 # - username ansible
664 # - no key-hash ssh-rsa 2ABB27BBC33ED53EF7D55037952ABB27 test@fedora
665 # - exit
666 # - exit
667 # - ip ssh pubkey-chain
668 # - username ansible
669 # - key-hash ssh-rsa B2C881222DB43D58A229EDF19D2228A2 test2@fedora
670 # - exit
671 # - exit
672
673 # After state:
674 # ------------
675
676 # router-ios#show running-config | section username
677 # username admin privilege 15 password 0 password
678 # username ansible nopassword
679 # username ansible
680 # key-hash ssh-rsa B2C881222DB43D58A229EDF19D2228A2 test2@fedora
681
682 # Using Purge: true
683
684 # Before state:
685 # -------------
686
687 # router-ios#show running-config | section ^username
688 # username admin privilege 15 password 0 password
689 # username testuser privilege 15 password 0 password
690 # username ansible nopassword
691 # username ansible
692 # key-hash ssh-rsa 2ABB27BBC33ED53EF7D55037952ABB27 test@fedora
693
694 # Purge all users except admin play:
695 # ----------------------------------
696
697 - name: Remove all users except admin
698 cisco.ios.ios_user:
699 purge: true
700
701 # Task Output
702 # -----------
703
704 # commands:
705 # - no username testuser
706 # - no username ansible
707 # - ip ssh pubkey-chain
708 # - no username ansible
709 # - exit
710
711 # After state:
712 # ------------
713
714 # router-ios#show running-config | section username
715 # username admin privilege 15 password 0 password
716
717 # Using Purge: true
718
719 # Before state:
720 # -------------
721
722 # router-ios#show running-config | section ^username
723 # username admin privilege 15 password 0 password
724 # username testuser privilege 15 password 0 password1
725 # username testuser1 privilege 15 password 0 password2
726 # username ansible nopassword
727
728 # Purge all users except admin and these listed users play:
729 # ---------------------------------------------------------
730
731 - name: Remove all users except admin and these listed users
732 cisco.ios.ios_user:
733 aggregate:
734 - name: testuser
735 - name: testuser1
736 purge: true
737
738 # Task Output
739 # -----------
740
741
742 # commands:
743 # - no username ansible
744
745 # After state:
746 # ------------
747
748 # router-ios#show running-config | section username
749 # username admin privilege 15 password 0 password
750 # username testuser privilege 15 password 0 password1
751 # username testuser1 privilege 15 password 0 password2
752
753 # Using state: present
754
755 # Before state:
756 # -------------
757
758 # router-ios#show running-config | section ^username
759 # username admin privilege 15 password 0 password
760 # username netop password 0 password1
761 # username netend password 0 password2
762
763 # Present state set multiple users to privilege level 15 play:
764 # ------------------------------------------------------------
765
766 - name: Set multiple users to privilege level 15
767 cisco.ios.ios_user:
768 aggregate:
769 - name: netop
770 - name: netend
771 privilege: 15
772 state: present
773
774 # Task Output
775 # -----------
776
777 # commands:
778 # - username netop privilege 15
779 # - username netend privilege 15
780
781 # After state:
782 # ------------
783
784 # router-ios#show running-config | section username
785 # username admin privilege 15 password 0 password
786 # username netop privilege 15 password 0 password1
787 # username netend privilege 15 password 0 password2
788
789 # Using state: present
790
791 # Before state:
792 # -------------
793
794 # router-ios#show running-config | section ^username
795 # username admin privilege 15 password 0 password
796 # username netop privilege 15 password 0 oldpassword
797
798 # Present state Change Password for User netop play:
799 # --------------------------------------------
800
801 - name: Change Password for User netop
802 cisco.ios.ios_user:
803 name: netop
804 configured_password: "newpassword"
805 password_type: password
806 update_password: always
807 state: present
808
809 # Task Output
810 # -----------
811
812 # commands:
813 # - username netop password newpassword
814
815 # After state:
816 # ------------
817
818 # router-ios#show running-config | section username
819 # username admin privilege 15 password 0 password
820 # username netop privilege 15 password 0 newpassword
821
822 # Using state: present
823
824 # Before state:
825 # -------------
826
827 # router-ios#show running-config | section ^username
828 # username admin privilege 15 password 0 password
829 # username netop privilege 15 password 0 password
830 # username netend privilege 15 password 0 password
831
832 # Present state set user view/role for users play:
833 # --------------------------------------------
834
835 - name: Set user view/role for users
836 cisco.ios.ios_user:
837 aggregate:
838 - name: netop
839 - name: netend
840 view: network-admin
841 state: present
842
843 # Task Output
844 # -----------
845
846 # commands:
847 # - username netop view network-admin
848 # - username netend view network-admin
849
850 # After state:
851 # ------------
852
853 # router-ios#show running-config | section username
854 # username admin privilege 15 password 0 password
855 # username netop privilege 15 view network-admin password 0 password
856 # username netend privilege 15 view network-admin password 0 password
857
858 # Using state: present
859
860 # Before state:
861 # -------------
862
863 # router-ios#show running-config | section ^username
864 # username admin privilege 15 password 0 password
865
866 # Present state create a new user with hashed password play:
867 # --------------------------------------------------------------
868
869 - name: Create a new user with hashed password
870 cisco.ios.ios_user:
871 name: ansibletest5
872 hashed_password:
873 type: 9
874 value: "thiswillbereplacedwithhashedpassword"
875 state: present
876
877 # Task Output
878 # -----------
879
880 # commands:
881 # - username ansibletest5 secret 9 thiswillbereplacedwithhashedpassword
882
883 # After state:
884 # ------------
885
886 # router-ios#show running-config | section username
887 # username admin privilege 15 password 0 password
888 # username ansibletest5 secret 9 thiswillbereplacedwithhashedpassword
889
890 # Using state: absent
891
892 # Before state:
893 # -------------
894
895 # router-ios#show running-config | section ^username
896 # username admin privilege 15 password 0 password
897 # username ansibletest1 password 0 password
898 # username ansibletest2 secret 9 thiswillbereplacedwithhashedpassword
899 # username ansibletest3 password 5 thistoowillbereplacedwithhashedpassword
900
901 # Absent state remove multiple users play:
902 # ----------------------------------------
903
904 - name: Delete users with aggregate
905 cisco.ios.ios_user:
906 aggregate:
907 - name: ansibletest1
908 - name: ansibletest2
909 - name: ansibletest3
910 state: absent
911
912 # Task Output
913 # -----------
914
915 # commands:
916 # - no username ansibletest1
917 # - no username ansibletest2
918 # - no username ansibletest3
919
920 # After state:
921 # ------------
922
923 # router-ios#show running-config | section username
924 # username admin privilege 15 password 0 password
925
926
927
928 Return Values
929 -------------
930 Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
931
932 .. raw:: html
933
934 <table border=0 cellpadding=0 class="documentation-table">
935 <tr>
936 <th colspan="1">Key</th>
937 <th>Returned</th>
938 <th width="100%">Description</th>
939 </tr>
940 <tr>
941 <td colspan="1">
942 <div class="ansibleOptionAnchor" id="return-"></div>
943 <b>commands</b>
944 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
945 <div style="font-size: small">
946 <span style="color: purple">list</span>
947 </div>
948 </td>
949 <td>always</td>
950 <td>
951 <div>The list of configuration mode commands to send to the device</div>
952 <br/>
953 <div style="font-size: smaller"><b>Sample:</b></div>
954 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[&#x27;username ansible secret password&#x27;, &#x27;username admin secret admin&#x27;]</div>
955 </td>
956 </tr>
957 </table>
958 <br/><br/>
959
960
961 Status
962 ------
963
964
965 Authors
966 ~~~~~~~
967
968 - Trishna Guha (@trishnaguha)