From 6fa3893d41c619ecf59e975532dbddfa8365b1e5 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Fri, 29 Nov 2024 14:30:36 +0100 Subject: [PATCH] Adding playbooks/enable-ldap-server-replication.yaml --- playbooks/enable-ldap-server-replication.yaml | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 playbooks/enable-ldap-server-replication.yaml diff --git a/playbooks/enable-ldap-server-replication.yaml b/playbooks/enable-ldap-server-replication.yaml new file mode 100644 index 0000000..50ee0b7 --- /dev/null +++ b/playbooks/enable-ldap-server-replication.yaml @@ -0,0 +1,71 @@ +--- +- name: "Validate the LDAP server to enable replication" + hosts: localhost + gather_facts: false + vars_prompt: + - name: ldap_server + prompt: "On wich LDAP server should replication be enabled" + private: false + + tasks: + + - name: "Setting fact ldapserver_to_enable." + ansible.builtin.set_fact: + ldapserver_to_enable: "{{ ldap_server }}" + cacheable: true + + - name: "Setting status variable found_ldapserver." + ansible.builtin.set_fact: + found_ldapserver: false + + - name: "Searching for LDAP server '{{ ldapserver_to_enable }}' ..." + ansible.builtin.set_fact: + found_ldapserver: true + when: "item == ldapserver_to_enable" + ignore_errors: true + with_inventory_hostnames: + - ldap_servers + + - name: "Fail for non LDAP server." + ansible.builtin.fail: + msg: "The given host '{{ ldapserver_to_enable }}' is not a valid LDAP server." + when: found_ldapserver == false + +- name: "Enabling Replication on a particular LDAP server." + hosts: ldap_servers + # gather_facts: false + + tasks: + + - name: "Get the LDAP server to enable replication:" + ansible.builtin.set_fact: + ldapserver_to_enable: "{{ hostvars.localhost.ldapserver_to_enable }}" + + - name: "The LDAP server to enable replication:" + debug: + var: ldapserver_to_enable + verbosity: 0 + + - name: "Get timestamp from the system" + ansible.builtin.shell: date +%Y-%m-%d_%H-%M-%S + register: tstamp + check_mode: false + changed_when: false + + - name: "Show current timestamp" + debug: + var: tstamp + verbosity: 3 + + - name: "Set date variables" + set_fact: + cur_date: "{{ tstamp.stdout[0:10] | default('2024-11-11') }}" + cur_time: "{{ tstamp.stdout[11:] | default('16-33-23') }}" + cur_timestamp: "{{ tstamp.stdout[0:10] }}_{{ tstamp.stdout[11:] | default('2024-11-11_16-33-23') }}" + + - name: "Show current date" + debug: + msg: "Current timestamp: '{{ cur_timestamp }}'." + verbosity: 0 + +# vim: filetype=yaml -- 2.39.5