From: Frank Brehm Date: Wed, 4 Dec 2024 16:18:29 +0000 (+0100) Subject: Adding and using Ansible role haproxy-check-initial X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=20b77006ea2e4149e4c52cf6448ca35eead43bc1;p=pixelpark%2Fpp-admin-tools.git Adding and using Ansible role haproxy-check-initial --- diff --git a/playbooks/disable-ldap-server.yaml b/playbooks/disable-ldap-server.yaml index 41b36b4..c1c4198 100644 --- a/playbooks/disable-ldap-server.yaml +++ b/playbooks/disable-ldap-server.yaml @@ -51,6 +51,10 @@ 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 }}" diff --git a/playbooks/enable-ldap-server-replication.yaml b/playbooks/enable-ldap-server-replication.yaml index 289c664..25329e4 100644 --- a/playbooks/enable-ldap-server-replication.yaml +++ b/playbooks/enable-ldap-server-replication.yaml @@ -31,6 +31,16 @@ 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 index 0000000..2a184a4 --- /dev/null +++ b/roles/haproxy-check-initial/defaults/main.yaml @@ -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 index 0000000..8d76537 --- /dev/null +++ b/roles/haproxy-check-initial/tasks/main.yaml @@ -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