From 67075e4324248322d163ee4cfef8414e1c47299c Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 4 Dec 2024 17:42:03 +0100 Subject: [PATCH] Extending Ansible role haproxy-check-initial --- inventory/dpx-ldap-dev1.yaml | 2 - inventory/spk-ldap-stage.yaml | 2 - roles/haproxy-check-initial/tasks/main.yaml | 60 +++++++++++++++++++ roles/haproxy-disable-backend/tasks/main.yaml | 20 ------- 4 files changed, 60 insertions(+), 24 deletions(-) diff --git a/inventory/dpx-ldap-dev1.yaml b/inventory/dpx-ldap-dev1.yaml index d63b43c..1e2c294 100644 --- a/inventory/dpx-ldap-dev1.yaml +++ b/inventory/dpx-ldap-dev1.yaml @@ -25,8 +25,6 @@ all: replication_manager_password_file: '/root/.private/dirserv-repl-mngr-pwd.txt' replication_manager_idle_timeout: 0 haproxy_backend_name: 'be-ldap-dev1' - haproxy_user_socket: '/run/haproxy/user.sock' - haproxy_admin_socket: '/run/haproxy/admin.sock' # ds389_plugin_attr_uniq_purge: false ds389_plugin_attr_uniq_attributes: 'uid': diff --git a/inventory/spk-ldap-stage.yaml b/inventory/spk-ldap-stage.yaml index 13ac24c..f536d71 100644 --- a/inventory/spk-ldap-stage.yaml +++ b/inventory/spk-ldap-stage.yaml @@ -22,8 +22,6 @@ all: replication_manager_password_file: '/root/.private/dirserv-repl-mngr-pwd.txt' replication_manager_idle_timeout: 0 haproxy_backend_name: 'be-stage-ldap' - haproxy_user_socket: '/run/haproxy/user.sock' - haproxy_admin_socket: '/run/haproxy/admin.sock' ds389_plugin_attr_uniq_config: false # ds389_plugin_attr_uniq_purge: false ds389_plugin_attr_uniq_attributes: diff --git a/roles/haproxy-check-initial/tasks/main.yaml b/roles/haproxy-check-initial/tasks/main.yaml index 8d76537..9875965 100644 --- a/roles/haproxy-check-initial/tasks/main.yaml +++ b/roles/haproxy-check-initial/tasks/main.yaml @@ -28,4 +28,64 @@ msg: "No HAProxy server found on host '{{ inventory_hostname }}'." when: version_haproxy == '' +- name: "Get file stat of HAProxy admin socket ..." + ansible.builtin.stat: + path: "{{ haproxy_admin_socket }}" + register: admin_socket + +- name: "File stat of HAProxy admin socket: " + debug: + var: admin_socket + verbosity: 3 + +- name: "Check existence of HAProxy admin socket." + ansible.builtin.fail: + msg: "The HAProxy admin socket '{{ haproxy_admin_socket }}' does not exists." + when: admin_socket.stat.exists != true + +- name: "Checking, whether '{{ haproxy_admin_socket }}' is a socket." + ansible.builtin.fail: + msg: "The path '{{ haproxy_admin_socket }}' for the HAProxy admin socket is not a socket." + when: admin_socket.stat.issock != true + +- name: "Get file stat of HAProxy operator socket ..." + ansible.builtin.stat: + path: "{{ haproxy_operator_socket }}" + register: operator_socket + +- name: "File stat of HAProxy operator socket: " + debug: + var: operator_socket + verbosity: 3 + +- name: "Check existence of HAProxy operator socket." + ansible.builtin.fail: + msg: "The HAProxy operator socket '{{ haproxy_operator_socket }}' does not exists." + when: operator_socket.stat.exists != true + +- name: "Checking, whether '{{ haproxy_operator_socket }}' is a socket." + ansible.builtin.fail: + msg: "The path '{{ haproxy_operator_socket }}' for the HAProxy operator socket is not a socket." + when: operator_socket.stat.issock != true + +- name: "Get file stat of HAProxy user socket ..." + ansible.builtin.stat: + path: "{{ haproxy_user_socket }}" + register: user_socket + +- name: "File stat of HAProxy user socket: " + debug: + var: user_socket + verbosity: 3 + +- name: "Check existence of HAProxy user socket." + ansible.builtin.fail: + msg: "The HAProxy user socket '{{ haproxy_user_socket }}' does not exists." + when: user_socket.stat.exists != true + +- name: "Checking, whether '{{ haproxy_user_socket }}' is a socket." + ansible.builtin.fail: + msg: "The path '{{ haproxy_user_socket }}' for the HAProxy user socket is not a socket." + when: user_socket.stat.issock != true + # vim: filetype=yaml diff --git a/roles/haproxy-disable-backend/tasks/main.yaml b/roles/haproxy-disable-backend/tasks/main.yaml index dd5b47d..7955b1c 100644 --- a/roles/haproxy-disable-backend/tasks/main.yaml +++ b/roles/haproxy-disable-backend/tasks/main.yaml @@ -4,26 +4,6 @@ msg: "Setting server '{{ backend_server }}' on HAProxy backend '{{ backend }}' into maintenance ..." verbosity: 0 -- name: "Get file stat of HAProxy admin socket '{{ haproxy_admin_socket }}' ..." - ansible.builtin.stat: - path: "{{ haproxy_admin_socket }}" - register: admin_socket - -- name: "File stat of HAProxy admin socket '{{ haproxy_admin_socket }}': " - debug: - var: admin_socket - verbosity: 3 - -- name: "Check existence of HAProxy admin socket '{{ haproxy_admin_socket }}'." - ansible.builtin.fail: - msg: "The HAProxy admin socket '{{ haproxy_admin_socket }}' does not exists." - when: admin_socket.stat.exists != true - -- name: "Checkinf, whether '{{ haproxy_admin_socket }}' is a socket." - ansible.builtin.fail: - msg: "The path '{{ haproxy_admin_socket }}' for the HAProxy admin socket is not a socket." - when: admin_socket.stat.issock != true - - name: "Setting backend server {{ backend }}/{{ backend_server }} into maintenance." community.general.haproxy: state: drain -- 2.39.5