From 47e13a2af3a768225e9b891cfa12b18c1d1901a6 Mon Sep 17 00:00:00 2001 From: Jack Meixensperger Date: Tue, 19 Nov 2024 16:11:56 -0800 Subject: [PATCH 1/3] remove adding peers from provisioning --- roles/splunk_monitor/tasks/adding_peers.yml | 1 + .../splunk_monitor/tasks/initialize_standalone_search_head.yml | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/roles/splunk_monitor/tasks/adding_peers.yml b/roles/splunk_monitor/tasks/adding_peers.yml index 2c0ce2dd..0b1a7ffe 100644 --- a/roles/splunk_monitor/tasks/adding_peers.yml +++ b/roles/splunk_monitor/tasks/adding_peers.yml @@ -14,6 +14,7 @@ use_proxy: no register: distsearch_server_info no_log: "{{ hide_password }}" + - name: Initialize lists set_fact: current_group_list: [] diff --git a/roles/splunk_monitor/tasks/initialize_standalone_search_head.yml b/roles/splunk_monitor/tasks/initialize_standalone_search_head.yml index 4fd79677..759de288 100644 --- a/roles/splunk_monitor/tasks/initialize_standalone_search_head.yml +++ b/roles/splunk_monitor/tasks/initialize_standalone_search_head.yml @@ -1,6 +1,4 @@ --- -- include_tasks: ../../../roles/splunk_monitor/tasks/adding_peers.yml - - include_tasks: ../../../roles/splunk_common/tasks/set_as_deployment_client.yml when: - splunk.deployment_server is defined From 08aa1f0ced999eef98be111b02d083cb5174a5a1 Mon Sep 17 00:00:00 2001 From: Jack Meixensperger Date: Tue, 19 Nov 2024 16:31:05 -0800 Subject: [PATCH 2/3] remove cm peering --- .../tasks/initialize_standalone_search_head.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/roles/splunk_monitor/tasks/initialize_standalone_search_head.yml b/roles/splunk_monitor/tasks/initialize_standalone_search_head.yml index 759de288..b03ef12d 100644 --- a/roles/splunk_monitor/tasks/initialize_standalone_search_head.yml +++ b/roles/splunk_monitor/tasks/initialize_standalone_search_head.yml @@ -18,12 +18,6 @@ vars: app_list: "{{ splunk.app_paths_install.default }}" -- include_tasks: ../../splunk_common/tasks/peer_cluster_master.yml - when: - - splunk_indexer_cluster or splunk.multisite_master is defined - - splunk.set_search_peers is defined - - splunk.set_search_peers | bool - - include_tasks: setup_multisite.yml when: - splunk.site is defined From f6e048631c25e74940ca7b30c33bd79a3acdd26f Mon Sep 17 00:00:00 2001 From: Jack Meixensperger Date: Thu, 21 Nov 2024 13:43:05 -0800 Subject: [PATCH 3/3] passing C3 --- roles/splunk_monitor/tasks/adding_peers.yml | 23 ++++++++++++++++++- .../initialize_standalone_search_head.yml | 6 +++++ roles/splunk_monitor/tasks/main.yml | 2 ++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/roles/splunk_monitor/tasks/adding_peers.yml b/roles/splunk_monitor/tasks/adding_peers.yml index 0b1a7ffe..4123ebbf 100644 --- a/roles/splunk_monitor/tasks/adding_peers.yml +++ b/roles/splunk_monitor/tasks/adding_peers.yml @@ -29,7 +29,28 @@ - name: Create list of peers set_fact: - group_list: "{{ (groups['splunk_indexer']| default([])) + (groups['splunk_search_head'] | default([])) + (groups['splunk_search_head_captain'] | default([])) + (groups['splunk_cluster_master'] | default([])) + (groups['splunk_deployment_server']| default([])) + (groups['splunk_license_master'] | default([])) + (groups['splunk_standalone'] | default([])) }}" + group_list: "{{ (groups['splunk_indexer'] | default([])) + (groups['splunk_search_head'] | default([])) + (groups['splunk_search_head_captain'] | default([])) + (groups['splunk_cluster_master'] | default([])) + (groups['splunk_deployment_server']| default([])) + (groups['splunk_license_master'] | default([])) + (groups['splunk_standalone'] | default([])) }}" + +- name: Fetch existing peers + splunk_api: + method: GET + url: "/services/search/distributed/peers?output_mode=json&count=0" + cert_prefix: "{{ cert_prefix }}" + username: "{{ splunk.admin_user }}" + password: "{{ splunk.password }}" + svc_port: "{{ splunk.svc_port }}" + status_code: [200] + timeout: 10 + return_content: yes + use_proxy: no + register: existing_peers + no_log: "{{ hide_password }}" + retries: "{{ retry_num }}" + delay: "{{ retry_delay }}" + +- name: Remove existing peers from group_list + set_fact: + group_list: "{{ group_list | difference(existing_peers['json']['entry'] | selectattr('content.status', 'search', 'Up') | map(attribute='content.peerName') | list) }}" - name: Update group_list vars: diff --git a/roles/splunk_monitor/tasks/initialize_standalone_search_head.yml b/roles/splunk_monitor/tasks/initialize_standalone_search_head.yml index b03ef12d..759de288 100644 --- a/roles/splunk_monitor/tasks/initialize_standalone_search_head.yml +++ b/roles/splunk_monitor/tasks/initialize_standalone_search_head.yml @@ -18,6 +18,12 @@ vars: app_list: "{{ splunk.app_paths_install.default }}" +- include_tasks: ../../splunk_common/tasks/peer_cluster_master.yml + when: + - splunk_indexer_cluster or splunk.multisite_master is defined + - splunk.set_search_peers is defined + - splunk.set_search_peers | bool + - include_tasks: setup_multisite.yml when: - splunk.site is defined diff --git a/roles/splunk_monitor/tasks/main.yml b/roles/splunk_monitor/tasks/main.yml index d48284e7..9aeaf8e0 100644 --- a/roles/splunk_monitor/tasks/main.yml +++ b/roles/splunk_monitor/tasks/main.yml @@ -4,6 +4,8 @@ - name: Flush restart handlers meta: flush_handlers +- include_tasks: ../../../roles/splunk_monitor/tasks/adding_peers.yml + - name: Fetch server info splunk_api: method: GET