|
| 1 | +# {{ ansible_managed }} |
| 2 | +import ldap |
| 3 | +from django_auth_ldap.config import LDAPSearch, GroupOfNamesType |
| 4 | + |
| 5 | +""" |
| 6 | +Read the NetBox LDAP configuration documentation if you need assistance: |
| 7 | +http://netbox.readthedocs.io/en/latest/installation/ldap/ |
| 8 | +
|
| 9 | +This is just an example. Modify it to your liking and place it in your |
| 10 | +playbook's templates/ directory (or anywhere, but make sure |
| 11 | +"netbox_ldap_config_template" is configured to whatever location you place the |
| 12 | +template in should it not be in templates/. |
| 13 | +""" |
| 14 | + |
| 15 | +# Use variables like the below if you prefer: |
| 16 | +AUTH_LDAP_SERVER_URI = "{{ ldap_server_uri }}" |
| 17 | + |
| 18 | +# Or just store all your values in this file: |
| 19 | +AUTH_LDAP_BIND_DN = "CN=NETBOXSA, OU=Service Accounts,DC=example,DC=com" |
| 20 | +# I would however recommend putting passwords in vaulted variables. |
| 21 | +AUTH_LDAP_BIND_PASSWORD = "demo" |
| 22 | + |
| 23 | +AUTH_LDAP_CONNECTION_OPTIONS = { |
| 24 | + ldap.OPT_REFERRALS: 0 |
| 25 | +} |
| 26 | + |
| 27 | +LDAP_IGNORE_CERT_ERRORS = False |
| 28 | + |
| 29 | +AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=Users,dc=example,dc=com", |
| 30 | + ldap.SCOPE_SUBTREE, |
| 31 | + "(sAMAccountName=%(user)s)") |
| 32 | +AUTH_LDAP_USER_DN_TEMPLATE = "uid=%(user)s,ou=users,dc=example,dc=com" |
| 33 | +AUTH_LDAP_USER_ATTR_MAP = { |
| 34 | + "first_name": "givenName", |
| 35 | + "last_name": "sn" |
| 36 | +} |
| 37 | + |
| 38 | +AUTH_LDAP_GROUP_SEARCH = LDAPSearch("dc=example,dc=com", ldap.SCOPE_SUBTREE, |
| 39 | + "(objectClass=group)") |
| 40 | +AUTH_LDAP_GROUP_TYPE = GroupOfNamesType() |
| 41 | +AUTH_LDAP_REQUIRE_GROUP = "CN=NETBOX_USERS,DC=example,DC=com" |
| 42 | +AUTH_LDAP_USER_FLAGS_BY_GROUP = { |
| 43 | + "is_active": "cn=active,ou=groups,dc=example,dc=com", |
| 44 | + "is_staff": "cn=staff,ou=groups,dc=example,dc=com", |
| 45 | + "is_superuser": "cn=superuser,ou=groups,dc=example,dc=com" |
| 46 | +} |
| 47 | +AUTH_LDAP_FIND_GROUP_PERMS = True |
| 48 | +AUTH_LDAP_CACHE_GROUPS = True |
| 49 | +AUTH_LDAP_GROUP_CACHE_TIMEOUT = 3600 |
| 50 | + |
| 51 | +# vim: ft=python |
0 commit comments