Created
April 12, 2017 20:46
-
-
Save asifiqbal/ca2a8a361a0dd730a27d91f2e1e70903 to your computer and use it in GitHub Desktop.
ansible to verify account againts ldap and then push as local account
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: localhost | |
roles: | |
- ldap | |
vars: | |
ldap_lookup_config: | |
url: ldaps://192.168.1.100 | |
base: ou=People,dc=com | |
binddn: uid=bind,dc=com | |
bindpw: secret | |
tls_reqcert: never | |
user_valid: | |
base: ou=People,dc=mnet,dc=qintra,dc=com | |
key: uid | |
value: cn | |
filter: (uid={{ term }}) | |
tasks: | |
- set_fact: | |
members: "{{ members|default([]) + [ { 'context' : 'user_valid' } ] }}" | |
- set_fact: | |
members: "{{ members + [ item ] }}" | |
with_items: "{{ lookup('file', 'uids').splitlines() }}" | |
- name: Display user full name | |
set_fact: | |
full_name: "{{ full_name|default({}) | combine( { item.uid : item.cn } ) }}" | |
with_ldap: "{{ members }}" | |
- hosts: stn-pcap-01 | |
become: yes | |
vars_prompt: | |
- name: ticket | |
prompt: "Enter the ticket ID" | |
tasks: | |
- set_fact: | |
full_name: "{{ hostvars['localhost']['full_name'] }}" | |
- name: adding account | |
loop_control: | |
loop_var: element | |
include_role: | |
name: accounts | |
vars: | |
account_users: | |
- name: "{{ element }}" | |
comment: "{{ full_name[element] }} - RT {{ ticket }}" | |
with_items: "{{ lookup('file', 'uids').splitlines() }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment