%PDF- %PDF-
| Direktori : /proc/self/root/proc/thread-self/root/lib/python2.7/site-packages/salt/pillar/ |
| Current File : //proc/self/root/proc/thread-self/root/lib/python2.7/site-packages/salt/pillar/pillar_ldap.pyc |
�
���^c @@ s� d Z d d l m Z m Z m Z d d l Z d d l Z d d l Z d d l m
Z
d d l Z y d d l Z e
Z Wn e k
r� e Z n Xe j e � Z d � Z d � Z d d � Z d � Z d � Z d
� Z d S( uP
Use LDAP data as a Pillar source
This pillar module executes a series of LDAP searches.
Data returned by these searches are aggregated, whereby data returned by later
searches override data by previous searches with the same key.
The final result is merged with existing pillar data.
The configuration of this external pillar module is done via an external
file which provides the actual configuration for the LDAP searches.
===============================
Configuring the LDAP ext_pillar
===============================
The basic configuration is part of the `master configuration
<master-configuration-ext-pillar>`_.
.. code-block:: yaml
ext_pillar:
- pillar_ldap: /etc/salt/master.d/pillar_ldap.yaml
.. note::
When placing the file in the ``master.d`` directory, make sure its name
doesn't end in ``.conf``, otherwise the salt-master process will attempt
to parse its content.
.. warning::
Make sure this file has very restrictive permissions, as it will contain
possibly sensitive LDAP credentials!
The only required key in the master configuration is ``pillar_ldap`` pointing
to a file containing the actual configuration.
Configuring the LDAP searches
=============================
The file is processed using `Salt's Renderers <renderers>` which makes it
possible to reference grains within the configuration.
.. warning::
When using Jinja in this file, make sure to do it in a way which prevents
leaking sensitive information. A rogue minion could send arbitrary grains
to trick the master into returning secret data.
Use only the 'id' grain which is verified through the minion's key/cert.
Map Mode
--------
The ``it-admins`` configuration below returns the Pillar ``it-admins`` by:
- filtering for:
- members of the group ``it-admins``
- objects with ``objectclass=user``
- returning the data of users, where each user is a dictionary containing the
configured string or list attributes.
Configuration
*************
.. code-block:: yaml
salt-users:
server: ldap.company.tld
port: 389
tls: true
dn: 'dc=company,dc=tld'
binddn: 'cn=salt-pillars,ou=users,dc=company,dc=tld'
bindpw: bi7ieBai5Ano
referrals: false
anonymous: false
mode: map
dn: 'ou=users,dc=company,dc=tld'
filter: '(&(memberof=cn=it-admins,ou=groups,dc=company,dc=tld)(objectclass=user))'
attrs:
- cn
- displayName
- givenName
- sn
lists:
- memberOf
search_order:
- salt-users
Result
******
.. code-block:: python
{
'salt-users': [
{
'cn': 'cn=johndoe,ou=users,dc=company,dc=tld',
'displayName': 'John Doe'
'givenName': 'John'
'sn': 'Doe'
'memberOf': [
'cn=it-admins,ou=groups,dc=company,dc=tld',
'cn=team01,ou=groups,dc=company'
]
},
{
'cn': 'cn=janedoe,ou=users,dc=company,dc=tld',
'displayName': 'Jane Doe',
'givenName': 'Jane',
'sn': 'Doe',
'memberOf': [
'cn=it-admins,ou=groups,dc=company,dc=tld',
'cn=team02,ou=groups,dc=company'
]
}
]
}
i ( t absolute_importt print_functiont unicode_literalsN( t SaltInvocationErrorc C@ s t r
d St Sd S( u1
Only return if ldap module is installed
u pillar_ldapN( t HAS_LDAPt False( ( ( s; /usr/lib/python2.7/site-packages/salt/pillar/pillar_ldap.pyt __virtual__� s c C@ sO t j j | � \ } } t j d t j | � � } | j | � } | j t � S( uB
Render config template, substituting grains where found.
t loader( t ost patht splitt jinja2t Environmentt FileSystemLoadert get_templatet rendert
__grains__( t config_filet dirnamet filenamet envt template( ( s; /usr/lib/python2.7/site-packages/salt/pillar/pillar_ldap.pyt _render_template� s c C@ sA y | | } Wn t k
r'