0

I have a problem with may came up with a new Ansible version, as it worked before:

I'm passing this block to the ansible template

 - monitoring-test-blackbox_exporter:
   source: "{{ consul_template_template_dir }}/blackbox_exporter.ctmpl"
   destination: "/etc/prometheus/file_sd/blackbox_exporter.json"
   create_dest_dirs: true
   command_timeout: "60s"
   error_on_missing_key: false
   grafana_link: "xtkCtBkiz" 

This is the template:

# Template configuration
{% for ctmpl in consul_template_templates_config_node %}
# {{ ctmpl | first }}
template {
{% for option, value in ctmpl.items()  %}
{%     if value is sameas true %}
  {{ option }} = true
{%     elif value is sameas false %}
  {{ option }} = false
{%     elif value is string %}
  {{ option }} = "{{ value|string }}"
{%     elif value is number %}
  {{ option }} = {{ value|int }}
{%     endif %}
{%   endfor %} 

ctmpl | first always worked before to filter out first element monitoring-test-blackbox_exporter this is important as we use it later in the template configuration.

I tried several things with sort and select attributes neither of them worked. Does anyone have an idea to get it working again?

β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
  • 3
    Hi holger.waschke welcome to SO. Please ban the use of "it didn't work" from your vocabulary when asking for technical help, because without knowing what **did** happen versus what you _wanted_ to happen, no one can possibly help you. Please [edit your question](https://stackoverflow.com/posts/68298726/edit) and include an [MCVE](https://stackoverflow.com/help/mcve) demonstrating the error and then include any error message or relevant details. Good luck – mdaniel Jul 08 '21 at 16:18
  • 1
    Your code works for me. What is the version of Python on this node? As for the order of properties in a dict this matters. And this question might help: https://stackoverflow.com/q/1867861/2123530 – β.εηοιτ.βε Jul 08 '21 at 17:32
  • 1
    Yes, thank you, i run the playbook on a WSL with Python2 installed this caused the different behaviour. – holger.waschke Jul 08 '21 at 23:03

0 Answers0