| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
""" |
| 8 |
The module file for sonic_ldap |
| 9 |
""" |
| 10 |
|
| 11 |
from __future__ import absolute_import, division, print_function |
| 12 |
__metaclass__ = type |
| 13 |
|
| 14 |
|
| 15 |
DOCUMENTATION = """ |
| 16 |
--- |
| 17 |
module: sonic_ldap |
| 18 |
author: 'Santhosh Kumar T(@santhosh-kt)' |
| 19 |
version_added: '2.5.0' |
| 20 |
notes: |
| 21 |
- Supports C(check_mode). |
| 22 |
short_description: Configure global LDAP server settings on SONiC. |
| 23 |
description: |
| 24 |
- This module provides configuration management of global LDAP server parameters on devices running SONiC. |
| 25 |
- Configure VRF instance before configuring VRF to be used for LDAP server connection. |
| 26 |
options: |
| 27 |
config: |
| 28 |
description: |
| 29 |
- Specifies the LDAP server related configuration. |
| 30 |
type: list |
| 31 |
elements: dict |
| 32 |
suboptions: |
| 33 |
name: |
| 34 |
description: |
| 35 |
- Specifies the LDAP type. |
| 36 |
type: str |
| 37 |
choices: |
| 38 |
- global |
| 39 |
- nss |
| 40 |
- pam |
| 41 |
- sudo |
| 42 |
required: true |
| 43 |
base: |
| 44 |
description: |
| 45 |
- Configure base distinguished name. |
| 46 |
type: str |
| 47 |
bind_timelimit: |
| 48 |
description: |
| 49 |
- Configure connect time limit (0 to 65535). |
| 50 |
type: int |
| 51 |
binddn: |
| 52 |
description: |
| 53 |
- Configure distinguished name to bind. |
| 54 |
type: str |
| 55 |
bindpw: |
| 56 |
description: |
| 57 |
- Configure credentials to bind |
| 58 |
type: dict |
| 59 |
suboptions: |
| 60 |
pwd: |
| 61 |
description: |
| 62 |
- Authentication password for the bind. |
| 63 |
type: str |
| 64 |
required: true |
| 65 |
encrypted: |
| 66 |
description: |
| 67 |
- Indicates whether the password is encrypted text. |
| 68 |
type: bool |
| 69 |
servers: |
| 70 |
description: |
| 71 |
- Configure host name or IP address for a LDAP server. |
| 72 |
- Applicable only for global. |
| 73 |
type: list |
| 74 |
elements: dict |
| 75 |
suboptions: |
| 76 |
address: |
| 77 |
description: |
| 78 |
- Hostname or IP address of LDAP server. |
| 79 |
type: str |
| 80 |
required: true |
| 81 |
port: |
| 82 |
description: |
| 83 |
- Configure server port number (1 to 65535). |
| 84 |
type: int |
| 85 |
priority: |
| 86 |
description: |
| 87 |
- Configure priority (1 to 99). |
| 88 |
type: int |
| 89 |
retry: |
| 90 |
description: |
| 91 |
- Configure retransmit attempt (0 to 10). |
| 92 |
type: int |
| 93 |
ssl: |
| 94 |
description: |
| 95 |
- Configure TLS configuration. |
| 96 |
type: str |
| 97 |
choices: |
| 98 |
- "on" |
| 99 |
- "off" |
| 100 |
- "start_tls" |
| 101 |
server_type: |
| 102 |
description: |
| 103 |
- Configure server type. |
| 104 |
type: str |
| 105 |
choices: |
| 106 |
- all |
| 107 |
- nss |
| 108 |
- sudo |
| 109 |
- pam |
| 110 |
- nss_sudo |
| 111 |
- nss_pam |
| 112 |
- sudo_pam |
| 113 |
idle_timelimit: |
| 114 |
description: |
| 115 |
- Configure NSS idle time limit (0 to 65535). |
| 116 |
- Applicable only for global and nss. |
| 117 |
type: int |
| 118 |
map: |
| 119 |
description: |
| 120 |
- Configure LDAP server for map. |
| 121 |
- Applicable only for global. |
| 122 |
type: dict |
| 123 |
suboptions: |
| 124 |
attribute: |
| 125 |
description: |
| 126 |
- Configure attribute map. |
| 127 |
- I(from) and I(to) are required together. |
| 128 |
type: list |
| 129 |
elements: dict |
| 130 |
suboptions: |
| 131 |
from: |
| 132 |
description: |
| 133 |
- Configure attribute map key. |
| 134 |
type: str |
| 135 |
to: |
| 136 |
description: |
| 137 |
- Configure attribute map value. |
| 138 |
type: str |
| 139 |
default_attribute: |
| 140 |
description: |
| 141 |
- Configure default attribute map. |
| 142 |
- I(from) and I(to) are required together. |
| 143 |
type: list |
| 144 |
elements: dict |
| 145 |
suboptions: |
| 146 |
from: |
| 147 |
description: |
| 148 |
- Configure default attribute map key. |
| 149 |
type: str |
| 150 |
to: |
| 151 |
description: |
| 152 |
- Configure default attribute map value. |
| 153 |
type: str |
| 154 |
map_remote_groups_to_sonic_roles: |
| 155 |
description: |
| 156 |
- Configure mapping for remote groups to sonic roles. |
| 157 |
- I(remote_group) and I(sonic_roles) are required together. |
| 158 |
type: list |
| 159 |
elements: dict |
| 160 |
suboptions: |
| 161 |
remote_group: |
| 162 |
description: |
| 163 |
- Map remote groups to SONiC roles. |
| 164 |
type: str |
| 165 |
sonic_roles: |
| 166 |
description: |
| 167 |
- Configure SONiC roles. |
| 168 |
type: list |
| 169 |
elements: str |
| 170 |
choices: |
| 171 |
- admin |
| 172 |
- operator |
| 173 |
- netadmin |
| 174 |
- secadmin |
| 175 |
objectclass: |
| 176 |
description: |
| 177 |
- Configure Objectclass map. |
| 178 |
- I(from) and I(to) are required together. |
| 179 |
type: list |
| 180 |
elements: dict |
| 181 |
suboptions: |
| 182 |
from: |
| 183 |
description: |
| 184 |
- Configure Objectclass map key. |
| 185 |
type: str |
| 186 |
to: |
| 187 |
description: |
| 188 |
- Configure Objectclass map value. |
| 189 |
type: str |
| 190 |
override_attribute: |
| 191 |
description: |
| 192 |
- Configure override attribute map. |
| 193 |
- I(from) and I(to) are required together. |
| 194 |
type: list |
| 195 |
elements: dict |
| 196 |
suboptions: |
| 197 |
from: |
| 198 |
description: |
| 199 |
- Configure override attribute map key. |
| 200 |
type: str |
| 201 |
to: |
| 202 |
description: |
| 203 |
- Configure override attribute map value. |
| 204 |
type: str |
| 205 |
nss_base_group: |
| 206 |
description: |
| 207 |
- Configure NSS search base for group map. |
| 208 |
- Applicable only for global and nss. |
| 209 |
type: str |
| 210 |
nss_base_netgroup: |
| 211 |
description: |
| 212 |
- Configure NSS search base for netgroup map. |
| 213 |
- Applicable only for global and nss. |
| 214 |
type: str |
| 215 |
nss_base_passwd: |
| 216 |
description: |
| 217 |
- Configure NSS search base for passwd map. |
| 218 |
- Applicable only for global, nss and pam. |
| 219 |
type: str |
| 220 |
nss_base_shadow: |
| 221 |
description: |
| 222 |
- Configure NSS search base for shadow map. |
| 223 |
- Applicable only for global and nss. |
| 224 |
type: str |
| 225 |
nss_base_sudoers: |
| 226 |
description: |
| 227 |
- Configure NSS search base for sudoers map. |
| 228 |
- Applicable only for global and nss. |
| 229 |
type: str |
| 230 |
nss_initgroups_ignoreusers: |
| 231 |
description: |
| 232 |
- Configure NSS init groups ignore users. |
| 233 |
- Applicable only for global and nss. |
| 234 |
type: str |
| 235 |
nss_skipmembers: |
| 236 |
description: |
| 237 |
- Configure NSS skipmembers |
| 238 |
type: bool |
| 239 |
pam_filter: |
| 240 |
description: |
| 241 |
- Configure PAM filter. |
| 242 |
- Applicable only for global and pam. |
| 243 |
type: str |
| 244 |
pam_group_dn: |
| 245 |
description: |
| 246 |
- Configure PAM Group Distinguished name. |
| 247 |
- Applicable only for global and pam. |
| 248 |
type: str |
| 249 |
pam_login_attribute: |
| 250 |
description: |
| 251 |
- Configure PAM Login attribute. |
| 252 |
- Applicable only for global and pam. |
| 253 |
type: str |
| 254 |
pam_member_attribute: |
| 255 |
description: |
| 256 |
- Configure PAM Member attribute. |
| 257 |
- Applicable only for global and pam. |
| 258 |
type: str |
| 259 |
port: |
| 260 |
description: |
| 261 |
- Configure server port (1 to 65535). |
| 262 |
type: int |
| 263 |
retry: |
| 264 |
description: |
| 265 |
- Configure retransmit attempt (0 to 10). |
| 266 |
type: int |
| 267 |
scope: |
| 268 |
description: |
| 269 |
- Configure the search scope. |
| 270 |
- Applicable only for global, nss and pam. |
| 271 |
type: str |
| 272 |
choices: |
| 273 |
- sub |
| 274 |
- one |
| 275 |
- base |
| 276 |
source_interface: |
| 277 |
description: |
| 278 |
- Configure source interface to be used as source IP for the LDAP packets. |
| 279 |
- Applicable only for global. |
| 280 |
- Full name of the Layer 3 interface, i.e. Eth1/1. |
| 281 |
type: str |
| 282 |
security_profile: |
| 283 |
description: |
| 284 |
- Configure security profile for LDAP. |
| 285 |
- Applicable only for global. |
| 286 |
type: str |
| 287 |
ssl: |
| 288 |
description: |
| 289 |
- Configure TLS configuration. |
| 290 |
type: str |
| 291 |
choices: |
| 292 |
- "on" |
| 293 |
- "off" |
| 294 |
- "start_tls" |
| 295 |
sudoers_base: |
| 296 |
description: |
| 297 |
- Configure sudo base distinguished name for queries. |
| 298 |
- Applicable only for global and sudo. |
| 299 |
type: str |
| 300 |
sudoers_search_filter: |
| 301 |
description: |
| 302 |
- Configure sudo search filter for queries. |
| 303 |
- Applicable only for global and sudo. |
| 304 |
type: str |
| 305 |
timelimit: |
| 306 |
description: |
| 307 |
- Configure search time limit (1 to 65535). |
| 308 |
type: int |
| 309 |
version: |
| 310 |
description: |
| 311 |
- Configure LDAP version 2 or 3. |
| 312 |
type: int |
| 313 |
choices: |
| 314 |
- 2 |
| 315 |
- 3 |
| 316 |
vrf: |
| 317 |
description: |
| 318 |
- Configure VRF to be used for LDAP server connection. |
| 319 |
- Applicable only for global. |
| 320 |
type: str |
| 321 |
state: |
| 322 |
description: |
| 323 |
- Specifies the operation to be performed on the LDAP server configured on the device. |
| 324 |
- In case of merged, the input configuration will be merged with the existing LDAP server configuration on the device. |
| 325 |
- In case of deleted, the existing LDAP server configuration will be removed from the device. |
| 326 |
- In case of overridden, all the existing LDAP server configuration will be deleted and the specified input configuration will be installed. |
| 327 |
- In case of replaced, the existing LDAP server configuration on the device will be replaced by the configuration in the playbook |
| 328 |
for each LDAP server group configured by the playbook. |
| 329 |
default: merged |
| 330 |
choices: ['merged', 'deleted', 'replaced', 'overridden'] |
| 331 |
type: str |
| 332 |
""" |
| 333 |
|
| 334 |
EXAMPLES = """ |
| 335 |
# Using "deleted" state |
| 336 |
# |
| 337 |
# Before state: |
| 338 |
# ------------- |
| 339 |
# |
| 340 |
# sonic# show running-configuration vrf Vrf_1 |
| 341 |
# ! |
| 342 |
# ip vrf Vrf_1 |
| 343 |
# sonic# show running-configuration | grep ldap |
| 344 |
# ldap-server port 389 |
| 345 |
# ldap-server version 2 |
| 346 |
# ldap-server nss-base-passwd password |
| 347 |
# ldap-server nss-initgroups-ignoreusers username1 |
| 348 |
# ldap-server nss scope sub |
| 349 |
# ldap-server nss timelimit 15 |
| 350 |
# ldap-server nss idle-timelimit 25 |
| 351 |
# ldap-server nss nss-base-group group1 |
| 352 |
# ldap-server nss nss-base-sudoers sudo1 |
| 353 |
# ldap-server pam base admin |
| 354 |
# ldap-server pam binddn CN=example.com |
| 355 |
# ldap-server pam pam-login-attribute loginattrstring |
| 356 |
# ldap-server sudo retry 10 |
| 357 |
# ldap-server sudo ssl start_tls |
| 358 |
# ldap-server sudo bind-timelimit 15 |
| 359 |
# ldap-server vrf Vrf_1 |
| 360 |
# ldap-server host 10.10.10.1 port 1550 priority 5 |
| 361 |
# ldap-server host 20.20.20.10 retry 1 |
| 362 |
# ldap-server host example.com priority 10 ssl off |
| 363 |
# ldap-server map default-attribute-value attr1 to attr2 |
| 364 |
# ldap-server map default-attribute-value attr3 to attr4 |
| 365 |
# ldap-server map objectclass attr1 to attr3 |
| 366 |
# sonic# |
| 367 |
|
| 368 |
- name: Delete the LDAP server configurations |
| 369 |
sonic_ldap: |
| 370 |
config: |
| 371 |
- name: "global" |
| 372 |
servers: |
| 373 |
- address: "example.com" |
| 374 |
vrf: "Vrf_1" |
| 375 |
- name: "nss" |
| 376 |
idle_timelimit: 25 |
| 377 |
scope: "sub" |
| 378 |
- name: "sudo" |
| 379 |
state: deleted |
| 380 |
|
| 381 |
# After state: |
| 382 |
# ------------ |
| 383 |
# |
| 384 |
# sonic# show running-configuration | grep ldap |
| 385 |
# ldap-server port 389 |
| 386 |
# ldap-server version 2 |
| 387 |
# ldap-server nss-base-passwd password |
| 388 |
# ldap-server nss-initgroups-ignoreusers username1 |
| 389 |
# ldap-server nss timelimit 15 |
| 390 |
# ldap-server nss nss-base-group group1 |
| 391 |
# ldap-server nss nss-base-sudoers sudo1 |
| 392 |
# ldap-server pam base admin |
| 393 |
# ldap-server pam binddn CN=example.com |
| 394 |
# ldap-server pam pam-login-attribute loginattrstring |
| 395 |
# ldap-server host 10.10.10.1 port 1550 priority 5 |
| 396 |
# ldap-server host 20.20.20.10 retry 1 |
| 397 |
# ldap-server map default-attribute-value attr1 to attr2 |
| 398 |
# ldap-server map default-attribute-value attr3 to attr4 |
| 399 |
# ldap-server map objectclass attr1 to attr3 |
| 400 |
# sonic# |
| 401 |
|
| 402 |
|
| 403 |
# Using "merged" state |
| 404 |
# |
| 405 |
# Before state: |
| 406 |
# ------------- |
| 407 |
# |
| 408 |
# sonic# show running-configuration vrf Vrf_1 |
| 409 |
# ! |
| 410 |
# ip vrf Vrf_1 |
| 411 |
# ! |
| 412 |
# sonic# show running-configuration | grep ldap |
| 413 |
# sonic# |
| 414 |
|
| 415 |
- name: Add the LDAP server configurations |
| 416 |
sonic_ldap: |
| 417 |
config: |
| 418 |
- name: "global" |
| 419 |
servers: |
| 420 |
- address: "example.com" |
| 421 |
priority: 10 |
| 422 |
ssl: "on" |
| 423 |
- address: "10.10.10.1" |
| 424 |
priority: 5 |
| 425 |
port: 1550 |
| 426 |
port: 389 |
| 427 |
version: 2 |
| 428 |
nss_base_passwd: password |
| 429 |
- name: "pam" |
| 430 |
base: "admin" |
| 431 |
binddn: "CN=example.com" |
| 432 |
pam_login_attribute: "loginattrstring" |
| 433 |
- name: "sudo" |
| 434 |
bind_timelimit: 20 |
| 435 |
retry: 10 |
| 436 |
state: merged |
| 437 |
|
| 438 |
# After state: |
| 439 |
# ------------ |
| 440 |
# |
| 441 |
# sonic# show running-configuration | grep ldap |
| 442 |
# ldap-server port 389 |
| 443 |
# ldap-server version 2 |
| 444 |
# ldap-server nss-base-passwd password |
| 445 |
# ldap-server pam base admin |
| 446 |
# ldap-server pam binddn CN=example.com |
| 447 |
# ldap-server pam pam-login-attribute loginattrstring |
| 448 |
# ldap-server sudo retry 10 |
| 449 |
# ldap-server sudo bind-timelimit 20 |
| 450 |
# ldap-server host 10.10.10.1 port 1550 priority 5 |
| 451 |
# ldap-server host example.com priority 10 ssl on |
| 452 |
# sonic# |
| 453 |
|
| 454 |
|
| 455 |
# Using "merged" state |
| 456 |
# |
| 457 |
# Before state: |
| 458 |
# ------------- |
| 459 |
# |
| 460 |
# sonic# show running-configuration vrf Vrf_1 |
| 461 |
# ! |
| 462 |
# ip vrf Vrf_1 |
| 463 |
# ! |
| 464 |
# sonic# show running-configuration | grep ldap |
| 465 |
# ldap-server port 389 |
| 466 |
# ldap-server version 2 |
| 467 |
# ldap-server nss-base-passwd password |
| 468 |
# ldap-server pam base admin |
| 469 |
# ldap-server pam binddn CN=example.com |
| 470 |
# ldap-server pam pam-login-attribute loginattrstring |
| 471 |
# ldap-server sudo retry 10 |
| 472 |
# ldap-server sudo bind-timelimit 20 |
| 473 |
# ldap-server host 10.10.10.1 port 1550 priority 5 |
| 474 |
# ldap-server host example.com priority 10 ssl on |
| 475 |
# sonic# |
| 476 |
|
| 477 |
- name: Add the LDAP server configurations |
| 478 |
sonic_ldap: |
| 479 |
config: |
| 480 |
- name: "global" |
| 481 |
servers: |
| 482 |
- address: "example.com" |
| 483 |
ssl: "off" |
| 484 |
- address: "20.20.20.10" |
| 485 |
retry: 1 |
| 486 |
nss_base_passwd: password |
| 487 |
pam_login_attribute: "globallogin" |
| 488 |
nss_initgroups_ignoreusers: "username1" |
| 489 |
vrf: "Vrf_1" |
| 490 |
map: |
| 491 |
default_attribute: |
| 492 |
- from: "attr1" |
| 493 |
to: "attr2" |
| 494 |
- from: "attr3" |
| 495 |
to: "attr4" |
| 496 |
objectclass: |
| 497 |
- from: "attr1" |
| 498 |
to: "attr3" |
| 499 |
map_remote_groups_to_sonic_roles: |
| 500 |
- remote_group: "group1" |
| 501 |
sonic_roles: |
| 502 |
- admin |
| 503 |
- operator |
| 504 |
- name: "nss" |
| 505 |
nss_base_netgroup: "group1" |
| 506 |
idle_timelimit: 25 |
| 507 |
timelimit: 15 |
| 508 |
scope: "sub" |
| 509 |
nss_base_sudoers: "sudo1" |
| 510 |
- name: "sudo" |
| 511 |
bind_timelimit: 15 |
| 512 |
ssl: "start_tls" |
| 513 |
state: merged |
| 514 |
|
| 515 |
# After state: |
| 516 |
# ------------ |
| 517 |
# |
| 518 |
# sonic# show running-configuration | grep ldap |
| 519 |
# ldap-server port 389 |
| 520 |
# ldap-server version 2 |
| 521 |
# ldap-server nss-base-passwd password |
| 522 |
# ldap-server pam-login-attribute globallogin |
| 523 |
# ldap-server nss-initgroups-ignoreusers username1 |
| 524 |
# ldap-server nss scope sub |
| 525 |
# ldap-server nss timelimit 15 |
| 526 |
# ldap-server nss idle-timelimit 25 |
| 527 |
# ldap-server nss nss-base-group group1 |
| 528 |
# ldap-server nss nss-base-sudoers sudo1 |
| 529 |
# ldap-server pam base admin |
| 530 |
# ldap-server pam binddn CN=example.com |
| 531 |
# ldap-server pam pam-login-attribute loginattrstring |
| 532 |
# ldap-server sudo retry 10 |
| 533 |
# ldap-server sudo ssl start_tls |
| 534 |
# ldap-server sudo bind-timelimit 15 |
| 535 |
# ldap-server vrf Vrf_1 |
| 536 |
# ldap-server host 10.10.10.1 port 1550 priority 5 |
| 537 |
# ldap-server host 20.20.20.10 retry 1 |
| 538 |
# ldap-server host example.com priority 10 ssl off |
| 539 |
# ldap-server map default-attribute-value attr1 to attr2 |
| 540 |
# ldap-server map default-attribute-value attr3 to attr4 |
| 541 |
# ldap-server map objectclass attr1 to attr3 |
| 542 |
# ldap-server map remote-groups-override-to-sonic-roles group1 to admin,operator |
| 543 |
# sonic# |
| 544 |
|
| 545 |
|
| 546 |
# Using "replaced" state |
| 547 |
# |
| 548 |
# Before state: |
| 549 |
# ------------- |
| 550 |
# |
| 551 |
# sonic# show running-configuration vrf Vrf_1 |
| 552 |
# ! |
| 553 |
# ip vrf Vrf_1 |
| 554 |
# sonic# show running-configuration | grep ldap |
| 555 |
# ldap-server port 389 |
| 556 |
# ldap-server version 2 |
| 557 |
# ldap-server nss-base-passwd password |
| 558 |
# ldap-server nss-initgroups-ignoreusers username1 |
| 559 |
# ldap-server nss idle-timelimit 25 |
| 560 |
# ldap-server nss nss-base-group group1 |
| 561 |
# ldap-server nss nss-base-sudoers sudo1 |
| 562 |
# ldap-server pam base admin |
| 563 |
# ldap-server pam binddn CN=example.com |
| 564 |
# ldap-server pam pam-login-attribute loginattrstring |
| 565 |
# ldap-server host 10.10.10.1 port 1550 priority 5 |
| 566 |
# ldap-server host 20.20.20.10 retry 1 |
| 567 |
# ldap-server map default-attribute-value attr1 to attr2 |
| 568 |
# ldap-server map default-attribute-value attr3 to attr4 |
| 569 |
# ldap-server map objectclass attr1 to attr3 |
| 570 |
# sonic# |
| 571 |
|
| 572 |
- name: Replace the LDAP server configurations |
| 573 |
sonic_ldap: |
| 574 |
config: |
| 575 |
- name: "nss" |
| 576 |
scope: "one" |
| 577 |
bindpw: |
| 578 |
pwd: "password" |
| 579 |
- name: "pam" |
| 580 |
version: 3 |
| 581 |
port: 2000 |
| 582 |
timelimit: 20 |
| 583 |
pam_group_dn: "DNAME" |
| 584 |
- name: "sudo" |
| 585 |
sudoers_search_filter: "filter1" |
| 586 |
base: "base_name" |
| 587 |
version: 3 |
| 588 |
state: replaced |
| 589 |
|
| 590 |
# After state: |
| 591 |
# ------------ |
| 592 |
# |
| 593 |
# sonic# show running-configuration | grep ldap |
| 594 |
# ldap-server port 389 |
| 595 |
# ldap-server version 2 |
| 596 |
# ldap-server nss scope one |
| 597 |
# ldap-server nss bindpw U2FsdGVkX1+t8PR9IIi+qjZpYoNwjmd78D1WDBdkLxs= encrypted |
| 598 |
# ldap-server pam version 3 |
| 599 |
# ldap-server pam port 2000 |
| 600 |
# ldap-server pam timelimit 20 |
| 601 |
# ldap-server pam pam-group-dn DNAME |
| 602 |
# ldap-server sudo version 3 |
| 603 |
# ldap-server sudo base base_name |
| 604 |
# ldap-server sudo sudoers-search-filter filter1 |
| 605 |
# ldap-server host 10.10.10.1 port 1550 priority 5 |
| 606 |
# ldap-server host 20.20.20.10 retry 1 |
| 607 |
# ldap-server map default-attribute-value attr1 to attr2 |
| 608 |
# ldap-server map default-attribute-value attr3 to attr4 |
| 609 |
# ldap-server map objectclass attr1 to attr3 |
| 610 |
# sonic# |
| 611 |
|
| 612 |
|
| 613 |
# Using "overridden" state |
| 614 |
# |
| 615 |
# Before state: |
| 616 |
# ------------- |
| 617 |
# |
| 618 |
# sonic# show running-configuration vrf Vrf_1 |
| 619 |
# ! |
| 620 |
# ip vrf Vrf_1 |
| 621 |
# sonic# show running-configuration | grep ldap |
| 622 |
# ldap-server port 389 |
| 623 |
# ldap-server version 2 |
| 624 |
# ldap-server nss scope one |
| 625 |
# ldap-server nss bindpw U2FsdGVkX1+t8PR9IIi+qjZpYoNwjmd78D1WDBdkLxs= encrypted |
| 626 |
# ldap-server pam version 3 |
| 627 |
# ldap-server pam port 2000 |
| 628 |
# ldap-server pam timelimit 20 |
| 629 |
# ldap-server pam pam-group-dn DNAME |
| 630 |
# ldap-server sudo version 3 |
| 631 |
# ldap-server sudo base base_name |
| 632 |
# ldap-server sudo sudoers-search-filter filter1 |
| 633 |
# ldap-server host 10.10.10.1 port 1550 priority 5 |
| 634 |
# ldap-server host 20.20.20.10 retry 1 |
| 635 |
# ldap-server map default-attribute-value attr1 to attr2 |
| 636 |
# ldap-server map default-attribute-value attr3 to attr4 |
| 637 |
# ldap-server map objectclass attr1 to attr3 |
| 638 |
# sonic# |
| 639 |
|
| 640 |
- name: Override the LDAP server configurations |
| 641 |
sonic_ldap: |
| 642 |
config: |
| 643 |
- name: "global" |
| 644 |
source_interface: "Eth1/1" |
| 645 |
security_profile: "default" |
| 646 |
vrf: "Vrf_1" |
| 647 |
servers: |
| 648 |
- address: "client.com" |
| 649 |
- address: "host.com" |
| 650 |
server_type: "sudo_pam" |
| 651 |
map: |
| 652 |
override_attribute: |
| 653 |
- from: "attr1" |
| 654 |
to: "attr2" |
| 655 |
map_remote_groups_to_sonic_roles: |
| 656 |
- remote_group: "group1" |
| 657 |
sonic_roles: |
| 658 |
- admin |
| 659 |
- operator |
| 660 |
idle_timelimit: 20 |
| 661 |
- name: "pam" |
| 662 |
ssl: "off" |
| 663 |
scope: "base" |
| 664 |
state: overridden |
| 665 |
|
| 666 |
# After state: |
| 667 |
# ------------ |
| 668 |
# |
| 669 |
# sonic# show running-configuration | grep ldap |
| 670 |
# ldap-server idle-timelimit 20 |
| 671 |
# ldap-server pam ssl off |
| 672 |
# ldap-server pam scope base |
| 673 |
# ldap-server source-interface Eth1/1 |
| 674 |
# ldap-server security-profile default |
| 675 |
# ldap-server vrf Vrf_1 |
| 676 |
# ldap-server host client.com |
| 677 |
# ldap-server host host.com use-type sudo_pam |
| 678 |
# ldap-server map override-attribute-value attr1 to attr2 |
| 679 |
# ldap-server map remote-groups-override-to-sonic-roles group1 to admin,operator |
| 680 |
# sonic# |
| 681 |
""" |
| 682 |
|
| 683 |
RETURN = """ |
| 684 |
before: |
| 685 |
description: The configuration prior to the module invocation. |
| 686 |
returned: always |
| 687 |
type: list |
| 688 |
sample: > |
| 689 |
The configuration returned will always be in the same format |
| 690 |
as the parameters above. |
| 691 |
after: |
| 692 |
description: The resulting configuration module invocation. |
| 693 |
returned: when changed |
| 694 |
type: list |
| 695 |
sample: > |
| 696 |
The configuration returned will always be in the same format |
| 697 |
as the parameters above. |
| 698 |
after_generated: |
| 699 |
description: The generated configuration module invocation. |
| 700 |
returned: when C(check_mode) |
| 701 |
type: list |
| 702 |
sample: > |
| 703 |
The configuration returned will always be in the same format |
| 704 |
as the parameters above. |
| 705 |
commands: |
| 706 |
description: The set of commands pushed to the remote device. |
| 707 |
returned: always |
| 708 |
type: list |
| 709 |
sample: ['command 1', 'command 2', 'command 3'] |
| 710 |
""" |
| 711 |
|
| 712 |
|
| 713 |
from ansible.module_utils.basic import AnsibleModule |
| 714 |
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.ldap.ldap import LdapArgs |
| 715 |
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.ldap.ldap import Ldap |
| 716 |
|
| 717 |
|
| 718 |
def main(): |
| 719 |
""" |
| 720 |
Main entry point for module execution |
| 721 |
|
| 722 |
:returns: the result from module invocation |
| 723 |
""" |
| 724 |
module = AnsibleModule(argument_spec=LdapArgs.argument_spec, |
| 725 |
supports_check_mode=True) |
| 726 |
|
| 727 |
result = Ldap(module).execute_module() |
| 728 |
module.exit_json(**result) |
| 729 |
|
| 730 |
|
| 731 |
if __name__ == '__main__': |
| 732 |
main() |