ansible-template Questions

2

I am trying to set a variable in Ansible with set_fact at runtime based upon another variable. If uses first value no matter what the actual value is. Here is my code example: - name: Global_vars ...
Nitwit asked 21/3, 2017 at 18:52

1

Solved

I have the next snippet in my role template: upstream portal { {% set nodes = groups["my_dev_cluster"] %} {% for node in nodes %} ...do something with nodes... {% endfor %} } And it works we...
Stereochrome asked 7/12, 2017 at 15:16

2

Solved

I'm passing env variables to a Docker container in an ansible playbook, how do I set an Ansible variable in the key in the key/value of an env? So this: - name: webproxy container docker_contain...
Cognoscenti asked 8/11, 2017 at 5:58

3

Solved

Couldn't find anything google'ing. There is group_vars/all/ for variables. Is there something similar for templates? I would like to use some templates across multiple roles.
Willamina asked 25/9, 2017 at 2:19

1

Solved

Most of my locations have 4+ DNS sources, but a few have less. Each location gets their own dns4_ips list variable like this: dns4_ips: - dns_A - dns_B - dns_C - dns_C My resolv.conf templat...
Pantograph asked 3/10, 2017 at 21:37

1

I am writing automation with this type of Ansible inventory: [nodes] <publicIp1> privateIp=<privateIp1> <publicIp2> privateIp=<privateIp2> I do this because sometimes hos...
Croom asked 10/7, 2017 at 1:23

1

I'm not able to do a very simple thing. In my task I'm trying to concat two default variables with a literal string to create a path - name: "Uploading File" copy: src: "{{ installer_iso_src_l...
Entrammel asked 21/6, 2017 at 21:36

1

Solved

I am using a simple template with only variables in it. This is how my task looks like in my playbook (actually a role being used from my playbook): - name: Ensure the conf file exists template: ...
Manche asked 29/3, 2017 at 4:15

1

I am generating config files and I want them to be indented just so. I started with a Jinja2 template that rendered correctly when called from a simple python program. When I call it from ansible, ...
Minneapolis asked 20/3, 2017 at 21:31

1

Solved

I'm trying to create files that have values that match their with_items values. I have a var list like so: sites: - domain: google.com cname: blue - domain: facebook.com cname: green - doma...
Gombosi asked 17/3, 2017 at 0:56

1

Solved

I have an Ansible playbook that sets a lot of variables. One the playbooks has this task: - name: create config file template: src: 'templates/main_config.j2' dest: "{{ tmp_dir }}/main_config....
Fusty asked 13/3, 2017 at 9:18

1

Solved

is it possible to use the result of Jinja2 filters in conditions in ansible playbooks? I'm trying to get this working, but without success: {% if (item | ipv4) %}{{ item }}{% else %}{{ lookup('di...
Blinkers asked 2/3, 2017 at 12:58

1

Solved

I want to have a simple if else condition in ansibles jinja templates. For plain python cluster_name+'A' if isCondition is True else cluster_name +'B' wors great if the following variables are d...
Dill asked 9/2, 2017 at 15:43

1

Solved

I have a fairly simple playbook which creates authorized_keys entries for a given user in Ansible: - name: chat user authorized keys authorized_key: user: chat key: | {% for filename in looku...
Kho asked 25/1, 2017 at 3:23

1

Solved

I have the following vars inside of my ansible playbook I got the following structure domains: - { main: 'local1.com', sans: ['test.local1.com', 'test2.local.com'] } - { main: 'local3.com' } - ...
Nationality asked 7/1, 2017 at 11:52

1

Solved

Is there a way to render Ansible template into the fact? I tried to find a solution but it looks like temp file is the the only way.
Latrinalatrine asked 2/1, 2017 at 10:25

1

Solved

I'm writing an Ansible template that needs to produce a list of ip's in a host group, excluding the current hosts IP. I've searched around online and through the documentation but I could not find ...
Frankforter asked 19/11, 2016 at 17:56

1

Solved

I am getting value of variable "env" in Jinja2 template file using a variable defined in group_vars like: env: "{{ defined_variable.split('-')[0] }}" env possible three values could be abc, def,...
Hid asked 17/10, 2016 at 12:39

1

Solved

I'm generating a Behat config file using Ansible. This configuration file is a YAML file. I'm using a Jinja2 template like this: default: paths: features: '../all/tests/features' filters: tags...
Antipope asked 30/11, 2015 at 17:13

1

I have the following task: - name: copy server.xml template: src=server.xml dest=/var/containers/{{ item.key }}/conf with_dict: containers And I've also added the containers dictionary in my g...
Miyamoto asked 24/9, 2014 at 15:10

2

Solved

based on the following ansible playbook values .. target: "actual.domain.com" aliases: - "alias1.domain.com" - "alias2.domain.com" I am trying to setup an ansible template to produce the nginx...
Tombouctou asked 1/1, 2015 at 18:32

© 2022 - 2024 — McMap. All rights reserved.