splunk / splunk-platform-automator

Ansible framework providing a fast and simple way to spin up complex Splunk environments.
Apache License 2.0
117 stars 46 forks source link

hostvars['cm'] is undefined. The error appears to have been in org_cluster_search_base.yml #5

Closed aleoliva closed 5 years ago

aleoliva commented 5 years ago

Hi Marco,

I face an error while creating a distributed Splunk environment. The error is on task [baseconfig_app : (org_cluster_search_base) setting static unhashed pass4SymmKey on clustermaster stanza], using Splunkenizer version 1.2devel:

$ ansible-playbook ansible/deploy_site.yml
...

TASK [baseconfig_app : (org_cluster_search_base) remove clustermaster:two cluster master group] **************************************************************************
changed: [splkT_ds]

TASK [baseconfig_app : (org_cluster_search_base) setting pass4SymmKey for hashing on clustermaster stanza] ***************************************************************
skipping: [splkT_ds] => (item={'value': u'cm', 'key': u'aleSplk_idxc_name-test'})

TASK [baseconfig_app : (org_cluster_search_base) setting pass4SymmKey for hashing on clustermaster stanza] ***************************************************************
skipping: [splkT_ds] => (item={'value': u'cm', 'key': u'aleSplk_idxc_name-test'})

TASK [baseconfig_app : (org_cluster_search_base) setting static unhashed pass4SymmKey on clustermaster stanza] ***********************************************************
fatal: [splkT_ds]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: u\"hostvars['cm']\" is undefined\n\nThe error appears to have been in '/home/linux/Vagrant/Splunkenizer/ansible/roles/baseconfig_app/tasks/org_cluster_search_base.yml': line 65, 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- name: \"({{ app_name }}) setting static unhashed pass4SymmKey on clustermaster stanza\"\n  ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes.  Always quote template expression brackets when they\nstart a value. For instance:\n\n    with_items:\n      - {{ foo }}\n\nShould be written as:\n\n    with_items:\n      - \"{{ foo }}\"\n"}

RUNNING HANDLER [splunk_common : restart splunk] *************************************************************************************************************************
    to retry, use: --limit @/home/linux/Vagrant/Splunkenizer/ansible/deploy_site.retry

PLAY RECAP ***************************************************************************************************************************************************************
splkT_cm                   : ok=37   changed=2    unreachable=0    failed=0
splkT_ds                   : ok=138  changed=17   unreachable=0    failed=1
splkT_hf1                  : ok=37   changed=2    unreachable=0    failed=0
splkT_idx1s1               : ok=37   changed=2    unreachable=0    failed=0
splkT_idx2s1               : ok=37   changed=2    unreachable=0    failed=0
splkT_idx3s2               : ok=37   changed=2    unreachable=0    failed=0
splkT_idx4s2               : ok=37   changed=2    unreachable=0    failed=0
splkT_sh1                  : ok=37   changed=2    unreachable=0    failed=0
splkT_sh2                  : ok=37   changed=2    unreachable=0    failed=0
splkT_sh3                  : ok=37   changed=2    unreachable=0    failed=0

Ansible version is:

$ ansible --version
ansible 2.7.9
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/linux/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Oct 30 2018, 23:45:53) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]

The error is reproducible, additional details can be submitted if you need them.

splunkenizer commented 5 years ago

Can you please attach the splunk_config.yml here or send it to me by mail? I need to reproduce.

aleoliva commented 5 years ago

Here is the zipped splunk_config.yml: splunk_config.zip

splunkenizer commented 5 years ago

I could not reproduce your error with the config file you submitted here, but I have verified your config file and found several issues with it:

vm:

splunk_config.zip

aleoliva commented 5 years ago

Yes, it's true. I had two monitoring_console roles defined.

After solve this point, I could go a bit further but the new error is:

fatal: [splkT-sh3]: FAILED! => {"msg": "The conditional check 'splunk_secret_share[splunk_install_app] == true' failed. The error was: error while evaluating conditional (splunk_secret_share[splunk_install_app] == true): 'splunk_secret_share' is undefined\n\nThe error appears to have been in '/home/linux/Vagrant/Splunkenizer/ansible/roles/splunk_software/tasks/main.yml': line 31, 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- name: check for existing splunk.secret file\n  ^ here\n"}

I cannot find documentation about where to place the splunk.secret file

Thanks in advance. splunk_config.zip

splunkenizer commented 5 years ago

The splunk.secret file will be picket up from the first installed server and placed into the auth directory in the Splunkenizer folder. The folder will be created automatically, when vagrant runs.

aleoliva commented 5 years ago

True and I had missed to set splunk_license_file on _config/splunkconfig.yml, although I was installing a license_master.

Solved, e.g.:

...
splunk_defaults:
  splunk_license_file: Splunk_Enterprise.lic
...
splunk_hosts:
  - name: splk-ds
    roles:
      - deployment_server
      - license_master
    shcluster: shc1
...