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
0 votes
1 answer
1k views

Ansible / Jinja2 Unexpected templating type error

I am trying to take a dictionary from one or more async tasks "register: task_variable" then collecting it as a list based on its id's and running a wait task using async_status on the ...
Cyber Axe's user avatar
2 votes
1 answer
838 views

How to access elements of a variable in ansible

I'm trying to access a specific value in a list of data and it fails, can't find the ipa variable. Here is a short bit of the boulder.yaml vars file, yes, dual homed. Network configurations require it:...
Freejack's user avatar
1 vote
1 answer
430 views

How Can I Escape Backspace Using Set_Fact In Ansible With Jinja Conditional

I cannot figure out how to escape an HTML closing tag, <\b> in this example, when used inside an Ansible Jinja conditional (ansible 2.9.27 in this case). Using an additional backslash <\\b>...
alteredstate's user avatar
1 vote
2 answers
1k views

ansible & jinja2: How to reference JSON structure items whose keys are variables?

I am using ansible's community.aws.iam_server_certificate_info module to get information about a server certificate on aws ec2, and registering it as a variable "server_cert_info_result" ...
Life5ign's user avatar
  • 128
2 votes
1 answer
753 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 ...
user22405's user avatar
2 votes
1 answer
1k views

How to programmatically generate docker-compose file?

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 ...
user2818782's user avatar
1 vote
2 answers
2k 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: ...
Sam's user avatar
  • 111
2 votes
1 answer
2k 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 ...
kenorb's user avatar
  • 7,841
2 votes
3 answers
3k 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: ...
Richard Slater's user avatar
1 vote
1 answer
803 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] {{ ...
David West's user avatar
1 vote
1 answer
2k 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 %} {%- ...
BlackBishop's user avatar
1 vote
1 answer
146 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 ...
Narasimha's user avatar
4 votes
1 answer
795 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 ...
Marged's user avatar
  • 163
6 votes
2 answers
29k 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 "{{ ...
jto's user avatar
  • 378
5 votes
4 answers
2k 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 ...
Pier's user avatar
  • 344
2 votes
1 answer
6k 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 } ...
Nahush's user avatar
  • 21
1 vote
1 answer
55 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 ...
jto's user avatar
  • 378
2 votes
1 answer
7k 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'. ...
jto's user avatar
  • 378
5 votes
1 answer
4k 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") %>
030's user avatar
  • 13.2k
5 votes
1 answer
3k 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 {% ...
Michael Mol's user avatar
  • 1,045
25 votes
2 answers
16k 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 ...
Michael Mol's user avatar
  • 1,045
7 votes
2 answers
1k 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 '...
Michael Mol's user avatar
  • 1,045