Skip to content

configure_shc_captain fails with no attribute #221

@zyphermonkey

Description

@zyphermonkey

command: "{{ splunk_home }}/bin/splunk bootstrap shcluster-captain -servers_list {{ splunk_shc_uri_list }} -auth {{ splunk_auth }}"

I know I used this in the past on our last SHC, but this time it failed with the following error (after taking off no_log). This is possibly an ansible bug because I know we've upgraded the version of ansible on our control node since the last time we built a SHC.

fatal: [splunk-sh-p01]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'ansible.vars.hostvars.HostVarsVars object' has no attribute 'splunk_mgmt_uri'. 'ansible.vars.hostvars.HostVarsVars object' has no attribute 'splunk_mgmt_uri'\n\nThe error appears to be in '/home/vagrant/.ansible/roles/ansible-role-for-splunk/tasks/configure_shc_captain.yml': line 23, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- set_fact:\n ^ here\n"}

I solved it by preceding the bootstrap task with the following.

- set_fact:
    splunk_mgmt_uri: "{{ ansible_fqdn }}"

- set_fact:
    splunk_shc_uri_list: "{% for h in groups[splunk_shc_target_group] %}https://{{ hostvars[h].splunk_mgmt_uri }}:{{ splunkd_port }}{% if not loop.last %},{% endif %}{% endfor %}" # If you manage multiple SHCs, configure the var value in group_vars

Looking to start the conversation to see if anyone else can replicate the issue and/or if I should just move forward with a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions