diff --git a/roles/splunk/tasks/configure_idxc_manager.yml b/roles/splunk/tasks/configure_idxc_manager.yml index 6511c423..38f3df2a 100644 --- a/roles/splunk/tasks/configure_idxc_manager.yml +++ b/roles/splunk/tasks/configure_idxc_manager.yml @@ -2,13 +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 based on Splunk version number - set_fact: - mode_value: "{% if splunk_version_release | float < 8.1 %}master{% else %}manager{% endif %}" +- name: Set IDXC Values + include_tasks: set_idxc_facts.yml - name: Configure clustering stanza for cluster manager node ini_file: @@ -25,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 old mode 100644 new mode 100755 index 3eea6f93..6a05c5fa --- a/roles/splunk/tasks/configure_idxc_member.yml +++ b/roles/splunk/tasks/configure_idxc_member.yml @@ -2,16 +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 based on Splunk version number - set_fact: - mode_value: "{% if splunk_version_release | float < 8.1 %}slave{% else %}peer{% endif %}" +- 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 }} -master_uri {{ 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 38468bcf..788954bd 100644 --- a/roles/splunk/tasks/configure_idxc_sh.yml +++ b/roles/splunk/tasks/configure_idxc_sh.yml @@ -1,6 +1,12 @@ --- +- name: Run splunk version command to check currently installed version + include_tasks: check_splunk_version.yml + +- 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 -master_uri {{ 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', '>=')