saltstack / saltstack/salt

Is pillar_ldap external module is broken in 3001 ?

Open
#58,760 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug python3 severity-medium
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description of Issue

Hello, I've just upgraded a syndic from version 2018.3.4 to 3001 and it seems that external ldap pillar module /usr/lib/python3/dist-packages/salt/pillar/pillar_ldap.py is not working anymore. The only LDAP module which exists for python3 is python3-ldap3 which is not loadable through "import ldap" code bellow :

134 # Import salt libs
135 import salt.utils.data
136 from salt.exceptions import SaltInvocationError
137
138 try:
**139     import ldap  # pylint: disable=W0611**
140
141     HAS_LDAP = True
142 except ImportError:
143     HAS_LDAP = False
Setup

Install salt master version 3001, python3-ldap3 package and configure it like this :

[root@hostname pillar]# cat /etc/salt/master.d/pillars.conf
ext_pillar:
  - pillar_ldap: /etc/salt/master.d/pillar_ldap.yaml

[root@hostname pillar]# cat /etc/salt/master.d/pillar_ldap.yaml
salt-groups:
  server: ldaphost.domain.tld
  port: 389
  tls: false
  dn: 'ou=group,dc=unix,,dc=fr'
  referrals: false
  anonymous: true
  mode: map
  filter: 'objectclass=posixgroup'
  attrs:
    - cn
    - gidNumber

search_order:
  - salt-groups

Restart salt master, logs like thoose appears :
2020-10-19 15:51:01,266 [salt.utils.lazy :106 ][DEBUG ][27269] Could not LazyLoad pillar_ldap.ext_pillar: 'pillar_ldap' __virtual__ returned False

due to this :

#  python3
Python 3.5.2 (default, Jul 17 2020, 14:04:10)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ldap
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'ldap'
>>> import ldap3
>>>
Steps to Reproduce Issue

$ salt-call pillar.get salt-groups
$

Versions Report
# salt --versions-report
Salt Version:
           Salt: 3001

Dependency Versions:
           cffi: 1.5.2
       cherrypy: 3.5.0
       dateutil: 2.4.2
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
         Jinja2: 2.8
        libgit2: 0.24.0
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.6.2
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: Not Installed
   pycryptodome: 3.4.7
         pygit2: 0.24.0
         Python: 3.5.2 (default, Jul 17 2020, 14:04:10)
   python-gnupg: 0.3.8
         PyYAML: 3.11
          PyZMQ: 17.1.2
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.1.4

System Versions:
           dist: ubuntu 16.04 Xenial Xerus
         locale: UTF-8
        machine: x86_64
        release: 4.4.0-190-generic
         system: Linux
        version: Ubuntu 16.04 Xenial Xerus


Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with /usr/lib/python3/dist-packages/salt/pillar/pillar_ldap.py, especially its import and virtual handling, then reproduce the failure with the supplied pillar_ldap.yaml and salt-call pillar.get salt-groups. Done means the external pillar loads with the reported Python 3 LDAP dependency and returns the configured group data instead of reporting that virtual returned False.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.