From d0375ebda10a8d2d4a160067d029c8673bf1ddd7 Mon Sep 17 00:00:00 2001 From: Todd Shell Date: Wed, 6 Dec 2023 17:44:49 -0500 Subject: [PATCH 1/4] Changes needed to support both 8.1< slave/master 8.1 >= peer/manager --- roles/splunk/tasks/configure_idxc_manager.yml | 11 +++++++++-- roles/splunk/tasks/configure_idxc_member.yml | 17 +++++++++++++---- roles/splunk/tasks/configure_idxc_sh.yml | 15 ++++++++++++++- 3 files changed, 36 insertions(+), 7 deletions(-) mode change 100644 => 100755 roles/splunk/tasks/configure_idxc_member.yml diff --git a/roles/splunk/tasks/configure_idxc_manager.yml b/roles/splunk/tasks/configure_idxc_manager.yml index 6511c423..c14e3770 100644 --- a/roles/splunk/tasks/configure_idxc_manager.yml +++ b/roles/splunk/tasks/configure_idxc_manager.yml @@ -6,9 +6,16 @@ # https://docs.splunk.com/Documentation/Splunk/8.0.9/Indexer/Configuremasterwithserverconf # Splunk version >= 8.1 supports mode=manager # https://docs.splunk.com/Documentation/Splunk/latest/Indexer/Configuremanagerwithserverconf -- name: Setting clustering mode based on Splunk version number + +- name: Setting clustering mode to master base on Splunk version + set_fact: + mode_value: "master" + when: splunk_version_release is version('8.1', '<') + +- name: Setting clustering mode to manager base on Splunk version set_fact: - mode_value: "{% if splunk_version_release | float < 8.1 %}master{% else %}manager{% endif %}" + mode_value: "manager" + when: splunk_version_release is version('8.1', '>=') - name: Configure clustering stanza for cluster manager node ini_file: diff --git a/roles/splunk/tasks/configure_idxc_member.yml b/roles/splunk/tasks/configure_idxc_member.yml old mode 100644 new mode 100755 index 3eea6f93..57138ffa --- a/roles/splunk/tasks/configure_idxc_member.yml +++ b/roles/splunk/tasks/configure_idxc_member.yml @@ -6,19 +6,28 @@ # https://docs.splunk.com/Documentation/Splunk/latest/Indexer/ConfigurepeerswithCLI # Splunk version < 8.1 supports mode=slave # https://docs.splunk.com/Documentation/Splunk/8.0.9/Indexer/ConfigurepeerswithCLI -- name: Setting clustering mode based on Splunk version number + +- name: Setting clustering mode to slave and uri to master base on Splunk version + set_fact: + mode_value: "slave" + uri_value: "master_uri" + when: splunk_version_release is version('8.1', '<') + +- name: Setting clustering mode to peer and uri to manager base on Splunk version set_fact: - mode_value: "{% if splunk_version_release | float < 8.1 %}slave{% else %}peer{% endif %}" + mode_value: "peer" + uri_value: "manager_uri" + when: splunk_version_release is version('8.1', '>=') - name: Configure idxc member - command: "{{ splunk_home }}/bin/splunk edit cluster-config -mode {{ mode_value }} -auth {{ splunk_auth }} -master_uri {{ splunk_uri_cm }} -replication_port {{ splunk_idxc_rep_port }} -secret {{ splunk_idxc_key }}" + command: "{{ splunk_home }}/bin/splunk edit cluster-config -mode {{ mode_value }} -auth {{ splunk_auth }} -{{ uri_value }} {{ splunk_uri_cm }} -replication_port {{ splunk_idxc_rep_port }} -secret {{ splunk_idxc_key }}" become: true become_user: "{{ splunk_nix_user }}" register: idxc_peer_init_result changed_when: idxc_peer_init_result.rc == 0 failed_when: idxc_peer_init_result.rc != 0 notify: restart splunk - no_log: true + no_log: false until: idxc_peer_init_result.rc == 0 retries: 6 delay: 5 diff --git a/roles/splunk/tasks/configure_idxc_sh.yml b/roles/splunk/tasks/configure_idxc_sh.yml index 38468bcf..f76a52c6 100644 --- a/roles/splunk/tasks/configure_idxc_sh.yml +++ b/roles/splunk/tasks/configure_idxc_sh.yml @@ -1,6 +1,19 @@ --- +- name: Run splunk version command to check currently installed version + include_tasks: check_splunk_version.yml + +- name: Setting clustering mode to slave and uri to master base on Splunk version + set_fact: + uri_value: "master_uri" + when: splunk_version_release is version('8.1', '<') + +- name: Setting clustering mode to peer and uri to manager base on Splunk version + set_fact: + uri_value: "manager_uri" + when: splunk_version_release is version('8.1', '>=') + - name: Configure search head to join indexer cluster - command: "{{ splunk_home }}/bin/splunk edit cluster-config -mode searchhead -master_uri {{ splunk_uri_cm }} -secret {{ splunk_idxc_key }} -auth {{ splunk_auth }}" + command: "{{ splunk_home }}/bin/splunk edit cluster-config -mode searchhead -{{ uri_value }} {{ splunk_uri_cm }} -secret {{ splunk_idxc_key }} -auth {{ splunk_auth }}" become: true become_user: "{{ splunk_nix_user }}" register: idxc_sh_join_result From 8d6c3a77d0e538baea34ccb7510ca9ea2e183cff Mon Sep 17 00:00:00 2001 From: Todd Shell Date: Thu, 29 Aug 2024 15:45:58 -0400 Subject: [PATCH 2/4] Changed per request --- roles/splunk/tasks/configure_idxc_member.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/splunk/tasks/configure_idxc_member.yml b/roles/splunk/tasks/configure_idxc_member.yml index 57138ffa..396589f5 100755 --- a/roles/splunk/tasks/configure_idxc_member.yml +++ b/roles/splunk/tasks/configure_idxc_member.yml @@ -27,7 +27,7 @@ changed_when: idxc_peer_init_result.rc == 0 failed_when: idxc_peer_init_result.rc != 0 notify: restart splunk - no_log: false + no_log: true until: idxc_peer_init_result.rc == 0 retries: 6 delay: 5 From 2cb40490de7dbc1222d42986b344d9ae49fabe86 Mon Sep 17 00:00:00 2001 From: dtwersky <80541771+dtwersky@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:32:49 -0400 Subject: [PATCH 3/4] Update roles/splunk/tasks/configure_idxc_manager.yml --- roles/splunk/tasks/configure_idxc_manager.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/splunk/tasks/configure_idxc_manager.yml b/roles/splunk/tasks/configure_idxc_manager.yml index c14e3770..32225364 100644 --- a/roles/splunk/tasks/configure_idxc_manager.yml +++ b/roles/splunk/tasks/configure_idxc_manager.yml @@ -14,7 +14,7 @@ - name: Setting clustering mode to manager base on Splunk version set_fact: - mode_value: "manager" + mode_value: "{% if splunk_version_release | version('8.1', '<') %}master{% else %}manager{% endif %}" when: splunk_version_release is version('8.1', '>=') - name: Configure clustering stanza for cluster manager node From c24fdeccd96c050d99b3cb93cce47cbbef5d7083 Mon Sep 17 00:00:00 2001 From: jewnix Date: Fri, 30 Aug 2024 13:58:35 -0400 Subject: [PATCH 4/4] set all values in separate task --- roles/splunk/tasks/configure_idxc_manager.yml | 18 +++-------------- roles/splunk/tasks/configure_idxc_member.yml | 20 +++---------------- roles/splunk/tasks/configure_idxc_sh.yml | 15 ++++---------- roles/splunk/tasks/set_idxc_facts.yml | 12 +++++++++++ 4 files changed, 22 insertions(+), 43 deletions(-) create mode 100644 roles/splunk/tasks/set_idxc_facts.yml diff --git a/roles/splunk/tasks/configure_idxc_manager.yml b/roles/splunk/tasks/configure_idxc_manager.yml index 32225364..38f3df2a 100644 --- a/roles/splunk/tasks/configure_idxc_manager.yml +++ b/roles/splunk/tasks/configure_idxc_manager.yml @@ -2,20 +2,8 @@ - name: Run splunk version command to check currently installed version include_tasks: check_splunk_version.yml -# Splunk version < 8.1 supports mode=master -# https://docs.splunk.com/Documentation/Splunk/8.0.9/Indexer/Configuremasterwithserverconf -# Splunk version >= 8.1 supports mode=manager -# https://docs.splunk.com/Documentation/Splunk/latest/Indexer/Configuremanagerwithserverconf - -- name: Setting clustering mode to master base on Splunk version - set_fact: - mode_value: "master" - when: splunk_version_release is version('8.1', '<') - -- name: Setting clustering mode to manager base on Splunk version - set_fact: - mode_value: "{% if splunk_version_release | version('8.1', '<') %}master{% else %}manager{% endif %}" - when: splunk_version_release is version('8.1', '>=') +- name: Set IDXC Values + include_tasks: set_idxc_facts.yml - name: Configure clustering stanza for cluster manager node ini_file: @@ -32,7 +20,7 @@ - wait for splunkd no_log: true loop: - - { option: "mode", value: "{{ mode_value}}" } + - { option: "mode", value: "{{ manager_mode_value }}" } - { option: "replication_factor", value: "{{ splunk_idxc_rf }}" } - { option: "search_factor", value: "{{ splunk_idxc_sf }}" } - { option: "pass4SymmKey", value: "{{ splunk_idxc_key }}" } diff --git a/roles/splunk/tasks/configure_idxc_member.yml b/roles/splunk/tasks/configure_idxc_member.yml index 396589f5..6a05c5fa 100755 --- a/roles/splunk/tasks/configure_idxc_member.yml +++ b/roles/splunk/tasks/configure_idxc_member.yml @@ -2,25 +2,11 @@ - name: Run splunk version command to check currently installed version include_tasks: check_splunk_version.yml -# Splunk version >= 8.1 supports mode=peer -# https://docs.splunk.com/Documentation/Splunk/latest/Indexer/ConfigurepeerswithCLI -# Splunk version < 8.1 supports mode=slave -# https://docs.splunk.com/Documentation/Splunk/8.0.9/Indexer/ConfigurepeerswithCLI - -- name: Setting clustering mode to slave and uri to master base on Splunk version - set_fact: - mode_value: "slave" - uri_value: "master_uri" - when: splunk_version_release is version('8.1', '<') - -- name: Setting clustering mode to peer and uri to manager base on Splunk version - set_fact: - mode_value: "peer" - uri_value: "manager_uri" - when: splunk_version_release is version('8.1', '>=') +- name: Set IDXC Values + include_tasks: set_idxc_facts.yml - name: Configure idxc member - command: "{{ splunk_home }}/bin/splunk edit cluster-config -mode {{ mode_value }} -auth {{ splunk_auth }} -{{ uri_value }} {{ splunk_uri_cm }} -replication_port {{ splunk_idxc_rep_port }} -secret {{ splunk_idxc_key }}" + command: "{{ splunk_home }}/bin/splunk edit cluster-config -mode {{ peer_mode_value }} -auth {{ splunk_auth }} -{{ manager_uri_value }} {{ splunk_uri_cm }} -replication_port {{ splunk_idxc_rep_port }} -secret {{ splunk_idxc_key }}" become: true become_user: "{{ splunk_nix_user }}" register: idxc_peer_init_result diff --git a/roles/splunk/tasks/configure_idxc_sh.yml b/roles/splunk/tasks/configure_idxc_sh.yml index f76a52c6..788954bd 100644 --- a/roles/splunk/tasks/configure_idxc_sh.yml +++ b/roles/splunk/tasks/configure_idxc_sh.yml @@ -2,18 +2,11 @@ - name: Run splunk version command to check currently installed version include_tasks: check_splunk_version.yml -- name: Setting clustering mode to slave and uri to master base on Splunk version - set_fact: - uri_value: "master_uri" - when: splunk_version_release is version('8.1', '<') - -- name: Setting clustering mode to peer and uri to manager base on Splunk version - set_fact: - uri_value: "manager_uri" - when: splunk_version_release is version('8.1', '>=') - +- name: Set IDXC Values + include_tasks: set_idxc_facts.yml + - name: Configure search head to join indexer cluster - command: "{{ splunk_home }}/bin/splunk edit cluster-config -mode searchhead -{{ uri_value }} {{ splunk_uri_cm }} -secret {{ splunk_idxc_key }} -auth {{ splunk_auth }}" + command: "{{ splunk_home }}/bin/splunk edit cluster-config -mode searchhead -{{ manager_uri_value }} {{ splunk_uri_cm }} -secret {{ splunk_idxc_key }} -auth {{ splunk_auth }}" become: true become_user: "{{ splunk_nix_user }}" register: idxc_sh_join_result diff --git a/roles/splunk/tasks/set_idxc_facts.yml b/roles/splunk/tasks/set_idxc_facts.yml new file mode 100644 index 00000000..042176c7 --- /dev/null +++ b/roles/splunk/tasks/set_idxc_facts.yml @@ -0,0 +1,12 @@ +--- +# Splunk version < 8.1 supports mode=master +# https://docs.splunk.com/Documentation/Splunk/8.0.9/Indexer/Configuremasterwithserverconf +# Splunk version >= 8.1 supports mode=manager +# https://docs.splunk.com/Documentation/Splunk/latest/Indexer/Configuremanagerwithserverconf + +- name: Setting clustering mode and value based on Splunk version + set_fact: + manager_mode_value: "{% if splunk_version_release | version('8.1', '<') %}master{% else %}manager{% endif %}" + peer_mode_value: "{% if splunk_version_release | version('8.1', '<') %}slave{% else %}peer{% endif %}" + manager_uri_value: "{% if splunk_version_release | version('8.1', '<') %}master_uri{% else %}manager_uri{% endif %}" + when: splunk_version_release is version('8.1', '>=')