Skip to content

Instantly share code, notes, and snippets.

@BrianGallew
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrianGallew/bb5dfcdc4ff1dab0e6ce to your computer and use it in GitHub Desktop.
Save BrianGallew/bb5dfcdc4ff1dab0e6ce to your computer and use it in GitHub Desktop.
{% from "zookeeper/map.jinja" import zookeeper, zookeeper_environment with context %}
# [CHOMP lots of other stuff]
my_zookeeper_environment: {{ zookeeper_environment }}
# map.jinja
{% set tags = salt['grains.get']('cornerstone.tags') -%}
{% set zookeeper_environment = tags %}
{% for my_tag in salt['grains.get']('cornerstone.tags') -%}
{% set zookeeper_environment = my_tag -%}
{% endfor -%}
# init.sls pulls in the map thusly
my_zookeeper_environment: ['zookeeper-env-qa-1']
@BrianGallew
Copy link
Author

Per whytewolf, I altered map.jinja to look like this:

{% set zookeeper_environment = tags %}

{% for my_tag in salt['grains.get']('cornerstone.tags') -%}
{% set zookeeper_environment = my_tag -%}
{% endfor -%}

The behavior is the same:

@whytewolf
Copy link

# map.jinja
{% set tags = grains['cornerstone.tags'] -%}
{% set zookeeper_environment = tags %}

{% for my_tag in grains['cornerstone.tags'] -%}
{% set zookeeper_environment = my_tag -%}


# init.sls pulls in the map thusly
{% from "zookeeper/map.jinja" import zookeeper, zookeeper_environment with context %}

# and this is how {{ zookeeper_environment }} expands
        my_zookeeper_environment: ['zookeeper-env-qa-1']

{% endfor -%}

@BrianGallew
Copy link
Author

OK, this is insane. I have another file (zoo.cfg) which is managed. If I change the list at the end to look like this:

server.{{loop.index}}={{servername}}:{{peer_port}}:{{election_port}}
{%- endfor %}

It works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment