# Undefined variable behaviour

**URL:** <https://forum.ansible.com/t/undefined-variable-behaviour/17220>\
**Category:** Ansible Project\
**Created:** [January 8, 2015, 12:13pm UTC](https://forum.ansible.com/t/undefined-variable-behaviour/17220 "2015-01-08T12:13:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jose\_Coelho](https://avatars.discourse-cdn.com/v4/letter/j/e36b37/32.png) [@Jose\_Coelho](https://forum.ansible.com/u/Jose_Coelho)\
**Post date:** [January 8, 2015, 12:13pm UTC](https://forum.ansible.com/t/undefined-variable-behaviour/17220/1 "2015-01-08T12:13:48Z")

</div>

I’m having some issues with variables scope and behavior, simplifying the issue:

I have two environments:

- production

- development

which one with several machines and a common role, for example backups.

A variable backup\_jobs define which files should be backup and when, so in the production group\_vars I set:

machine\_a\_backup\_jobs: …

machine\_b\_backup\_jobs: …

On machine\_a group\_vars I set:

backup\_jobs: “{{ machine\_a\_backup\_jobs }}”

And on machine\_b group\_vars:

backup\_jobs: “{{ machine\_b\_backup\_jobs }}”

In the development group\_vars I don’t set these variables since I don’t want backups

the expected behavior was that machine\_a\_backups and machine\_b\_backups would be undefined for this environment, instead when I check the variable I see that is replaced as a string:

“backup\_jobs”: “{{ machine\_a\_backup\_jobs }}”

ansible --version  
ansible 1.8.2
