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

index 41b36b46331701c0cddfddd72944e1611e602734..c1c4198822e223979948485a4d5f8443d811ea55 100644 (file)
 
   tasks:
 
+    - name: "Made basic checks for HAProxy."
+      include_role:
+        name: haproxy-check-initial
+
     - name: "Get the LDAP server to disable replication:"
       ansible.builtin.set_fact:
         ldapserver_to_disable: "{{ hostvars.localhost.ldapserver_to_disable }}"
index 289c664ba6d6d75c31645b723a4aa96019aa303a..25329e49e425ac906547abd291924748aaa0ebff 100644 (file)
         msg: "The given host '{{ ldapserver_to_enable }}' is not a valid LDAP server."
       when: found_ldapserver == false
 
+- name: "Initial checks for the HAProxy."
+  hosts: haproxy_servers
+  gather_facts: false
+
+  tasks:
+
+    - name: "Made basic checks for HAProxy."
+      include_role:
+        name: haproxy-check-initial
+
 - name: "Enabling Replication on a particular LDAP server."
   hosts: ldap_servers
   gather_facts: false
diff --git a/roles/haproxy-check-initial/defaults/main.yaml b/roles/haproxy-check-initial/defaults/main.yaml
new file mode 100644 (file)
index 0000000..2a184a4
--- /dev/null
@@ -0,0 +1,8 @@
+---
+
+haproxy_backend_name: 'be'
+haproxy_admin_socket: '/run/haproxy/admin.sock'
+haproxy_operator_socket: '/run/haproxy/operator.sock'
+haproxy_user_socket: '/run/haproxy/user.sock'
+
+# vim: filetype=yaml
diff --git a/roles/haproxy-check-initial/tasks/main.yaml b/roles/haproxy-check-initial/tasks/main.yaml
new file mode 100644 (file)
index 0000000..8d76537
--- /dev/null
@@ -0,0 +1,31 @@
+---
+
+# Role for Initial checks of a HAProxy installation
+
+- name: "Exec command for retrieving version of HAProxy."
+  ansible.builtin.shell: "haproxy -v | grep -i -P '^HAProxy\\s+version' | sed -e 's/^HAProxy[  ][      ]*version[      ][      ]*//' -e 's/[   ].*//'"
+  register: get_haproxy_version
+  check_mode: false
+  changed_when: false
+
+- name: "Checking results of getting the HAProxy version."
+  debug:
+    var: get_haproxy_version
+    verbosity: 2
+
+- name: "Get the version of the HAProxy."
+  ansible.builtin.set_fact:
+    version_haproxy: "{{ get_haproxy_version.stdout }}"
+    cacheable: true
+
+- name: "Show version of HAProxy."
+  debug:
+    var: version_haproxy
+    verbosity: 0
+
+- name: "Fail for non existing HAProxy."
+  ansible.builtin.fail:
+    msg: "No HAProxy server found on host '{{ inventory_hostname }}'."
+  when: version_haproxy == ''
+
+# vim: filetype=yaml