From b03f96a3fa6875506556a65e7c168bfc21f70b79 Mon Sep 17 00:00:00 2001 From: Jesus Garcia Date: Wed, 29 Oct 2025 15:30:26 -0500 Subject: [PATCH] Adapt wazuh dashboard role (backport from 6.0.0) --- CHANGELOG.md | 1 + roles/wazuh-dashboard/defaults/main.yml | 2 +- roles/wazuh-dashboard/tasks/main.yml | 26 +++++++------------------ wazuh-distributed.yml | 2 +- 4 files changed, 10 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08f1d449..c504055a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file. ### Changed +- Dashboard role backport and adaptation ([#1831](https://github.com/wazuh/wazuh-ansible/pull/1831)) - Server role backport and adaptation ([#1825](https://github.com/wazuh/wazuh-ansible/pull/1825)) - Indexer role backport and adaptation ([#1823](https://github.com/wazuh/wazuh-ansible/pull/1823)) - Ansible base configuration files and directories backport ([#1819](https://github.com/wazuh/wazuh-ansible/pull/1819)) diff --git a/roles/wazuh-dashboard/defaults/main.yml b/roles/wazuh-dashboard/defaults/main.yml index c6df3a70..44e711fb 100644 --- a/roles/wazuh-dashboard/defaults/main.yml +++ b/roles/wazuh-dashboard/defaults/main.yml @@ -1,7 +1,7 @@ --- dashboard_node_name: "dashboard" -wazuh_server_api_host: "localhost" +wazuh_server_master_address: "{{ hostvars[inventory_hostname].private_ip }}" indexer_cluster_nodes: - "{{ hostvars[inventory_hostname].private_ip }}" diff --git a/roles/wazuh-dashboard/tasks/main.yml b/roles/wazuh-dashboard/tasks/main.yml index 73daf94a..7e6e07b0 100644 --- a/roles/wazuh-dashboard/tasks/main.yml +++ b/roles/wazuh-dashboard/tasks/main.yml @@ -39,31 +39,19 @@ - name: Dashboard-config | Remove current opensearch.hosts configuration ansible.builtin.replace: path: /etc/wazuh-dashboard/opensearch_dashboards.yml - regexp: 'opensearch\.hosts: .*$' + regexp: '^opensearch\.hosts:.*(?:\n\s+-\s+https?://[^\n]+)*' replace: 'opensearch.hosts:' - name: Dashboard-config | Add opensearch.hosts configuration - ansible.builtin.blockinfile: + ansible.builtin.replace: path: /etc/wazuh-dashboard/opensearch_dashboards.yml - insertafter: 'opensearch.hosts:' - marker: "# OpenSearch hosts configuration" - block: | + regexp: '^opensearch\.hosts:\s*$' + replace: | + opensearch.hosts: {% for node in indexer_cluster_nodes %} - https://{{ node }}:9200 {% endfor %} - - name: Dashboard-config | Remove comments from configuration file - ansible.builtin.replace: - path: "/etc/wazuh-dashboard/opensearch_dashboards.yml" - regexp: '^\s*#.*$' - replace: '' - - - name: Dashboard-config | Remove empty lines from config.yml file - ansible.builtin.replace: - path: "/etc/wazuh-dashboard/opensearch_dashboards.yml" - regexp: '^\s*$' - replace: '' - - name: Copy the certificates from local to the Wazuh dashboard instance ansible.builtin.copy: src: "{{ local_configs_path }}/wazuh-certificates/{{ item }}" @@ -89,11 +77,11 @@ - { src: "{{ dashboard_node_name }}-key.pem", dest: "dashboard-key.pem" } when: dashboard_node_name != "dashboard" -- name: Ensure Wazuh dashboard started and enabled +- name: Ensure Wazuh dashboard started ansible.builtin.service: name: wazuh-dashboard enabled: true - state: started + state: restarted - name: Extract server host from dashboard configuration ansible.builtin.shell: diff --git a/wazuh-distributed.yml b/wazuh-distributed.yml index e8cd3330..1f00d3ce 100644 --- a/wazuh-distributed.yml +++ b/wazuh-distributed.yml @@ -79,7 +79,7 @@ become: true vars: dashboard_node_name: "node-6" - wazuh_server_api_host: "{{ hostvars.balancer.private_ip }}" + wazuh_server_master_address: "{{ hostvars.manager.private_ip }}" indexer_cluster_nodes: - "{{ hostvars.wi1.private_ip }}" - "{{ hostvars.wi2.private_ip }}"