Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running configure_shc_captain.yml multiple times yields different results #96

Open
derek126 opened this issue Aug 30, 2021 · 3 comments
Assignees

Comments

@derek126
Copy link

Ansible tasks should be idempotent. If the search head cluster already had a captain this task should be able to figure that out and skip.

@peterchenadded
Copy link

Need to run the show shcluster-status command and if captain already elected do not run the init captain command again.

@derek126
Copy link
Author

That is what I do now

- name: Check If Captain is Already Elected
  hosts:
    - shc
  run_once: true
  tasks:
  - name: Get SHC Captain Status
    shell: "/opt/splunk/bin/splunk show shcluster-status -auth {{ splunk_admin_username }}:{{ splunk_admin_password }} | grep label | head -n1 | cut -d ':' -f2 | xargs"
    become: true
    become_user: "{{ splunk_nix_user }}"
    register: shc_response
    no_log: false
    until: shc_response.stdout != "" and shc_response.rc == 0
    retries: 10
    delay: 5
    ignore_errors: yes
  - name: Setting SHC Captain Fact
    set_fact: 
      shc_captain: "{{ shc_response.stdout }}"

It could take a few minutes after restart for this to detect if a captain has been elected already.

@peterchenadded
Copy link

Yeah I also ran into timing issues with that. I ended up checking if server.conf shclustering has the id option using btools to work out if the bootstrap captain command is already run.

@mason-splunk mason-splunk self-assigned this Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants