1

I am running osx-mojave and I am trying to run ansible with the ldap-module.

However, when I try to run it like this

ansible-playbook play.yml

I get this error

PLAY [localhost] ************************************************************************************************************************************
TASK [Gathering Facts] ***************************************************************************
ok: [localhost]

TASK [create the account] ***************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Missing required 'ldap' module (pip install python-ldap)."}
    to retry, use: --limit @/Users/testuser/adtest/play.retry

PLAY RECAP ***************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1

I have searched similar questions on this site and I cant find a solution to this.

I have run

pip install python-ldap

and

sudo pip install python-ldap

This is the output

Requirement already satisfied: python-ldap in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (3.2.0) Requirement already satisfied: pyasn1>=0.3.7 in /Users/testuser/Library/Python/3.7/lib/python/site-packages (from python-ldap) (0.4.5) Requirement already satisfied: pyasn1-modules>=0.1.5 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from python-ldap) (0.2.5)

It doesn't solve the problem.

The output of pip freeze:

$ pip freeze 
awscli==1.16.132 
botocore==1.12.122 
colorama==0.3.9 
docutils==0.14 
jmespath==0.9.4 
ldap3==2.6 
pbr==5.2.1 
pyasn1==0.4.5 
pyasn1-modules==0.2.5 
python-dateutil==2.8.0 
python-ldap==3.2.0 
python3-ldap==0.9.8.4 
PyYAML==3.13 rsa==3.4.2 
s3transfer==0.2.0 
six==1.12.0 
stevedore==1.30.1 
urllib3==1.24.1 
virtualenv==16.6.0 
virtualenv-clone==0.5.3 
virtualenvwrapper==4.8.4

If anyone has a solution for this please let me know.

8
  • Added to the question - see output
    – RYU1
    Jul 9, 2019 at 19:37
  • What happens if you go into a python terminal and type import python-ldap? Jul 9, 2019 at 19:37
  • Is ansible executing python in a different virtual environment? Maybe that environment doesn't have the ldap package installed.
    – bigh_29
    Jul 9, 2019 at 19:44
  • Python 2.7.10 (default, Feb 22 2019, 21:55:15) [GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import python-ldap File "<stdin>", line 1 import python-ldap ^ SyntaxError: invalid syntax
    – RYU1
    Jul 9, 2019 at 19:49
  • Can you print the value of ansible_python_interpreter, or is if undefined? Jul 9, 2019 at 20:01

1 Answer 1

0

your computer might not recognize the command python or pip,

try looking up how to get your osx computer to recognize the pip or python command from the terminal.

sorry i'm not an osx guy sorry.

2
  • pip is working, and it shows that it installs the ldap module. python and python3 work also when I enter them on cmdline
    – RYU1
    Jul 9, 2019 at 19:32
  • try going into the command line and reinstalling the module if it is installed it will say "Requirement already satisfied"
    – Potoo
    Jul 9, 2019 at 20:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.