Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
---
- 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