# How to structure variables to distinguish different environments

**URL:** <https://forum.ansible.com/t/how-to-structure-variables-to-distinguish-different-environments/33298>\
**Category:** Ansible Project\
**Created:** [July 1, 2020, 6:56pm UTC](https://forum.ansible.com/t/how-to-structure-variables-to-distinguish-different-environments/33298 "2020-07-01T18:56:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xinhuan\_Zheng](https://avatars.discourse-cdn.com/v4/letter/x/a88e57/32.png) [@Xinhuan\_Zheng](https://forum.ansible.com/u/Xinhuan_Zheng)\
**Post date:** [July 1, 2020, 6:56pm UTC](https://forum.ansible.com/t/how-to-structure-variables-to-distinguish-different-environments/33298/1 "2020-07-01T18:56:15Z")

</div>

Hello,

I want to define a variable for playbook in **group\_vars/server\_genre** file. However, I don’t know if Ansible can support something like server\_genre@environment syntax notation. Here is the detail:

**In inventory/environment** :

---

<div class="post-metadata">

**Author:** ![Srinivas\_Naram](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@Srinivas\_Naram](https://forum.ansible.com/u/Srinivas_Naram)\
**Post date:** [July 2, 2020, 10:22am UTC](https://forum.ansible.com/t/how-to-structure-variables-to-distinguish-different-environments/33298/2 "2020-07-02T10:22:56Z")

</div>

There could be some distinction between both the environments. Can you use gather\_facts and get the differentiating value ?

if you are able to get it using gather\_facts, you can use set\_facts

Example

set\_facts:  
nfs\_server: xyx  
when: ansible\_distribution= ‘CentOS’

set\_fact:  
nfs\_server: abc  
when: ansible\_distribution =‘Ubuntu’

---

<div class="post-metadata">

**Author:** ![Xinhuan\_Zheng](https://avatars.discourse-cdn.com/v4/letter/x/a88e57/32.png) [@Xinhuan\_Zheng](https://forum.ansible.com/u/Xinhuan_Zheng)\
**Post date:** [July 7, 2020, 1:54pm UTC](https://forum.ansible.com/t/how-to-structure-variables-to-distinguish-different-environments/33298/3 "2020-07-07T13:54:32Z")

</div>

Hello,

That construct actually makes sense to me. The fact of Development vs. Production is controlled by their network. We can just create custom fact based on each host IP address, and return customer fact variable. Then we can set nfs\_server per that custom fact.

Thanks for showing this tip.

- Xinhuan
