# how to get the server Site & location name get automatically when playbook will run

**URL:** <https://forum.ansible.com/t/how-to-get-the-server-site-location-name-get-automatically-when-playbook-will-run/25861>\
**Category:** Ansible Project\
**Created:** [October 30, 2017, 9:32am UTC](https://forum.ansible.com/t/how-to-get-the-server-site-location-name-get-automatically-when-playbook-will-run/25861 "2017-10-30T09:32:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karn\_Kumar](https://avatars.discourse-cdn.com/v4/letter/k/87869e/32.png) [@Karn\_Kumar](https://forum.ansible.com/u/Karn_Kumar)\
**Post date:** [October 30, 2017, 9:32am UTC](https://forum.ansible.com/t/how-to-get-the-server-site-location-name-get-automatically-when-playbook-will-run/25861/1 "2017-10-30T09:32:08Z")

</div>

I’m instaling collectd service using ansible version 2.4 and making some changes into the colectd config and that’s working fine.  
In my playbook i’m using `lineinfile` module to make the chnages in the collectd confg file using the regex , here i have two `lineinfile` chnages one is to chnage  
the default Hostname from the config file using `ansible_hostname` variable while in another line i have some Prefix’s which i’m changing and that the Key point for my playbook…

For clarification belwo the line where i need the playbook to be opting the values dynamically  
Example:  
a) this is what is value looks like  
Prefix “collectd..\<Changable\_StateName\>.\<Changable\_location\>”  
b) this is what i’m appending values manually in my play as of now …  
Prefix "collectd.OpenDJ.EMEA.sophia.

My Invetory looks like as follows( this is based on host:var and using private keys over)
