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.

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.

24 questions
25
votes
2 answers

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 In principle, it should be possible to, somehow…
Michael Mol
  • 1,045
  • 1
  • 8
  • 19
7
votes
2 answers

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 'components' in pillar.items() %} include: {% for…
Michael Mol
  • 1,045
  • 1
  • 8
  • 19
6
votes
2 answers

Ansible Jinja template if statement

This is a snippet from my Ansible jinja template which populates an environment specific template. docker_compose_mq: docker_compose_profiles: "string" {% if "{{ risk_docker_compose_mq }}" == "string" %} {% "{{…
jto
  • 378
  • 1
  • 6
  • 19
5
votes
1 answer

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 jinja2 template: {% for host in groups['zookeeper']…
Marged
  • 183
  • 6
5
votes
4 answers

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 is not possible to validate a yaml file in which…
Pier
  • 344
  • 4
  • 16
5
votes
1 answer

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
  • 13,383
  • 17
  • 76
  • 178
5
votes
1 answer

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 {% include 'hosts/' + salt['grains.get']('fqdn') + '.sls'…
Michael Mol
  • 1,045
  • 1
  • 8
  • 19
2
votes
1 answer

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 separately. Example of playbook to deploy to a…
user2818782
  • 151
  • 5
2
votes
1 answer

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 version with pip3 list, but Ansible is still using Jinja…
kenorb
  • 8,011
  • 14
  • 43
  • 80
2
votes
3 answers

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: The conditional check 'aptitude_installed is…
Richard Slater
  • 11,747
  • 7
  • 43
  • 82
2
votes
1 answer

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 } I will be using this variable in Jinja template…
Nahush
  • 121
  • 1
  • 3
2
votes
1 answer

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'. As the webservers are different (same underlying…
jto
  • 378
  • 1
  • 6
  • 19
2
votes
1 answer

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: service: control: - name: "bldr0cuomdev01" …
Freejack
  • 21
  • 3
2
votes
1 answer

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 missing endif tag. Any help please? CODE: {% if…
user22405
  • 29
  • 1
1
vote
2 answers

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: - spot - snowy hamsters: -…
Sam
  • 111
  • 2
1
2