We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
{% load_yaml as yaml %} test: dev: 'xxxxx' test_2: dev: 'yyyyy' {% endload %} {% set proj = slspath.split('/')[0] %} {% set env = slspath.split('/')[1] %} {% set service = slspath.split('/')[2] %} {% set a = yaml ~ '.' ~ proj ~ '.' ~ env %} test: cmd.run: - name: echo {{ a }}
Output:
test: cmd.run: - name: echo {'test': {'dev': 'xxxxx'}, 'test_2': {'dev': 'yyyyy'}}.test.dev <======================
Is it possible to access test yaml from dynamically created variable?
As I really want to return yaml.test.dev value no entire yaml + test.dev...
The text was updated successfully, but these errors were encountered:
yaml in your example is a dictionary/hashmap. You just access the value in a dictionary like you would any value in jinja. So your code should be
yaml
dictionary/hashmap
{%- set a = yaml[proj][env] %}
All of your example is just plain jinja (https://jinja.palletsprojects.com/en/3.0.x/templates/#variables) and really has nothing to with salt specifically except that it uses jinja for the default renderer.
Sorry, something went wrong.
Thanks! It works.
No branches or pull requests
Output:
Is it possible to access test yaml from dynamically created variable?
As I really want to return yaml.test.dev value no entire yaml + test.dev...
The text was updated successfully, but these errors were encountered: