Skip to content

Instantly share code, notes, and snippets.

@Akasurde
Created June 7, 2018 11:40
Show Gist options
  • Save Akasurde/4fd67358b3f21934e51df854c7f24e64 to your computer and use it in GitHub Desktop.
Save Akasurde/4fd67358b3f21934e51df854c7f24e64 to your computer and use it in GitHub Desktop.
Ldap_attr
[root@qeos-39 ~]# ldapsearch -x -D "cn=Directory Manager" -h localhost -p 38901 -b "uid=testuser,ou=People,dc=example,dc=com" -w password
# extended LDIF
#
# LDAPv3
# base <uid=testuser,ou=People,dc=example,dc=com> with scope subtree
# filter: (objectclass=*)
# requesting: ALL
#
# testuser, People, example.com
dn: uid=testuser,ou=People,dc=example,dc=com
objectClass: top
objectClass: account
objectClass: posixaccount
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: nsMemberOf
objectClass: person
uid: testuser
cn: testuser
sn: test
uidNumber: 1000
gidNumber: 2000
homeDirectory: /home/testuser
# search result
search: 2
result: 0 Success
# numResponses: 2
# numEntries: 1
[root@qeos-39 ~]# vim ldap.yml
[root@qeos-39 ~]# ansible-playbook ldap.yml -vvv
ansible-playbook 2.5.4
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/ansible
executable location = /opt/rh/rh-python36/root/usr/bin/ansible-playbook
python version = 3.6.3 (default, Oct 5 2017, 20:27:50) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]
No config file found; using defaults
[WARNING]: Unable to parse /etc/ansible/hosts as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAYBOOK: ldap.yml *************************************************************************************************************
1 plays in ldap.yml
PLAY [LDAP] ********************************************************************************************************************
META: ran handlers
TASK [ldap_attr] ***************************************************************************************************************
task path: /root/ldap.yml:6
Using module file /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/ansible/modules/net_tools/ldap/ldap_attr.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c 'echo ~root && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1528370581.6122127-219873984689978 `" && echo ansible-tmp-1528370581.6122127-219873984689978="` echo /root/.ansible/tmp/ansible-tmp-1528370581.6122127-219873984689978 `" ) && sleep 0'
<127.0.0.1> PUT /root/.ansible/tmp/ansible-local-1244537kurun6/tmp66401ulz TO /root/.ansible/tmp/ansible-tmp-1528370581.6122127-219873984689978/ldap_attr.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1528370581.6122127-219873984689978/ /root/.ansible/tmp/ansible-tmp-1528370581.6122127-219873984689978/ldap_attr.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/opt/rh/rh-python36/root/usr/bin/python3 /root/.ansible/tmp/ansible-tmp-1528370581.6122127-219873984689978/ldap_attr.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1528370581.6122127-219873984689978/ > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
"changed": true,
"invocation": {
"module_args": {
"bind_dn": "cn=Directory Manager",
"bind_pw": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"dn": "uid=testuser,ou=People,dc=example,dc=com",
"name": "sn",
"params": null,
"server_uri": "ldap://localhost:38901",
"start_tls": false,
"state": "exact",
"validate_certs": false,
"values": "test_is_test"
}
},
"modlist": [
[
2,
"sn",
[
"test_is_test"
]
]
]
}
META: ran handlers
META: ran handlers
PLAY RECAP *********************************************************************************************************************
localhost : ok=1 changed=1 unreachable=0 failed=0
[root@qeos-39 ~]# ldapsearch -x -D "cn=Directory Manager" -h localhost -p 38901 -b "uid=testuser,ou=People,dc=example,dc=com" -w password
# extended LDIF
#
# LDAPv3
# base <uid=testuser,ou=People,dc=example,dc=com> with scope subtree
# filter: (objectclass=*)
# requesting: ALL
#
# testuser, People, example.com
dn: uid=testuser,ou=People,dc=example,dc=com
objectClass: top
objectClass: account
objectClass: posixaccount
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: nsMemberOf
objectClass: person
uid: testuser
cn: testuser
sn: test_is_test
uidNumber: 1000
gidNumber: 2000
homeDirectory: /home/testuser
# search result
search: 2
result: 0 Success
# numResponses: 2
# numEntries: 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment