How to use variables set in inventory file for the hostname /group

28 views
Skip to first unread message

Victor Sava

unread,
Jun 24, 2019, 10:23:38 AM6/24/19
to Ansible Project
Hello

I have this inventory file:

/etc/ansible/inventory/inventory-file
[my-group]
myhost
.com project=my group=group


[my-group:vars]
project
=my
group=my-group

and this is my playbook

- hosts: '{{ host }}'
  gather_facts
: yes
 


  roles
:
   
- role: collectd
      vars
:
       
group: {{ project }}
        project
: {{ group }}
 


But for some reason ansible cant read those variables, can i know how i can access this variables ?

<Plugin write_graphite>
{% if project == "my" %}
<Node "my_graphite">
  Host "my_host"
{% elif project == "11" or project == "22" %}
<Node "11">
  Host "22"


I will be using this variables to create a flexible tempalte file

 
Reply all
Reply to author
Forward
0 new messages