Questions tagged [jinja]

Jinja2 is a full featured template engine for Python. It has full unicode support, an optional integrated sandboxed execution environment, widely used and BSD licensed.

Filter by
Sorted by
Tagged with
2
votes
0answers
33 views

Jinja syntax error: missing endif, in spite of providing it

I am using Salt 2019.2.0 version and below is my state file where I am using if condition to check the values and run states if it's a match. Even if I have provided endif, it says Jinja looking for ...
2
votes
0answers
184 views

How to programmatically generate docker-compose file? [closed]

I am writing an Ansible playbook to deploy services to a clustered environment. There are 3 types of hosts (Application, Load balancer, database). Services are deployed via docker-compose on each host ...
1
vote
1answer
303 views

Ansible fetch all vars files from a directory to generate a combined vars file

What I'm looking for is a task (or tasks) to read whatever .yml files exist in a specified folder and combine them into a file containing all the variables. For example: pets/steves_pets.yml: cats: ...
1
vote
1answer
136 views

How to downgrade Jinja for Ansible?

I'm using Ansible 2.8.0 (ansible --version installed by brew on macOS) which is using Jinja 2.10. I've tried to downgrade Jinja to 2.8 via pip3 install jinja2==2.8, and I can confirm the right ...
2
votes
3answers
442 views

Ansible playbook fails with: no test named 'success'

I have an Ansible Playbook that is used to configure WSL on my Windows Laptop, having rebuilt my laptop recently I needed to run the playbook again, however it is failing with the following message: ...
1
vote
1answer
48 views

How do I get the hosts from a specific section of an Ansible `hosts` file in a Jinja2 Template

I have a hosts file including the following contents [elasticsearch_nodes] host1 os=linux host2 os=linux host3 os=linux In a .j2 template I want to get the the list of [elasticsearch_nodes] {{ ...
1
vote
1answer
786 views

Saltstack Jinja template pillar merge

I have a several pillars and I am trying to merge them in the same jinja variable {%- import_yaml "server_list_de.yaml" as servers %} {%- import_yaml "server_list_uk.yaml" as servers_uk %} {%- ...
1
vote
1answer
52 views

How to add multiple jvm options in a saltstack jinja?

I have a config.jinja file with below jvm options: `-Dappdynamics.agent.appName=AP_{{ pillar['region'] }}` However the AP_{{ pillar['region'] }} varies for different environments. For Dev/Prod it ...
4
votes
1answer
412 views

Configuring Zookeeper from Ansible

I'm trying to configure a Zookeeper Cluster with Ansible. As you might know Zookeeper has two important config files. zookeeper/conf/zoo.cfg I create this file on each cluster member using this ...
5
votes
2answers
15k views

Ansible Jinja template if statement

This is a snippet from my Ansible jinja template which populates an environment specific template. docker_compose_mq: <string-passed from Jenkins> docker_compose_profiles: "string" {% if "{{ ...
3
votes
3answers
642 views

Yaml linting failling when jinja is used

I am using https://yamllint.readthedocs.io/en/stable/index.html to lint my yaml files (used in a saltstack context, and linted by jenkins jobs at every commit), but as reported and explained here, it ...
2
votes
1answer
3k views

Compare Strings to get Unique values in Jinja2

I have a variable with list of node IP's and its respective Availability Zone. seed = { 10.18.13.12 = us-east-1a 10.18.37.93 = us-east-1b 10.18.68.147 = us-east-1a 10.18.21.55 = us-east-1b } ...
1
vote
1answer
39 views

Salt State is running against all servers except one, why?

I recently asked a question here: Is it possible to use multiple if statements in a salt state? Thanks to the answer I have managed to update my state to only check specific files exist on specific ...
2
votes
1answer
4k views

Is it possible to use multiple if statements in a salt state?

I have a Salt state which checks multiple files exist on our webservers, we have 4 webservers and 2 environments so a combined total of 8. This state is applied to all by using a grain 'webserver'. ...
4
votes
1answer
2k views

Is it possible to combine jinja templates in ansible like this is possible with erbs in puppet?

It is possible to include a subtemplate in another Puppet template. <%= scope.function_template("subtemplate.erb") %>
5
votes
1answer
2k views

Securely grab minion ID in pillar top file template?

I found this SLS file in a pillar top.sls targeting example: top.sls: base: '*': - hostspecificsls hostspecificsls: # See https://groups.google.com/forum/#!topic/salt-users/UWfP6bMe6F8 {% ...
18
votes
2answers
11k views

How to examine Jinja output in Saltstack?

I have a templated SLS in Salt I'm trying to build, but it's emitting invalid syntax, which is resulting in errors such as: my-minion-id: - State 'system' in SLS 'network' is not formed as a list ...
7
votes
2answers
780 views

Constructing Dependencies from a Pillar in Saltstack

I'm trying to create a dummy state in Salt to pull dependencies from a list derived from a pillar. In my top.sls file, I have: base: '*': - components Then, in components.sls, I have: {% if '...