salt icon indicating copy to clipboard operation
salt copied to clipboard

[BUG] ldap.managed state KeyError: 'ldap3.connect'

Open SimBou opened this issue 1 year ago • 4 comments

Description After upgrade of salt-minion from 3005.5-1 to 3005.5-2, state ldap.managed fails with KeyError: 'ldap3.connect'

Setup salt-master 3005.5 salt-minion 3005.5 salt-minion-3005.5-2.el7.x86_64

Steps to Reproduce the behavior salt <my_minion> state.highstate

      ID: state-dirsrv-tls
Function: ldap.managed
  Result: False
 Comment: An exception occurred in this state: Traceback (most recent call last):
            File "salt/state.py", line 2276, in call
              ret = self.states[cdata["full"]](
            File "salt/loader/lazy.py", line 149, in __call__
              return self.loader.run(run_func, *args, **kwargs)
            File "salt/loader/lazy.py", line 1228, in run
              return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
            File "salt/loader/lazy.py", line 1243, in _run_as
              return _func_or_method(*args, **kwargs)
            File "salt/loader/lazy.py", line 1276, in wrapper
              return f(*args, **kwargs)
            File "/opt/saltstack/salt/run/salt/states/ldap.py", line 249, in managed
              connect = __salt__["ldap3.connect"]
            File "salt/loader/context.py", line 78, in __getitem__
              return self.value()[item]
            File "salt/loader/lazy.py", line 336, in __getitem__
              super().__getitem__(item)  # try to get the item from the dictionary
            File "salt/utils/lazy.py", line 100, in __getitem__
              return self._dict[key]
          KeyError: 'ldap3.connect'
 Started: 17:22:40.210579
Duration: 11.396 ms

Versions Report

salt --versions-report Salt Version: Salt: 3005.5

Dependency Versions: cffi: 1.14.3 cherrypy: unknown dateutil: 2.7.5 docker-py: Not Installed gitdb: Not Installed gitpython: Not Installed Jinja2: 2.10.1 libgit2: Not Installed M2Crypto: 0.35.2 Mako: Not Installed msgpack: 0.6.2 msgpack-pure: Not Installed mysql-python: Not Installed pycparser: 2.14 pycrypto: Not Installed pycryptodome: Not Installed pygit2: Not Installed Python: 3.6.8 (default, Jan 16 2024, 02:08:59) python-gnupg: 0.4.6 PyYAML: 5.4.1 PyZMQ: 20.0.0 smmap: Not Installed timelib: Not Installed Tornado: 4.5.3 ZMQ: 4.3.4

System Versions: dist: oracle 8.9 locale: UTF-8 machine: x86_64 release: 4.18.0-513.11.0.1.el8_9.x86_64 system: Linux version: Oracle Linux Server 8.9

state-dirsrv-tls:
  ldap.managed:
    - connect_spec:
        url: ldap://127.0.0.1:389/
        bind:
          method: simple
          dn: cn=Directory Manager
          password: xxxxxxxx
    - entries:
      # TLS settings
      - cn=encryption,cn=config:
        - replace:
            sslVersionMin: TLS1.2

SimBou avatar May 02 '24 16:05 SimBou

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey. Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar. If you have additional questions, email us at [email protected]. We’re glad you’ve joined our community and look forward to doing awesome things with you!

welcome[bot] avatar May 02 '24 16:05 welcome[bot]

I am getting the same error.

          Salt: 3007.1

Python Version:
        Python: 3.10.14 (main, Apr  3 2024, 21:30:09) [GCC 11.2.0]

Dependency Versions:
          cffi: 1.16.0
      cherrypy: unknown
      dateutil: 2.8.2
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.4
       libgit2: Not Installed
  looseversion: 1.3.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.7
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 23.1
     pycparser: 2.21
      pycrypto: Not Installed
  pycryptodome: 3.19.1
        pygit2: Not Installed
  python-gnupg: 0.5.2
        PyYAML: 6.0.1
         PyZMQ: 25.1.2
        relenv: 0.16.0
         smmap: Not Installed
       timelib: 0.3.0
       Tornado: 6.3.3
           ZMQ: 4.3.4

Salt Package Information:
  Package Type: onedir

System Versions:
          dist: rocky 8.9 Green Obsidian
        locale: utf-8
       machine: x86_64
       release: 4.18.0-513.24.1.el8_9.x86_64
        system: Linux
       version: Rocky Linux 8.9 Green Obsidian```

bchill avatar May 28 '24 19:05 bchill

Dupe of https://github.com/saltstack/salt/issues/64962

zleite avatar May 31 '24 00:05 zleite

Dupe of #64962

This is not a dupe. They may be related in some high-level way, but this is not the same error that https://github.com/saltstack/salt/issues/64962 addresses.

bchill avatar Jun 21 '24 06:06 bchill

I sorted this out:

It turns out that the only module that needs to be added with salt-pip is python-ldap. The ldap3 and gssapi modules are not needed.

Special note for Salt 3007.1, salt-pip must be downgraded to be able to successfully add python-ldap:

# salt-pip install pip==22.3.1

It seems odd that this module needs to be specifically added when the ldap3 module is already included.

If it is ok with @SimBou, this report can be closed.

bchill avatar Aug 05 '24 08:08 bchill