Debian Codegraph @

ansible_collections/cisco/iosxr/docs/cisco.iosxr.iosxr_user_module.rst

raw
1 .. _cisco.iosxr.iosxr_user_module:
2
3
4 **********************
5 cisco.iosxr.iosxr_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 Requirements
25 ------------
26 The below requirements are needed on the host that executes this module.
27
28 - ncclient >= 0.5.3 when using netconf
29 - lxml >= 4.1.1 when using netconf
30 - base64 when using *public_key_contents* or *public_key*
31
32
33 Parameters
34 ----------
35
36 .. raw:: html
37
38 <table border=0 cellpadding=0 class="documentation-table">
39 <tr>
40 <th colspan="2">Parameter</th>
41 <th>Choices/<font color="blue">Defaults</font></th>
42 <th width="100%">Comments</th>
43 </tr>
44 <tr>
45 <td colspan="2">
46 <div class="ansibleOptionAnchor" id="parameter-"></div>
47 <b>admin</b>
48 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
49 <div style="font-size: small">
50 <span style="color: purple">boolean</span>
51 </div>
52 </td>
53 <td>
54 <ul style="margin: 0; padding: 0"><b>Choices:</b>
55 <li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
56 <li>yes</li>
57 </ul>
58 </td>
59 <td>
60 <div>Enters into administration configuration mode for making config changes to the device.</div>
61 <div>Applicable only when using network_cli transport</div>
62 </td>
63 </tr>
64 <tr>
65 <td colspan="2">
66 <div class="ansibleOptionAnchor" id="parameter-"></div>
67 <b>aggregate</b>
68 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
69 <div style="font-size: small">
70 <span style="color: purple">list</span>
71 / <span style="color: purple">elements=dictionary</span>
72 </div>
73 </td>
74 <td>
75 </td>
76 <td>
77 <div>The set of username objects to be configured on the remote Cisco IOS XR 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>
78 <div style="font-size: small; color: darkgreen"><br/>aliases: users, collection</div>
79 </td>
80 </tr>
81 <tr>
82 <td class="elbow-placeholder"></td>
83 <td colspan="1">
84 <div class="ansibleOptionAnchor" id="parameter-"></div>
85 <b>admin</b>
86 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
87 <div style="font-size: small">
88 <span style="color: purple">boolean</span>
89 </div>
90 </td>
91 <td>
92 <ul style="margin: 0; padding: 0"><b>Choices:</b>
93 <li>no</li>
94 <li>yes</li>
95 </ul>
96 </td>
97 <td>
98 <div>Enters into administration configuration mode for making config changes to the device.</div>
99 <div>Applicable only when using network_cli transport</div>
100 </td>
101 </tr>
102 <tr>
103 <td class="elbow-placeholder"></td>
104 <td colspan="1">
105 <div class="ansibleOptionAnchor" id="parameter-"></div>
106 <b>configured_password</b>
107 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
108 <div style="font-size: small">
109 <span style="color: purple">string</span>
110 </div>
111 </td>
112 <td>
113 </td>
114 <td>
115 <div>The password to be configured on the Cisco IOS XR device. The password needs to be provided in clear text. Password is encrypted on the device when used with <em>cli</em> and by Ansible when used with <em>netconf</em> using the same MD5 hash technique with salt size of 3. Please note that this option is not same as <code>provider password</code>.</div>
116 </td>
117 </tr>
118 <tr>
119 <td class="elbow-placeholder"></td>
120 <td colspan="1">
121 <div class="ansibleOptionAnchor" id="parameter-"></div>
122 <b>group</b>
123 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
124 <div style="font-size: small">
125 <span style="color: purple">string</span>
126 </div>
127 </td>
128 <td>
129 </td>
130 <td>
131 <div>Configures the group for the username in the device running configuration. The argument accepts a string value defining the group name. This argument does not check if the group has been configured on the device.</div>
132 <div style="font-size: small; color: darkgreen"><br/>aliases: role</div>
133 </td>
134 </tr>
135 <tr>
136 <td class="elbow-placeholder"></td>
137 <td colspan="1">
138 <div class="ansibleOptionAnchor" id="parameter-"></div>
139 <b>groups</b>
140 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
141 <div style="font-size: small">
142 <span style="color: purple">list</span>
143 / <span style="color: purple">elements=string</span>
144 </div>
145 </td>
146 <td>
147 </td>
148 <td>
149 <div>Configures the groups for the username in the device running configuration. The argument accepts a list of group names. This argument does not check if the group has been configured on the device. It is similar to the aggregate command for usernames, but lets you configure multiple groups for the user(s).</div>
150 </td>
151 </tr>
152 <tr>
153 <td class="elbow-placeholder"></td>
154 <td colspan="1">
155 <div class="ansibleOptionAnchor" id="parameter-"></div>
156 <b>name</b>
157 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
158 <div style="font-size: small">
159 <span style="color: purple">string</span>
160 / <span style="color: red">required</span>
161 </div>
162 </td>
163 <td>
164 </td>
165 <td>
166 <div>The username to be configured on the Cisco IOS XR 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>
167 </td>
168 </tr>
169 <tr>
170 <td class="elbow-placeholder"></td>
171 <td colspan="1">
172 <div class="ansibleOptionAnchor" id="parameter-"></div>
173 <b>public_key</b>
174 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
175 <div style="font-size: small">
176 <span style="color: purple">string</span>
177 </div>
178 </td>
179 <td>
180 </td>
181 <td>
182 <div>Configures the contents of the public keyfile to upload to the IOS-XR node. This enables users to login using the accompanying private key. IOS-XR only accepts base64 decoded files, so this will be decoded and uploaded to the node. Do note that this requires an OpenSSL public key file, PuTTy generated files will not work! Mutually exclusive with public_key_contents. If used with multiple users in aggregates, then the same key file is used for all users.</div>
183 </td>
184 </tr>
185 <tr>
186 <td class="elbow-placeholder"></td>
187 <td colspan="1">
188 <div class="ansibleOptionAnchor" id="parameter-"></div>
189 <b>public_key_contents</b>
190 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
191 <div style="font-size: small">
192 <span style="color: purple">string</span>
193 </div>
194 </td>
195 <td>
196 </td>
197 <td>
198 <div>Configures the contents of the public keyfile to upload to the IOS-XR node. This enables users to login using the accompanying private key. IOS-XR only accepts base64 decoded files, so this will be decoded and uploaded to the node. Do note that this requires an OpenSSL public key file, PuTTy generated files will not work! Mutually exclusive with public_key.If used with multiple users in aggregates, then the same key file is used for all users.</div>
199 </td>
200 </tr>
201 <tr>
202 <td class="elbow-placeholder"></td>
203 <td colspan="1">
204 <div class="ansibleOptionAnchor" id="parameter-"></div>
205 <b>state</b>
206 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
207 <div style="font-size: small">
208 <span style="color: purple">string</span>
209 </div>
210 </td>
211 <td>
212 <ul style="margin: 0; padding: 0"><b>Choices:</b>
213 <li>present</li>
214 <li>absent</li>
215 </ul>
216 </td>
217 <td>
218 <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>
219 </td>
220 </tr>
221 <tr>
222 <td class="elbow-placeholder"></td>
223 <td colspan="1">
224 <div class="ansibleOptionAnchor" id="parameter-"></div>
225 <b>update_password</b>
226 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
227 <div style="font-size: small">
228 <span style="color: purple">string</span>
229 </div>
230 </td>
231 <td>
232 <ul style="margin: 0; padding: 0"><b>Choices:</b>
233 <li>on_create</li>
234 <li>always</li>
235 </ul>
236 </td>
237 <td>
238 <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>
239 </td>
240 </tr>
241
242 <tr>
243 <td colspan="2">
244 <div class="ansibleOptionAnchor" id="parameter-"></div>
245 <b>configured_password</b>
246 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
247 <div style="font-size: small">
248 <span style="color: purple">string</span>
249 </div>
250 </td>
251 <td>
252 </td>
253 <td>
254 <div>The password to be configured on the Cisco IOS XR device. The password needs to be provided in clear text. Password is encrypted on the device when used with <em>cli</em> and by Ansible when used with <em>netconf</em> using the same MD5 hash technique with salt size of 3. Please note that this option is not same as <code>provider password</code>.</div>
255 </td>
256 </tr>
257 <tr>
258 <td colspan="2">
259 <div class="ansibleOptionAnchor" id="parameter-"></div>
260 <b>group</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 </td>
268 <td>
269 <div>Configures the group for the username in the device running configuration. The argument accepts a string value defining the group name. This argument does not check if the group has been configured on the device.</div>
270 <div style="font-size: small; color: darkgreen"><br/>aliases: role</div>
271 </td>
272 </tr>
273 <tr>
274 <td colspan="2">
275 <div class="ansibleOptionAnchor" id="parameter-"></div>
276 <b>groups</b>
277 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
278 <div style="font-size: small">
279 <span style="color: purple">list</span>
280 / <span style="color: purple">elements=string</span>
281 </div>
282 </td>
283 <td>
284 </td>
285 <td>
286 <div>Configures the groups for the username in the device running configuration. The argument accepts a list of group names. This argument does not check if the group has been configured on the device. It is similar to the aggregate command for usernames, but lets you configure multiple groups for the user(s).</div>
287 </td>
288 </tr>
289 <tr>
290 <td colspan="2">
291 <div class="ansibleOptionAnchor" id="parameter-"></div>
292 <b>name</b>
293 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
294 <div style="font-size: small">
295 <span style="color: purple">string</span>
296 </div>
297 </td>
298 <td>
299 </td>
300 <td>
301 <div>The username to be configured on the Cisco IOS XR 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>
302 </td>
303 </tr>
304 <tr>
305 <td colspan="2">
306 <div class="ansibleOptionAnchor" id="parameter-"></div>
307 <b>public_key</b>
308 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
309 <div style="font-size: small">
310 <span style="color: purple">string</span>
311 </div>
312 </td>
313 <td>
314 </td>
315 <td>
316 <div>Configures the contents of the public keyfile to upload to the IOS-XR node. This enables users to login using the accompanying private key. IOS-XR only accepts base64 decoded files, so this will be decoded and uploaded to the node. Do note that this requires an OpenSSL public key file, PuTTy generated files will not work! Mutually exclusive with public_key_contents. If used with multiple users in aggregates, then the same key file is used for all users.</div>
317 </td>
318 </tr>
319 <tr>
320 <td colspan="2">
321 <div class="ansibleOptionAnchor" id="parameter-"></div>
322 <b>public_key_contents</b>
323 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
324 <div style="font-size: small">
325 <span style="color: purple">string</span>
326 </div>
327 </td>
328 <td>
329 </td>
330 <td>
331 <div>Configures the contents of the public keyfile to upload to the IOS-XR node. This enables users to login using the accompanying private key. IOS-XR only accepts base64 decoded files, so this will be decoded and uploaded to the node. Do note that this requires an OpenSSL public key file, PuTTy generated files will not work! Mutually exclusive with public_key.If used with multiple users in aggregates, then the same key file is used for all users.</div>
332 </td>
333 </tr>
334 <tr>
335 <td colspan="2">
336 <div class="ansibleOptionAnchor" id="parameter-"></div>
337 <b>purge</b>
338 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
339 <div style="font-size: small">
340 <span style="color: purple">boolean</span>
341 </div>
342 </td>
343 <td>
344 <ul style="margin: 0; padding: 0"><b>Choices:</b>
345 <li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
346 <li>yes</li>
347 </ul>
348 </td>
349 <td>
350 <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 and the current defined set of users.</div>
351 </td>
352 </tr>
353 <tr>
354 <td colspan="2">
355 <div class="ansibleOptionAnchor" id="parameter-"></div>
356 <b>state</b>
357 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
358 <div style="font-size: small">
359 <span style="color: purple">string</span>
360 </div>
361 </td>
362 <td>
363 <ul style="margin: 0; padding: 0"><b>Choices:</b>
364 <li><div style="color: blue"><b>present</b>&nbsp;&larr;</div></li>
365 <li>absent</li>
366 </ul>
367 </td>
368 <td>
369 <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>
370 </td>
371 </tr>
372 <tr>
373 <td colspan="2">
374 <div class="ansibleOptionAnchor" id="parameter-"></div>
375 <b>update_password</b>
376 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
377 <div style="font-size: small">
378 <span style="color: purple">string</span>
379 </div>
380 </td>
381 <td>
382 <ul style="margin: 0; padding: 0"><b>Choices:</b>
383 <li>on_create</li>
384 <li><div style="color: blue"><b>always</b>&nbsp;&larr;</div></li>
385 </ul>
386 </td>
387 <td>
388 <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>
389 </td>
390 </tr>
391 </table>
392 <br/>
393
394
395 Notes
396 -----
397
398 .. note::
399 - This module works with connection ``network_cli`` and ``netconf``. See `the IOS-XR Platform Options <../network/user_guide/platform_iosxr.html>`_.
400 - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide <network_guide>`
401 - For more information on using Ansible to manage Cisco devices see the `Cisco integration page <https://www.ansible.com/integrations/networks/cisco>`_.
402
403
404
405 Examples
406 --------
407
408 .. code-block:: yaml
409
410 - name: create a new user
411 cisco.iosxr.iosxr_user:
412 name: ansible
413 configured_password: mypassword
414 state: present
415 - name: create a new user in admin configuration mode
416 cisco.iosxr.iosxr_user:
417 name: ansible
418 configured_password: mypassword
419 admin: true
420 state: present
421 - name: remove all users except admin
422 cisco.iosxr.iosxr_user:
423 purge: true
424 - name: set multiple users to group sys-admin
425 cisco.iosxr.iosxr_user:
426 aggregate:
427 - name: netop
428 - name: netend
429 group: sysadmin
430 state: present
431 - name: set multiple users to multiple groups
432 cisco.iosxr.iosxr_user:
433 aggregate:
434 - name: netop
435 - name: netend
436 groups:
437 - sysadmin
438 - root-system
439 state: present
440 - name: Change Password for User netop
441 cisco.iosxr.iosxr_user:
442 name: netop
443 configured_password: '{{ new_password }}'
444 update_password: always
445 state: present
446 - name: Add private key authentication for user netop
447 cisco.iosxr.iosxr_user:
448 name: netop
449 state: present
450 public_key_contents: "{{ lookup('file', '/home/netop/.ssh/id_rsa.pub' }}"
451
452
453
454 Return Values
455 -------------
456 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:
457
458 .. raw:: html
459
460 <table border=0 cellpadding=0 class="documentation-table">
461 <tr>
462 <th colspan="1">Key</th>
463 <th>Returned</th>
464 <th width="100%">Description</th>
465 </tr>
466 <tr>
467 <td colspan="1">
468 <div class="ansibleOptionAnchor" id="return-"></div>
469 <b>commands</b>
470 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
471 <div style="font-size: small">
472 <span style="color: purple">list</span>
473 </div>
474 </td>
475 <td>always</td>
476 <td>
477 <div>The list of configuration mode commands to send to the device</div>
478 <br/>
479 <div style="font-size: smaller"><b>Sample:</b></div>
480 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[&#x27;username ansible secret password group sysadmin&#x27;, &#x27;username admin secret admin&#x27;]</div>
481 </td>
482 </tr>
483 <tr>
484 <td colspan="1">
485 <div class="ansibleOptionAnchor" id="return-"></div>
486 <b>xml</b>
487 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
488 <div style="font-size: small">
489 <span style="color: purple">list</span>
490 </div>
491 </td>
492 <td>always (empty list when no xml rpc to send)</td>
493 <td>
494 <div>NetConf rpc xml sent to device with transport <code>netconf</code></div>
495 <br/>
496 <div style="font-size: smaller"><b>Sample:</b></div>
497 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[&#x27;&lt;config xmlns:xc=&quot;urn:ietf:params:xml:ns:netconf:base:1.0&quot;&gt; &lt;aaa xmlns=&quot;http://cisco.com/ns/yang/Cisco-IOS-XR-aaa-lib-cfg&quot;&gt; &lt;usernames xmlns=&quot;http://cisco.com/ns/yang/Cisco-IOS-XR-aaa-locald-cfg&quot;&gt; &lt;username xc:operation=&quot;merge&quot;&gt; &lt;name&gt;test7&lt;/name&gt; &lt;usergroup-under-usernames&gt; &lt;usergroup-under-username&gt; &lt;name&gt;sysadmin&lt;/name&gt; &lt;/usergroup-under-username&gt; &lt;/usergroup-under-usernames&gt; &lt;secret&gt;$1$ZsXC$zZ50wqhDC543ZWQkkAHLW0&lt;/secret&gt; &lt;/username&gt; &lt;/usernames&gt; &lt;/aaa&gt; &lt;/config&gt;&#x27;]</div>
498 </td>
499 </tr>
500 </table>
501 <br/><br/>
502
503
504 Status
505 ------
506
507
508 Authors
509 ~~~~~~~
510
511 - Trishna Guha (@trishnaguha)
512 - Sebastiaan van Doesselaar (@sebasdoes)
513 - Kedar Kekan (@kedarX)