| 1 |
.. _dellemc.enterprise_sonic.sonic_users_module: |
| 2 |
|
| 3 |
|
| 4 |
************************************ |
| 5 |
dellemc.enterprise_sonic.sonic_users |
| 6 |
************************************ |
| 7 |
|
| 8 |
**Manage users and its parameters** |
| 9 |
|
| 10 |
|
| 11 |
Version added: 1.1.0 |
| 12 |
|
| 13 |
.. contents:: |
| 14 |
:local: |
| 15 |
:depth: 1 |
| 16 |
|
| 17 |
|
| 18 |
Synopsis |
| 19 |
-------- |
| 20 |
- This module provides configuration management of users parameters on devices running Enterprise SONiC. |
| 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="2">Parameter</th> |
| 33 |
<th>Choices/<font color="blue">Defaults</font></th> |
| 34 |
<th width="100%">Comments</th> |
| 35 |
</tr> |
| 36 |
<tr> |
| 37 |
<td colspan="2"> |
| 38 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 39 |
<b>config</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>Specifies the users related configuration.</div> |
| 50 |
</td> |
| 51 |
</tr> |
| 52 |
<tr> |
| 53 |
<td class="elbow-placeholder"></td> |
| 54 |
<td colspan="1"> |
| 55 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 56 |
<b>name</b> |
| 57 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 58 |
<div style="font-size: small"> |
| 59 |
<span style="color: purple">string</span> |
| 60 |
/ <span style="color: red">required</span> |
| 61 |
</div> |
| 62 |
</td> |
| 63 |
<td> |
| 64 |
</td> |
| 65 |
<td> |
| 66 |
<div>Specifies the name of the user.</div> |
| 67 |
</td> |
| 68 |
</tr> |
| 69 |
<tr> |
| 70 |
<td class="elbow-placeholder"></td> |
| 71 |
<td colspan="1"> |
| 72 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 73 |
<b>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">string</span> |
| 77 |
</div> |
| 78 |
</td> |
| 79 |
<td> |
| 80 |
</td> |
| 81 |
<td> |
| 82 |
<div>Specifies the password of the user.</div> |
| 83 |
</td> |
| 84 |
</tr> |
| 85 |
<tr> |
| 86 |
<td class="elbow-placeholder"></td> |
| 87 |
<td colspan="1"> |
| 88 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 89 |
<b>role</b> |
| 90 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 91 |
<div style="font-size: small"> |
| 92 |
<span style="color: purple">string</span> |
| 93 |
</div> |
| 94 |
</td> |
| 95 |
<td> |
| 96 |
<ul style="margin: 0; padding: 0"><b>Choices:</b> |
| 97 |
<li>admin</li> |
| 98 |
<li>operator</li> |
| 99 |
<li>netadmin</li> |
| 100 |
<li>secadmin</li> |
| 101 |
</ul> |
| 102 |
</td> |
| 103 |
<td> |
| 104 |
<div>Specifies the role of the user.</div> |
| 105 |
</td> |
| 106 |
</tr> |
| 107 |
<tr> |
| 108 |
<td class="elbow-placeholder"></td> |
| 109 |
<td colspan="1"> |
| 110 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 111 |
<b>ssh_key</b> |
| 112 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 113 |
<div style="font-size: small"> |
| 114 |
<span style="color: purple">string</span> |
| 115 |
</div> |
| 116 |
<div style="font-style: italic; font-size: small; color: darkgreen">added in 3.1.0</div> |
| 117 |
</td> |
| 118 |
<td> |
| 119 |
</td> |
| 120 |
<td> |
| 121 |
<div>Specifies the user ssh key for an existing user.</div> |
| 122 |
<div>The ssh key pair (public and private key) can be created using ssh-keygen command on the server from</div> |
| 123 |
<div>where the user will connect to the SONiC device.</div> |
| 124 |
<div>Only the public key is configured in the ssh_key field.</div> |
| 125 |
<div>The ssh_key option can only be "merged" after initial creation of the affected "user" instance</div> |
| 126 |
<div>and must be merged without any additional options specified other than "name".</div> |
| 127 |
<div>It can only be deleted as an individual option if it is the only option specified.</div> |
| 128 |
<div>If other options are specified for deletion, the entire user instance is deleted.</div> |
| 129 |
</td> |
| 130 |
</tr> |
| 131 |
<tr> |
| 132 |
<td class="elbow-placeholder"></td> |
| 133 |
<td colspan="1"> |
| 134 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 135 |
<b>update_password</b> |
| 136 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 137 |
<div style="font-size: small"> |
| 138 |
<span style="color: purple">string</span> |
| 139 |
</div> |
| 140 |
</td> |
| 141 |
<td> |
| 142 |
<ul style="margin: 0; padding: 0"><b>Choices:</b> |
| 143 |
<li><div style="color: blue"><b>always</b> ←</div></li> |
| 144 |
<li>on_create</li> |
| 145 |
</ul> |
| 146 |
</td> |
| 147 |
<td> |
| 148 |
<div>Specifies the update password flag.</div> |
| 149 |
<div>In case of always, password will be updated every time.</div> |
| 150 |
<div>In case of on_create, password will be updated only when user is created.</div> |
| 151 |
</td> |
| 152 |
</tr> |
| 153 |
|
| 154 |
<tr> |
| 155 |
<td colspan="2"> |
| 156 |
<div class="ansibleOptionAnchor" id="parameter-"></div> |
| 157 |
<b>state</b> |
| 158 |
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> |
| 159 |
<div style="font-size: small"> |
| 160 |
<span style="color: purple">string</span> |
| 161 |
</div> |
| 162 |
</td> |
| 163 |
<td> |
| 164 |
<ul style="margin: 0; padding: 0"><b>Choices:</b> |
| 165 |
<li><div style="color: blue"><b>merged</b> ←</div></li> |
| 166 |
<li>deleted</li> |
| 167 |
<li>overridden</li> |
| 168 |
<li>replaced</li> |
| 169 |
</ul> |
| 170 |
</td> |
| 171 |
<td> |
| 172 |
<div>Specifies the operation to be performed on the users configured on the device.</div> |
| 173 |
<div>In case of merged, the input configuration will be merged with the existing users configuration on the device.</div> |
| 174 |
<div>In case of deleted the existing users configuration will be removed from the device.</div> |
| 175 |
<div>In case of replaced, the existing specified user configuration will be replaced with provided configuration.</div> |
| 176 |
<div>In case of overridden, the existing users configuration will be overridden with the provided configuration.</div> |
| 177 |
</td> |
| 178 |
</tr> |
| 179 |
</table> |
| 180 |
<br/> |
| 181 |
|
| 182 |
|
| 183 |
Notes |
| 184 |
----- |
| 185 |
|
| 186 |
.. note:: |
| 187 |
- Tested against Enterprise SONiC Distribution by Dell Technologies. |
| 188 |
- Supports ``check_mode``. |
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
Examples |
| 193 |
-------- |
| 194 |
|
| 195 |
.. code-block:: yaml |
| 196 |
|
| 197 |
# Using "deleted" state |
| 198 |
# |
| 199 |
# Before state: |
| 200 |
# ------------- |
| 201 |
# |
| 202 |
# sonic# show users configured |
| 203 |
# ---------------------------------------------------------------------- |
| 204 |
# User Role(s) |
| 205 |
# ---------------------------------------------------------------------- |
| 206 |
# admin admin |
| 207 |
# sysadmin admin |
| 208 |
# sysoperator operator |
| 209 |
|
| 210 |
- name: Delete user |
| 211 |
dellemc.enterprise_sonic.sonic_users: |
| 212 |
config: |
| 213 |
- name: sysoperator |
| 214 |
state: deleted |
| 215 |
|
| 216 |
# After state: |
| 217 |
# ------------ |
| 218 |
# |
| 219 |
# sonic# show users configured |
| 220 |
# ---------------------------------------------------------------------- |
| 221 |
# User Role(s) |
| 222 |
# ---------------------------------------------------------------------- |
| 223 |
# admin admin |
| 224 |
# sysadmin admin |
| 225 |
|
| 226 |
# Using "deleted" state |
| 227 |
# |
| 228 |
# Before state: |
| 229 |
# ------------- |
| 230 |
# |
| 231 |
# sonic# show users configured |
| 232 |
# ---------------------------------------------------------------------- |
| 233 |
# User Role(s) |
| 234 |
# ---------------------------------------------------------------------- |
| 235 |
# admin admin |
| 236 |
# sysadmin admin |
| 237 |
# sysoperator operator |
| 238 |
|
| 239 |
- name: Delete all users configurations except admin |
| 240 |
dellemc.enterprise_sonic.sonic_users: |
| 241 |
config: |
| 242 |
state: deleted |
| 243 |
|
| 244 |
# After state: |
| 245 |
# ------------ |
| 246 |
# |
| 247 |
# sonic# show users configured |
| 248 |
# ---------------------------------------------------------------------- |
| 249 |
# User Role(s) |
| 250 |
# ---------------------------------------------------------------------- |
| 251 |
# admin admin |
| 252 |
|
| 253 |
# Using "merged" state |
| 254 |
# |
| 255 |
# Before state: |
| 256 |
# ------------- |
| 257 |
# |
| 258 |
# sonic# show users configured |
| 259 |
# ---------------------------------------------------------------------- |
| 260 |
# User Role(s) |
| 261 |
# ---------------------------------------------------------------------- |
| 262 |
# admin admin |
| 263 |
|
| 264 |
- name: Merge users configurations |
| 265 |
dellemc.enterprise_sonic.sonic_users: |
| 266 |
config: |
| 267 |
- name: sysadmin |
| 268 |
role: admin |
| 269 |
password: admin |
| 270 |
update_password: always |
| 271 |
- name: sysoperator |
| 272 |
role: operator |
| 273 |
password: operator |
| 274 |
update_password: always |
| 275 |
state: merged |
| 276 |
|
| 277 |
# After state: |
| 278 |
# ------------ |
| 279 |
# |
| 280 |
# sonic# show users configured |
| 281 |
# ---------------------------------------------------------------------- |
| 282 |
# User Role(s) |
| 283 |
# ---------------------------------------------------------------------- |
| 284 |
# admin admin |
| 285 |
# sysadmin admin |
| 286 |
# sysoperator operator |
| 287 |
|
| 288 |
# Using "overridden" state |
| 289 |
# |
| 290 |
# Before state: |
| 291 |
# ------------- |
| 292 |
# |
| 293 |
# sonic# show users configured |
| 294 |
# ---------------------------------------------------------------------- |
| 295 |
# User Role(s) |
| 296 |
# ---------------------------------------------------------------------- |
| 297 |
# admin admin |
| 298 |
# sysadmin admin |
| 299 |
# sysoperator operator |
| 300 |
|
| 301 |
- name: Override users configurations |
| 302 |
dellemc.enterprise_sonic.sonic_users: |
| 303 |
config: |
| 304 |
- name: user1 |
| 305 |
role: secadmin |
| 306 |
password: 123abc |
| 307 |
update_password: always |
| 308 |
state: overridden |
| 309 |
|
| 310 |
# After state: |
| 311 |
# ------------ |
| 312 |
# |
| 313 |
# sonic# show users configured |
| 314 |
# ---------------------------------------------------------------------- |
| 315 |
# User Role(s) |
| 316 |
# ---------------------------------------------------------------------- |
| 317 |
# admin admin |
| 318 |
# user1 secadmin |
| 319 |
|
| 320 |
# Using "replaced" state |
| 321 |
# |
| 322 |
# Before state: |
| 323 |
# ------------- |
| 324 |
# |
| 325 |
# sonic# show users configured |
| 326 |
# ---------------------------------------------------------------------- |
| 327 |
# User Role(s) |
| 328 |
# ---------------------------------------------------------------------- |
| 329 |
# admin admin |
| 330 |
# user1 secadmin |
| 331 |
# user2 operator |
| 332 |
|
| 333 |
- name: Replace users configurations |
| 334 |
dellemc.enterprise_sonic.sonic_users: |
| 335 |
config: |
| 336 |
- name: user1 |
| 337 |
role: operator |
| 338 |
password: 123abc |
| 339 |
update_password: always |
| 340 |
- name: user2 |
| 341 |
role: netadmin |
| 342 |
password: 123abc |
| 343 |
update_password: always |
| 344 |
state: replaced |
| 345 |
|
| 346 |
# After state: |
| 347 |
# ------------ |
| 348 |
# |
| 349 |
# sonic# show users configured |
| 350 |
# ---------------------------------------------------------------------- |
| 351 |
# User Role(s) |
| 352 |
# ---------------------------------------------------------------------- |
| 353 |
# admin admin |
| 354 |
# user1 operator |
| 355 |
# user2 netadmin |
| 356 |
|
| 357 |
# Using Merged |
| 358 |
# |
| 359 |
# Before state: |
| 360 |
# ------------- |
| 361 |
# |
| 362 |
# sonic# show users sshkey |
| 363 |
# |
| 364 |
# sonic# show users configured |
| 365 |
# -------------------------------------------------------------------- |
| 366 |
# User Role(s) |
| 367 |
# -------------------------------------------------------------------- |
| 368 |
# admin admin |
| 369 |
# user1 operator |
| 370 |
# user2 netadmin |
| 371 |
|
| 372 |
- name: Configure user sshkey |
| 373 |
dellemc.enterprise_sonic.sonic_users: |
| 374 |
config: |
| 375 |
- name: user1 |
| 376 |
ssh_key: > |
| 377 |
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCoCc6lPgrSAXZByJAPH6cwn0Mhj9J1zYUfiLc |
| 378 |
/iz/IwHt/7s++bN1tnL6bAan6Ssg4XvOF0mcP5K53AAP+bX5WHy/d1wm7icllBI0JT150qp9nY5y |
| 379 |
bjNdvLH11cxqc+mmNYa7d40fpeoUgMdSBGtSL0jY2PHHRCvVscFYjSm6tQQ== root@sonic |
| 380 |
state: merged |
| 381 |
|
| 382 |
# After state: |
| 383 |
# ------------ |
| 384 |
# |
| 385 |
# sonic# show users configured |
| 386 |
# ---------------------------------------------------------------------- |
| 387 |
# sonic# show users sshKey |
| 388 |
# User: user1 |
| 389 |
# SSH Key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCoCc6lPgrSAXZByJAPH6cwn0Mhj9J1zYUfiLc/iz/IwHt/7s |
| 390 |
# ++bN1tnL6bAan6Ssg4XvOF0mcP5K53AAP+bX5WHy/d1wm7icllBI0JT150qp9nY5ybjNdvLH11cxqc+mmNYa7d |
| 391 |
# 40fpeoUgMdSBGtSL0jY2PHHRCvVscFYjSm6tQQ== root@sonic |
| 392 |
# ---------------------------------------------------------------------- |
| 393 |
|
| 394 |
# Using Deleted |
| 395 |
# |
| 396 |
# Before state: |
| 397 |
# ------------- |
| 398 |
# |
| 399 |
# sonic# show users sshKey |
| 400 |
# User: user1 |
| 401 |
# SSH Key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDHD2TJqQ/Fve+fG5i6heOJH55wgbEf+7kTtUGBUtNttQ9OXgBRr |
| 402 |
# A2h2GKSyUNlyfaVijBrcr2MKwhSASvk58WnEqZhfmmhRDsdNVXPlMQuDBheIlCaXyOh+URJZCfmfeERSVO7kjRhqM |
| 403 |
# mbHlpTbMDHdFgYEvHGcrHMwIZyZ6KbBw== root@sonic |
| 404 |
# ---------------------------------------------------------------------- |
| 405 |
|
| 406 |
- name: Delete sshkey for existing users |
| 407 |
dellemc.enterprise_sonic.sonic_users: |
| 408 |
config: |
| 409 |
- name: user1 |
| 410 |
ssh_key: |
| 411 |
state: deleted |
| 412 |
|
| 413 |
# After state: |
| 414 |
# ------------ |
| 415 |
# |
| 416 |
# sonic# show users sshkey |
| 417 |
# ---------------------------------------------------------------------- |
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
Return Values |
| 422 |
------------- |
| 423 |
Common return values are documented `here <https://docs.ansible.com/projects/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: |
| 424 |
|
| 425 |
.. raw:: html |
| 426 |
|
| 427 |
<table border=0 cellpadding=0 class="documentation-table"> |
| 428 |
<tr> |
| 429 |
<th colspan="1">Key</th> |
| 430 |
<th>Returned</th> |
| 431 |
<th width="100%">Description</th> |
| 432 |
</tr> |
| 433 |
<tr> |
| 434 |
<td colspan="1"> |
| 435 |
<div class="ansibleOptionAnchor" id="return-"></div> |
| 436 |
<b>after</b> |
| 437 |
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> |
| 438 |
<div style="font-size: small"> |
| 439 |
<span style="color: purple">list</span> |
| 440 |
</div> |
| 441 |
</td> |
| 442 |
<td>when changed</td> |
| 443 |
<td> |
| 444 |
<div>The resulting configuration module invocation.</div> |
| 445 |
<br/> |
| 446 |
<div style="font-size: smaller"><b>Sample:</b></div> |
| 447 |
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format as the parameters above.</div> |
| 448 |
</td> |
| 449 |
</tr> |
| 450 |
<tr> |
| 451 |
<td colspan="1"> |
| 452 |
<div class="ansibleOptionAnchor" id="return-"></div> |
| 453 |
<b>after_generated</b> |
| 454 |
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> |
| 455 |
<div style="font-size: small"> |
| 456 |
<span style="color: purple">list</span> |
| 457 |
</div> |
| 458 |
</td> |
| 459 |
<td>when <code>check_mode</code></td> |
| 460 |
<td> |
| 461 |
<div>The generated configuration module invocation.</div> |
| 462 |
<br/> |
| 463 |
<div style="font-size: smaller"><b>Sample:</b></div> |
| 464 |
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format as the parameters above.</div> |
| 465 |
</td> |
| 466 |
</tr> |
| 467 |
<tr> |
| 468 |
<td colspan="1"> |
| 469 |
<div class="ansibleOptionAnchor" id="return-"></div> |
| 470 |
<b>before</b> |
| 471 |
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> |
| 472 |
<div style="font-size: small"> |
| 473 |
<span style="color: purple">list</span> |
| 474 |
</div> |
| 475 |
</td> |
| 476 |
<td>always</td> |
| 477 |
<td> |
| 478 |
<div>The configuration prior to the module invocation.</div> |
| 479 |
<br/> |
| 480 |
<div style="font-size: smaller"><b>Sample:</b></div> |
| 481 |
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format as the parameters above.</div> |
| 482 |
</td> |
| 483 |
</tr> |
| 484 |
<tr> |
| 485 |
<td colspan="1"> |
| 486 |
<div class="ansibleOptionAnchor" id="return-"></div> |
| 487 |
<b>commands</b> |
| 488 |
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> |
| 489 |
<div style="font-size: small"> |
| 490 |
<span style="color: purple">list</span> |
| 491 |
</div> |
| 492 |
</td> |
| 493 |
<td>always</td> |
| 494 |
<td> |
| 495 |
<div>The set of commands pushed to the remote device.</div> |
| 496 |
<br/> |
| 497 |
<div style="font-size: smaller"><b>Sample:</b></div> |
| 498 |
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['command 1', 'command 2', 'command 3']</div> |
| 499 |
</td> |
| 500 |
</tr> |
| 501 |
</table> |
| 502 |
<br/><br/> |
| 503 |
|
| 504 |
|
| 505 |
Status |
| 506 |
------ |
| 507 |
|
| 508 |
|
| 509 |
Authors |
| 510 |
~~~~~~~ |
| 511 |
|
| 512 |
- Niraimadaiselvam M (@niraimadaiselvamm) |