Ansible framework providing a fast and simple way to spin up complex Splunk environments.
117
stars
46
forks
source link
Splunk Hosts index.html creation broken #18
Closed
tonyprinzler closed 2 years ago
\n <div class=\"card-body\">\n <p
class=\"card-text\">Env: {{ hostvars[hostname]['splunk_env_name'] }}\n
<p class=\"card-text\">IP Addr: {{
hostvars[hostname]['ip_addr']|default(\"unknown\") }}\n \n <div
class=\"card-footer\">\n {%- set web_port = '8000' -%}\n {%- if
hostvars[hostname]['splunk_ssl']['web']['enable'] is true -%}\n {%- set url
= 'https://' -%}\n {%- else -%}\n {%- set url = 'http://' -%}\n {%- endif
-%}\n {%- for role_name in
groups|map('regexsearch','role .*')|select('string')|list -%}\n {%- if
hostname in groups[role_name] -%}\n {%- if role_name ==
\"role_search_head\" -%}\n <a class=\"btn btn-success\" target=\"_blank\"
href=\"{{ url }}{{
hostvars[hostname]['public_dns_name']|default(hostvars[hostname]['ip_addr']|default(\"unknown\"))
}}:{{web_port}}/{{ url_locale|default(\"en-GB\")
}}/app/launcher/home\">Search Head\n {%- elif role_name ==
\"role_indexer\" -%}\n <span class=\"d-inline-block\" tabindex=\"0\"
data-toggle=\"tooltip\" title=\"No web access on indexer\">\n <button
class=\"btn btn-primary\" style=\"pointer-events: none;\" type=\"button\"
disabled=\"\">Indexer\n \n {%- elif role_name ==
\"role_license_master\" -%}\n <a class=\"btn btn-success\"
target=\"_blank\" href=\"{{ url }}{{
hostvars[hostname]['public_dns_name']|default(hostvars[hostname]['ip_addr']|default(\"unknown\"))
}}:{{web_port}}/{{ url_locale|default(\"en-GB\")
}}/manager/system/licensing\">License Master\n {%- elif role_name ==
\"role_cluster_master\" -%}\n <a class=\"btn btn-success\"
target=\"_blank\" href=\"{{ url }}{{
hostvars[hostname]['public_dns_name']|default(hostvars[hostname]['ip_addr']|default(\"unknown\"))
}}:{{web_port}}/{{ url_locale|default(\"en-GB\")
}}/manager/system/clustering\">Cluster Master\n {%- elif role_name ==
\"role_deployment_server\" -%}\n <a class=\"btn btn-success\"
target=\"_blank\" href=\"{{ url }}{{
hostvars[hostname]['public_dns_name']|default(hostvars[hostname]['ip_addr']|default(\"unknown\"))
}}:{{web_port}}/{{ url_locale|default(\"en-GB\")
}}/manager/system/deploymentserver\">Deployment Server\n {%- elif
role_name == \"role_deployer\" -%}\n <a class=\"btn btn-success\"
target=\"_blank\" href=\"{{ url }}{{
hostvars[hostname]['public_dns_name']|default(hostvars[hostname]['ip_addr']|default(\"unknown\"))
}}:{{web_port}}/{{ url_locale|default(\"en-GB\")
}}/app/launcher/home\">Deployer\n {%- elif role_name ==
\"role_monitoring_console\" -%}\n <a class=\"btn btn-success\"
target=\"_blank\" href=\"{{ url }}{{
hostvars[hostname]['public_dns_name']|default(hostvars[hostname]['ip_addr']|default(\"unknown\"))
}}:{{web_port}}/{{ url_locale|default(\"en-GB\")
}}/app/splunk_monitoring_console\">Monitoring Console\n {%- elif
role_name == \"role_heavy_forwarder\" -%}\n <a class=\"btn btn-success\"
target=\"_blank\" href=\"{{ url }}{{
hostvars[hostname]['public_dns_name']|default(hostvars[hostname]['ip_addr']|default(\"unknown\"))
}}:{{web_port}}/{{ url_locale|default(\"en-GB\")
}}/app/launcher/home\">Heavy Forwarder\n {%- elif role_name ==
\"role_universal_forwarder\" -%}\n <span class=\"d-inline-block\"
tabindex=\"0\" data-toggle=\"tooltip\" title=\"No web access on universal
forwarder\">\n <button class=\"btn btn-primary\" style=\"pointer-events:
none;\" type=\"button\" disabled=\"\">Universal Forwarder\n
\n {%- elif role_name == \"role_universal_forwarder_windows\" -%}\n
<span class=\"d-inline-block\" tabindex=\"0\" data-toggle=\"tooltip\"
title=\"No web access on universal forwarder\">\n <button class=\"btn
btn-primary\" style=\"pointer-events: none;\" type=\"button\"
disabled=\"\">Universal Forwarder (Windows)\n \n {%- endif
-%}\n {%- endif -%}\n {%- endfor -%}\n \n \n \n {%-
endfor -%}\n {%- endfor -%}\n \n \n \n
Hi Marco,
by executing the ansible-playbook ansible/deploy_site.yml i got the following error by the task:
TASK [splunk_control : Create Splunk Hosts index.html] *************************************************************************************************************************************************************************************************************************************** fatal: [localhost]: FAILED! => {"changed": false, "msg": "AnsibleError: template error while templating string: no test named 'true'. String: <!doctype html>\n<html lang=\"en\">\n <head>\n <!-- Required meta tags -->\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">\n\n <!-- Bootstrap CSS -->\n <link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css\" integrity=\"sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l\" crossorigin=\"anonymous\">\n\n <title>Splunkenizer Host List</title>\n </head>\n <body>\n\n <div class=\"container-fluid\" class=\"mx-auto\" class=\"border border-primary\">\n <h1><p class=\"text-center\">Splunkenizer Host List</p></h1>\n </div>\n\n <div class=\"container-fluid\">\n <div class=\"row\">\n {%- for splunk_env in groups|map('regex_search','splunk_env_.*')|select('string')|list -%}\n {%- for hostname in groups[splunk_env] -%}\n <div class=\"col-sm-3\">\n <div class=\"card text-white bg-secondary mb-3\">\n <div class=\"card-header\">{{ hostname }}</div>\n <div class=\"card-body\">\n <p class=\"card-text\">Env: {{ hostvars[hostname]['splunk_env_name'] }}</p>\n <p class=\"card-text\">IP Addr: {{ hostvars[hostname]['ip_addr']|default(\"unknown\") }}</p>\n </div>\n <div class=\"card-footer\">\n {%- set web_port = '8000' -%}\n {%- if hostvars[hostname]['splunk_ssl']['web']['enable'] is true -%}\n {%- set url = 'https://' -%}\n {%- else -%}\n {%- set url = 'http://' -%}\n {%- endif -%}\n {%- for role_name in groups|map('regex_search','role_.*')|select('string')|list -%}\n {%- if hostname in groups[role_name] -%}\n {%- if role_name == \"role_search_head\" -%}\n <a class=\"btn btn-success\" target=\"_blank\" href=\"{{ url }}{{ hostvars[hostname]['public_dns_name']|default(hostvars[hostname]['ip_addr']|default(\"unknown\")) }}:{{web_port}}/{{ url_locale|default(\"en-GB\") }}/app/launcher/home\">Search Head</a>\n {%- elif role_name == \"role_indexer\" -%}\n <span class=\"d-inline-block\" tabindex=\"0\" data-toggle=\"tooltip\" title=\"No web access on indexer\">\n <button class=\"btn btn-primary\" style=\"pointer-events: none;\" type=\"button\" disabled=\"\">Indexer</button>\n </span>\n {%- elif role_name == \"role_license_master\" -%}\n <a class=\"btn btn-success\" target=\"_blank\" href=\"{{ url }}{{ hostvars[hostname]['public_dns_name']|default(hostvars[hostname]['ip_addr']|default(\"unknown\")) }}:{{web_port}}/{{ url_locale|default(\"en-GB\") }}/manager/system/licensing\">License Master</a>\n {%- elif role_name == \"role_cluster_master\" -%}\n <a class=\"btn btn-success\" target=\"_blank\" href=\"{{ url }}{{ hostvars[hostname]['public_dns_name']|default(hostvars[hostname]['ip_addr']|default(\"unknown\")) }}:{{web_port}}/{{ url_locale|default(\"en-GB\") }}/manager/system/clustering\">Cluster Master</a>\n {%- elif role_name == \"role_deployment_server\" -%}\n <a class=\"btn btn-success\" target=\"_blank\" href=\"{{ url }}{{ hostvars[hostname]['public_dns_name']|default(hostvars[hostname]['ip_addr']|default(\"unknown\")) }}:{{web_port}}/{{ url_locale|default(\"en-GB\") }}/manager/system/deploymentserver\">Deployment Server</a>\n {%- elif role_name == \"role_deployer\" -%}\n <a class=\"btn btn-success\" target=\"_blank\" href=\"{{ url }}{{ hostvars[hostname]['public_dns_name']|default(hostvars[hostname]['ip_addr']|default(\"unknown\")) }}:{{web_port}}/{{ url_locale|default(\"en-GB\") }}/app/launcher/home\">Deployer</a>\n {%- elif role_name == \"role_monitoring_console\" -%}\n <a class=\"btn btn-success\" target=\"_blank\" href=\"{{ url }}{{ hostvars[hostname]['public_dns_name']|default(hostvars[hostname]['ip_addr']|default(\"unknown\")) }}:{{web_port}}/{{ url_locale|default(\"en-GB\") }}/app/splunk_monitoring_console\">Monitoring Console</a>\n {%- elif role_name == \"role_heavy_forwarder\" -%}\n <a class=\"btn btn-success\" target=\"_blank\" href=\"{{ url }}{{ hostvars[hostname]['public_dns_name']|default(hostvars[hostname]['ip_addr']|default(\"unknown\")) }}:{{web_port}}/{{ url_locale|default(\"en-GB\") }}/app/launcher/home\">Heavy Forwarder</a>\n {%- elif role_name == \"role_universal_forwarder\" -%}\n <span class=\"d-inline-block\" tabindex=\"0\" data-toggle=\"tooltip\" title=\"No web access on universal forwarder\">\n <button class=\"btn btn-primary\" style=\"pointer-events: none;\" type=\"button\" disabled=\"\">Universal Forwarder</button>\n </span>\n {%- elif role_name == \"role_universal_forwarder_windows\" -%}\n <span class=\"d-inline-block\" tabindex=\"0\" data-toggle=\"tooltip\" title=\"No web access on universal forwarder\">\n <button class=\"btn btn-primary\" style=\"pointer-events: none;\" type=\"button\" disabled=\"\">Universal Forwarder (Windows)</button>\n </span>\n {%- endif -%}\n {%- endif -%}\n {%- endfor -%}\n </div>\n </div>\n </div>\n {%- endfor -%}\n {%- endfor -%}\n </div>\n </div>\n </body>\n</html>\n"}
Tested this with single node and cluster. There are no custom modifications done. Only copied files from examples to config.
OS: CentOS 8 Ansible: 2.9.25 Python: 3.6.8