Skip to content

Instantly share code, notes, and snippets.

@asifiqbal
Created April 12, 2017 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asifiqbal/3857ce3d2fd9de27451d6fe1e61ffc61 to your computer and use it in GitHub Desktop.
Save asifiqbal/3857ce3d2fd9de27451d6fe1e61ffc61 to your computer and use it in GitHub Desktop.
---
- 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