2024-05-14 10:40:33 +00:00
|
|
|
# synchronize user and group data from LDAP when sync-ldap context key is set to a realm
|
2024-05-18 16:35:41 +00:00
|
|
|
- name: Set up LDAP user synchronization
|
|
|
|
when: '"sync-ldap" in hostvars[inventory_hostname]'
|
|
|
|
block:
|
2024-05-14 10:04:35 +00:00
|
|
|
- name: Install LDAP sync script
|
|
|
|
template:
|
|
|
|
dest: /usr/local/bin/sync-ldap.py
|
|
|
|
src: sync-ldap.py.j2
|
|
|
|
mode: 0700
|
2024-05-18 16:35:41 +00:00
|
|
|
when: is_primary
|
2024-05-14 10:04:35 +00:00
|
|
|
|
|
|
|
- name: Remove LDAP sync script
|
|
|
|
file:
|
|
|
|
path: /usr/local/bin/sync-ldap.py
|
|
|
|
state: absent
|
2024-05-18 16:35:41 +00:00
|
|
|
when: not is_primary
|
2024-05-14 10:04:35 +00:00
|
|
|
|
|
|
|
- name: Configure cronjob
|
|
|
|
cron:
|
|
|
|
name: 'sync LDAP users and groups'
|
|
|
|
job: 'ip vrf exec default /usr/local/bin/sync-ldap.py'
|
|
|
|
user: root
|
|
|
|
cron_file: sync-ldap
|
|
|
|
hour: "2"
|
|
|
|
minute: "51"
|
2024-05-18 16:35:41 +00:00
|
|
|
state: '{{ "present" if is_primary else "absent" }}'
|