]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Adding and using Ansible role set-timestamp-vars
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 4 Dec 2024 15:52:20 +0000 (16:52 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 4 Dec 2024 15:52:20 +0000 (16:52 +0100)
playbooks/disable-ldap-server.yaml
playbooks/enable-ldap-server-replication.yaml
roles/set-timestamp-vars/tasks/main.yaml [new file with mode: 0644]

index 65b8d85fd403056b1675f109ef25883482d51487..41b36b46331701c0cddfddd72944e1611e602734 100644 (file)
 
   tasks:
 
+    - name: "Setting timestamp variables."
+      include_role:
+        name: set-timestamp-vars
+
     - name: "Get the LDAP server to disable replication:"
       ansible.builtin.set_fact:
         ldapserver_to_disable: "{{ hostvars.localhost.ldapserver_to_disable }}"
         var: ldapserver_to_disable
         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
-
     - name: "Initial set target_replica_id"
       ansible.builtin.set_fact:
         target_replica_id: ~
index 7ab29a5f4602f4057a3e6b19db8bd11314a54ddc..289c664ba6d6d75c31645b723a4aa96019aa303a 100644 (file)
       include_role:
         name: 389ds-check-initial
 
+    - name: "Setting timestamp variables."
+      include_role:
+        name: set-timestamp-vars
+
     - name: "Get the LDAP server to enable replication:"
       ansible.builtin.set_fact:
         ldapserver_to_enable: "{{ hostvars.localhost.ldapserver_to_enable }}"
         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
diff --git a/roles/set-timestamp-vars/tasks/main.yaml b/roles/set-timestamp-vars/tasks/main.yaml
new file mode 100644 (file)
index 0000000..4d983b7
--- /dev/null
@@ -0,0 +1,28 @@
+---
+
+# Setting timestamp variables on base of the local time on the apropiate hosts
+
+- name: "Get timestamp from the system"
+  ansible.builtin.shell: date +%Y-%m-%d_%H-%M-%S%:z
+  register: get_tstamp
+  check_mode: false
+  changed_when: false
+
+- name: "Show current timestamp"
+  debug:
+    var: get_tstamp
+    verbosity: 3
+
+- name: "Set date variables"
+  set_fact:
+    cur_date: "{{ get_tstamp.stdout[0:10] }}"
+    cur_time: "{{ get_tstamp.stdout[11:19] }}"
+    cur_timestamp: "{{ get_tstamp.stdout[0:10] }}_{{ get_tstamp.stdout[11:19] }}"
+    cur_timezone: "{{ get_tstamp.stdout[19:] }}"
+
+- name: "Show current timestamp"
+  debug:
+    msg: "cur_timestamp: '{{ cur_timestamp }} {{ cur_timezone }}'"
+    verbosity: 0
+
+# vim: filetype=yaml