ansible-template Questions
10
I want to recursively copy over a directory and render all .j2 files in there as templates. For this I am currently using the following lines:
- template: >
src=/src/conf.d/{{ item }}
dest=/de...
Menstruate asked 5/5, 2013 at 14:27
7
Solved
Below is the jinja2 template that i wrote to use in ansible.
{% set port = 1234 %}
{% set server_ip = [] %}
{% for ip in host_ip %}
{% do server_ip.append({{ ip }}:{{ port }}) %}
{% endfor %}
{% s...
Monroe asked 2/4, 2018 at 22:5
14
Solved
How do you get the current host's IP address in a role?
I know you can get the list of groups the host is a member of and the hostname of the host but I am unable to find a solution to getting the...
Graphite asked 2/10, 2016 at 16:54
3
Solved
I merged two lists from an Ansible inventory:
set_fact:
fact1: "{{ groups['group1'] + groups[group2']|list }}
The output is:
fact1:
- server01
- server02
- server03
With the above results...
Electroencephalograph asked 1/11, 2017 at 3:40
2
Solved
Here is inventory file.
[abc]
host1
host2
[123]
host3
And main.yml
#play1
- hosts: abc
roles:
- { role: abc }
tasks:
...
#play2
- hosts: 123
roles:
- { role: 123 }
tasks:
debug: msg...
Colner asked 12/6, 2020 at 17:16
3
Solved
I'm trying to set up a server with ansible and I'd like to use this galaxy role.
It defines a template that I'd like to customize, but I don't know how.
Right now I defined the role into requirem...
Gingivitis asked 18/4, 2019 at 9:18
1
Solved
Right now my inventory file looks like this: (using password-based authentication)
[testvm]
104.231.213.32 ansible_user=worker ansible_password=Worker@12345
52.176.22.203 ansible_user=worker2 ansib...
Zulema asked 25/7, 2022 at 13:26
5
Solved
I'm trying to loop a dictionary through an ansible template using jinja2 to create a number of datasources but receive this error [{'msg': "AnsibleUndefinedVariable: One or more undefined variables...
Disharmonious asked 10/6, 2016 at 20:20
1
Solved
I have a split function in ansible based on a delimiter. But only want to get the first occurance of the delimiter string and the rest as the second string.
string: "hello=abcd=def=asd"
s...
Estremadura asked 4/10, 2021 at 8:41
5
Solved
I believe the Ansible copy module can take a whole bunch of "files" and copy them in one hit. This I believe can be achieved by copying a directory recursively.
Can the Ansible template module tak...
Wuhu asked 16/1, 2017 at 0:21
5
Sometimes I need to test some jinja2 templates that I use in my ansible roles. What is the simplest way for doing this?
For example, I have a template (test.j2):
{% if users is defined and users ...
Yam asked 15/2, 2016 at 11:10
2
I try to start docker containers with traefik labels.
To create a traefik router for a container you have to put some labels like this.
app_names:
- tower01
- tower02
docker_labels:
awx_web:...
Loophole asked 25/5, 2020 at 20:57
1
Solved
An error occurs when preparing the template. Who can tell you how to fix it?
Variables, if necessary, can also be edited.
vars:
AllСountry:
- "name1"
- "name2"
name1:
- &q...
Headstone asked 23/11, 2020 at 21:54
6
I have my directory structure as this
.
├── README.md
├── play.yml
└── roles
├── bootstrap_server
│ └── tasks
│ └── main.yml
├── create_new_user
│ └── tasks
│ └── main.yml
├── update...
Bugbane asked 19/3, 2017 at 7:9
1
Solved
Team,
I am trying to verify if sdd exists in mount command output. so when there is any, i am fine but when there is none, my task is simply failing instead of just telling me that no mounts exis...
Noheminoil asked 26/11, 2019 at 20:11
2
Solved
I'm trying to populate nsswitch.conf with values that are determined from a list. The list is of string:
openldap_nsswitch:
- group
- hosts
- passwd
- shadow
If the string is in the list I w...
Propulsion asked 28/11, 2017 at 22:47
1
I have written an Ansible playbook that needs as one of its parameters the job number that is running it so that I make add a reference to the job to a database that I maintain. How can I get the T...
Kiushu asked 30/5, 2019 at 23:6
3
Solved
I am creating a systemd service using template module
---
- name: Systemd service
template:
src: sonar.unit.j2
dest: /etc/systemd/system/sonarqube.service
when: "ansible_service_mgr == 'system...
Auctorial asked 20/8, 2019 at 10:36
1
I have defined the nginx_upstreams variable in a different role that in turn uses the geerlingguy.nginx role and I have also specified the "name", "strategy" and the "servers", but when I run this ...
Foremast asked 2/8, 2019 at 21:3
1
Solved
In Ansible role, I'm using Jinja template to create a file with fetching value from a variable.
Contents of vars file vars/main.yml from where variables are being fetched in jinja template:
Heade...
Blythebm asked 8/8, 2019 at 18:50
8
Solved
My use case is the following :
I have a template file, and I would like to create 2 different files from that template, with the variables being filled by a different set of variables for each fi...
Intelligencer asked 30/6, 2015 at 15:24
2
Solved
How to find a match using regex in ansible playbook where variable appears in the regex_search argument?
The following playbook doesn't find the match... when run using: ansible-playbook playbook....
Waive asked 7/3, 2019 at 14:46
7
Solved
Im working on a little Ansible project in which I'm using Docker Containers.
I'll keep my question short:
I want to get the state of a running Dockercontainer!
What I mean by that is, that i wan...
Granddaddy asked 21/7, 2017 at 12:24
1
Solved
My playbook:
- name: JBoss KeyStore and Truststore passwords will be stored in the password vault
#shell: less "{{ vault }}"
shell: cat "{{ vault }}"
register: vault_contents
tags:
- BW.6.1.1...
Nilson asked 24/12, 2018 at 15:0
1
Solved
I have yml file with template. Template is a part of keys started from a middle of yml tree.
Templating works is ok, but indent is saved only for last key. How to save indent for all keys?
base.y...
Merideth asked 28/6, 2018 at 13:35
1 Next >
© 2022 - 2024 — McMap. All rights reserved.