Created
April 12, 2017 20:46
-
-
Save asifiqbal/3857ce3d2fd9de27451d6fe1e61ffc61 to your computer and use it in GitHub Desktop.
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 | |
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