I have an Ansible playbook that sets up Splunk cluster, one of the commands adds a Server List of cluster members,
- name: search head init & set CAPTAIN
block:
- command: splunk init shcluster-config -auth admin:changeme \
-mgmt_uri "https://{{ ansible_default_ipv4.address }}:8089" \
-replication_port 8090 -conf_deploy_fetch_url https://{{ deployer_ip }}:8089 -secret {{ cluster['secret'] }}
# set captain
- debug: msg='setting captain'
- command: splunk bootstrap shcluster-captain \
-servers_list "10.185.20.156:8089, 10.185.20.160:8089, 10.185.20.161:8089" -auth admin:changeme
I have all my config vars set inside a file, and thats where Im getting them from (for example, cluster['secret']
), the config.yaml
varfile looks like this,
# Cluster Config
cluster:
secret: abracadabra # secret key
app_name: cluster # adds a custom Splunk App for Cluster config
members:
mrxsplunksh01: 10.185.20.156
mrxsplunksh02: 10.185.20.160
mrxsplunksh03: 10.185.20.161
I cant figure out how to parse/loop the cluster['members'] dictionary to get the IP of each cluster member, so I dont have to do this part manually,
- command: splunk bootstrap shcluster-captain \
-servers_list "10.185.20.156:8089, 10.185.20.160:8089, 10.185.20.161:8089" -auth admin:changeme
I tried with_items
and with_dict
and I can't get it to parse each element correctly.