Questions tagged [jinja2]
23 questions
0
votes
2 answers
conditional statements should not include jinja2 with dictionary list
How do I get rid of this warning?
The task works as expected but I would like to do it correctly
I have tried to fish out the value for ansible_facts.services["{{ component }}.service"].state and save it in a variable without any success.
---
-…

Nifle
- 374
- 1
- 8
- 22
0
votes
0 answers
Ansible- Define variables based on conditions with if elif else
I have multiple roles as follows : haproxy, java, nginx, tomcat
├── ansible-test-host.yml
├── hapoxy
├── java
├── myplaybook.yml
├── nginx
└── tomcat
Base playbook is : myplaybook.yml and looks like below:
---
- hosts: test-local
connection:…

SAGAR Nair
- 133
- 1
- 8
0
votes
1 answer
Ansible jinja2 template from JSON format provided as extra-vars
I have this jinja2 template:
# {{ ansible_managed }}
{% for vhost in nginx_vhosts %}
{%- if vhost.name == item.name -%}
# redirect www to non-www
server {
listen {{ nginx_port }};
listen [::]:{{ nginx_port }};
port_in_redirect off;
…

Bogdan Stoica
- 403
- 4
- 9
0
votes
2 answers
ansible - template json for environmental variable in docker container
I'm trying to assign a one-liner json string to an environmental variable in a docker container.
This is what the json look like:
{"ip_access": {"IP_whitelist": {"192.168.99.19/32": "grafana/status (Provider)"}}, "vhosts": {"prometheus1":…

Lethargos
- 455
- 2
- 7
- 19
0
votes
3 answers
templating file with ansible to get different variable parts (through its index) for different hosts
I'm trying to distribute certificates to its corresponding hosts (I'll just give the example for the private key task):
- name: create certificate private key
community.crypto.openssl_privatekey:
path: "/root/client/{{ item }}.key"
type:…

Lethargos
- 455
- 2
- 7
- 19
0
votes
1 answer
Ansible webserver backup: pull other host vars to generate backup scripts
I'm using Ansible to manage a fleet of dissimilar cloud linux servers. I built a script that pulls backups down to a backup server via rync over ssh. All of the host vars are managed in host_vars/example.com.yml files, each containing the…

deliriouspuppet
- 1
- 1
0
votes
2 answers
Templating firewalld zones with ansible - issue with xml or vars
Templating firewalld zones with ansible - issue with xml manipulation
I am running into a small bit of confusion for the rule family.
whats in my CORRECTED vars file:
firewalld_zones:
- name: public
short: "Public"
description: "Public…

Wipiid
- 1
- 2
0
votes
1 answer
Ansible - copying and editing a remote file at the same time?
In an Ansible role, I'm looking for a way to copy a remote file to a different location, while also replacing the first two lines of the file.
I'm open to other approaches, but my solution involves using slurp to retrieve the file, somehow convert…

Kevin Keane
- 900
- 1
- 8
- 13