简体   繁体   中英

Cannot use ldap_entry in ansible (Missing required 'ldap' module (pip install python-ldap))

I'm using ansible to update some OpenLdap database but without success. (it complains it does not have python-ldap module installed)

I have the following:

- name: Install dependencies
  apt: name="{{ item }}" state=present
  with_items:
    - python-pip
    - libsasl2-dev
    - libldap2-dev
    - libssl-dev

- name: Upgrade pip
  command: pip install --upgrade pip

- name: Install python-ldap
  command: pip install python-ldap

- name: Make sure we have a parent entry for users
  ldap_entry:
    dn: ou=Developers,dc=myCompany,dc=com
    objectClass: organizationalUnit
    server_uri: ldap://someIp/
    bind_dn: cn=admin,dc=myCompany,dc=com
    bind_pw: somePass

If I run pip freeze (on ansible defined hosts) it lists python-ldap==2.4.22 among the other modules, so the ldap python library is installed (I also created a sample py script where I imported ldap module and worked). I have no ideea why when ansible runs ldap_entry it fails to import python-ldap module.

TASK [openldap-add-users : Make sure we have a parent entry for users] *************************************************************************************************************************************
fatal: [someIp]: FAILED! => {"changed": false, "msg": "Missing required 'ldap' module (pip install python-ldap)."}

Looking at the ansible documentation for ldap_entry , it says:

The below requirements are needed on the host that executes this module.

python-ldap

If I am not mistaken, that means the module needs to be installed on the machine executing the playbook, not on the target machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM