Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Questions tagged [jinja]

The tag has no usage guidance.

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

converting two lists into a specific dictionary so it can be sorted

I want to convert the following lists: rtt: [38,1,97] site: ["A","B","C"] into a dictionary like: dict: [ {'rtt':38, 'site':'A'},{'rtt':1, 'site':'B'},{'rtt':97,'site':'C'}] so i can sort it on ...
0
votes
1answer
31 views

Loop through salt pillar to create file without knowing keys

Background: I need to make an XML file like this: <?xml version="1.0"?> <configuration> <appSettings> <add key="BaseOU" value="DC=myplace,DC=wan" /> <add key="...
0
votes
0answers
51 views

Set variable from cmd.run in jinja + saltstack on Windows Minion

I am trying to set a variable in jinja when a task in task scheduler is found on the Windows Minion. Tried many things but dont seem to get this working yet. here is the code that I have {% set ...
0
votes
0answers
22 views

Is it possible to use Jinja in a SLS file and create a dependency relation with other states?

I have an interesting problem to solve using SaltStack 2016.3. I need to set a Jinja variable to collect some runtime parameters in the minion, but the problem is that these parameters depend on the ...
1
vote
1answer
261 views

Reject in ansible list variable

I have such a variable: apps: - {name: kapitalism, extension: .war} - {name: socialism, extension: .war} - {name: somethingelse, extension: .ear} And I need to make another one based on it, which ...
1
vote
0answers
676 views

Ansible: Loop over registered output in the next task

Ansible version: ansible 2.6.2 python version 2.7.5 I am struggling to loop over registered IP addresses from one task in other using with_items and have a debug output from an ansible playbook which ...
1
vote
1answer
2k views

Ansible: How to get a subelement of a nested list of dictionaries

I'd like to build our DNS zones via Ansible. The user should just maintain one variable for the forward-lookup zones (e.g. foo.bar). Reverse-lookup zones (0.0.10.in-appr.arpa) should be auto-generated ...
0
votes
0answers
75 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 %} {%- ...
0
votes
1answer
162 views

Jinja “for loop” statement with multiple lines (saltstack)

When using salt for specifying user creation, it is unorganized to have the for statement in a single line. Example: {% for USR in 'hewey','dewey','loui' %} Is it possible to break this into ...
0
votes
1answer
104 views

Haproxy healthcheck and backend section generation

I have a lot of sites and I want to do a http healthcheck for each one. Does it mean that I need to make a backend section for each site? If so, I need to generate it somehow. Can I achieve it with ...
0
votes
0answers
2k views

Avoiding jinja templating delimiter in when statements

I'm currently porting my Ansible playbooks from version 2.1 to 2.7. Ansible now prints a warning if I use jinja templating delmiters such as {{ .. }} in a when clause. [WARNING]: when statements ...
0
votes
2answers
145 views

Saltstack state.apply determine whether it is being run in test=True mode ?

We are using serverdensity (BETA MODULE - https://docs.saltstack.com/en/latest/ref/states/all/salt.states.serverdensity_device.html) with salt and have hit the (bug?) where if you try a : salt '*...
0
votes
1answer
295 views

Ansible - manage installed apps and send output via email - variables are filling wrong

so i have this playbook, which checking, if there are installed selected packages. nothing special there. Then i would like to send an output to my email, if everything went right etc. --- - name: ...
1
vote
1answer
4k views

use a variable inside json_query in ansible/jinja

I'm trying to loop on a custom dictionary in ansible in order to check some mount points on a linux server, and I'm a little bit in trouble finding the correct solution, find below my playbook right ...
16
votes
6answers
29k views

Ansible: Conditionally define variables in vars file if a certain condition is met

Depending on the value(True/False) of a variable defined into the group_vars I am trying to define some variables in a vars file. Their value depends on the group var's value. My current var file ...
2
votes
1answer
1k views

Ansible:how to adapt the output format of map (with extract) filters

I am trying to extract the IP addresses of the hosts that are part of two groups and use them in a .xml config file. The problem I'm facing here is the output generated by the expression used into ...
0
votes
1answer
407 views

How to expand jinja inside imports for GCP Deployment Manager

I have a Deployment Manager template/schema and I want to dynamically include different startup-script options for cloud-init depending on the template.yaml I am calling. In my template.jinja I have: ...
0
votes
1answer
107 views

How do I use debconf in salt with pillars?

I have the following: newrelic-debconf: debconf.set: - name: newrelic-php5 - data: 'newrelic-php5/application-name': { 'type': 'string', 'value': '{{ salt['pillar.get']('newrelic:...
0
votes
1answer
619 views

How to pass urlencoded string to jenkins api using ansible?

I have to pass value to jenkins api. But jenkins api accept value in urlencode. I tried to use filter urlencode in ansible, but it gives error. - name: Add credential to add node uri: body: | ...
10
votes
1answer
31k views

Loop over Ansible variable array in Jinja2 template

when Ansible gathers facts about hosts, it for example gets all the mounts of the host: "ansible_mounts": [ { "block_available": 7800291, "block_size": ...
2
votes
1answer
8k views

SaltStack | How to assign the shell output from cmd.run to Jinja variable?

Problem Unable to assign the output from cmd.run in my Salt State. The condition always return true even if the load_avg in the minion is not really equal or beyond the threshold. I also included in ...
5
votes
1answer
2k views

How to trigger a custom error from inside a Jinja template?

Though Ansible itself has a way for triggering a custom error, I can not find anything similar for Jinja. My current method uses a syntax error: {% if 'ansible_mounts' in hostvars[host] %} # {{ ...
3
votes
1answer
6k views

How to do multiline Jinja2 conditionals in single block? [closed]

The below code is rejected as syntactically incorrect: {% if inventory_hostname in groups.aptcache set cachehost = 'localhost' else set cachehost = groups['aptcache'] | first ...