Questions tagged [jinja2]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
48 views

How to merge two files into single file using ansible in remote server

I need to merge two files without duplicate entries in it. is there any way i can achieve it through ansible modules. Ex i have two files /etc/hosts1 and /etc/hosts2. I need to have one /etc/hosts ...
0
votes
3answers
246 views

Ansible check if variable exists in attribute list

I have a variable containing details of host machines on my network (called 'hostlist' - I believe you call this a dictionary, but I'm not sure of the terminology. The variable is defined in a file in ...
0
votes
1answer
62 views

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 ...
2
votes
2answers
101 views

How to pass a group value in inventory file to jinja2 template file in ansible

I have an inventory file named hospital.inventory and it contains following group with a single value. [dockerSwarmManager] hp2-3.mydomain.com Then I have a file name security.json.j2 inside the ...
0
votes
1answer
131 views

Use lookup/dynamic variable names in Ansible jinja2 template

The playbook below should generate a file with the content: a,b ssh_host_key ssh_rsa_host_key However, the way I construct the variable names results in either syntax/templating errors or 'variable ...
1
vote
1answer
89 views

When using an Ansible playbook, how do you store and use a password containing quotes or other metacharacters without them being interpereted?

My company uses Ansible (which I am a novice at) and we have a playbook and a related role for joining new Linux machines to AD. Our admin accounts have their passwords rolled three times a day, and ...
1
vote
2answers
351 views

ansible/jinja2 reject all items from list of dicts with specific attribute

I have a list of dicts like this: list_of_dicts: - name: Item1 - name: Item2 type: special - name: Item3 - name: Item4 type: small As you can see, not all items have a type attribute....