# Possible bug with 1.8.x : Loading environment specific variable files via vars\_files no longer working for - \[\] syntax

**URL:** <https://forum.ansible.com/t/possible-bug-with-1-8-x-loading-environment-specific-variable-files-via-vars-files-no-longer-working-for-syntax/17257>\
**Category:** Ansible Project\
**Created:** [January 14, 2015, 2:03am UTC](https://forum.ansible.com/t/possible-bug-with-1-8-x-loading-environment-specific-variable-files-via-vars-files-no-longer-working-for-syntax/17257 "2015-01-14T02:03:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aliaksei\_Ilkiu](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@Aliaksei\_Ilkiu](https://forum.ansible.com/u/Aliaksei_Ilkiu)\
**Post date:** [January 14, 2015, 2:03am UTC](https://forum.ansible.com/t/possible-bug-with-1-8-x-loading-environment-specific-variable-files-via-vars-files-no-longer-working-for-syntax/17257/1 "2015-01-14T02:03:19Z")

</div>

I have a variable `ourenv` that defines specific environment. This variable is defined in inventory file a used to load environment specific values via `vars_files` as demonstrated in [https://gist.github.com/marktheunissen/2979474](https://gist.github.com/marktheunissen/2979474)  
After upgrade to 1.8.0 I’m facing problem with loading environment specific properties via `- []` syntax

**Sample site.yml**

```auto
---
- name: CheckIt
  hosts: all
  sudo: yes
  gather_facts: yes
  vars_files:
  - ['vars/env_{{ourenv}}.yml', vars/env_defaults.yml]
  tasks:
  - name: debug
    debug: msg="ourenv {{ ourenv }} pg_wal_buffers {{ pg_wal_buffers }}"

```

**Sample inventory file**

```auto
[singlebox]
localbox ourenv=dev_single host=devsrv ansible_ssh_host=192.168.18.129 alias=dev

```

**Sample vars/env\_dev\_single.yml**

```auto
pg_wal_buffers: 4MB

```

**Sample vars/env\_defaults.yml**

```auto
pg_wal_buffers: value

```

**Output in 1.8.X/1.9 (UNEXPECTED)**

```auto
PLAY [CheckIt] **************************************************************** 

GATHERING FACTS *************************************************************** 
ok: [localbox]

TASK: [debug] ***************************************************************** 
ok: [localbox] => {
    "msg": "ourenv dev_single pg_wal_buffers value"
}

```

**Output in 1.4.X/…/1.7.2 (CORRECT)**

```auto
PLAY [CheckIt] **************************************************************** 

GATHERING FACTS *************************************************************** 
ok: [localbox]
localbox: importing /bla-bla-bla/vars/env_dev_single.yml

TASK: [debug] ***************************************************************** 
ok: [localbox] => {
    "msg": "ourenv dev_single pg_wal_buffers 4MB"
}

```

It seams to me that no issues with loading these variables directly if I replace `- ['vars/env_{{ourenv}}.yml', vars/env_defaults.yml]` with `- 'vars/env_{{ourenv}}.yml'` but I want to have ‘failback to defaults’ option.  
Also if I pass `ourenv` via command line (`-e "ourenv=dev_single"`) it works as expected but I think it’s bad practice (splitting environment knowledge between inventory file and command line arguments).

Can somebody point me to the right direction?

I also opened ticket [https://github.com/ansible/ansible/issues/10000](https://github.com/ansible/ansible/issues/10000) but hope to get faster response here.

---

<div class="post-metadata">

**Author:** ![Leibo](https://avatars.discourse-cdn.com/v4/letter/l/41988e/32.png) [@Leibo](https://forum.ansible.com/u/Leibo)\
**Post date:** [January 20, 2015, 10:09am UTC](https://forum.ansible.com/t/possible-bug-with-1-8-x-loading-environment-specific-variable-files-via-vars-files-no-longer-working-for-syntax/17257/2 "2015-01-20T10:09:05Z")

</div>

Upgrading into 1.8.2 (from 1.6.x) produces the same behaviour for me.

I use:

vars\_files:

- “vars/DEFAULTS.yml”
- “vars/{{ansible\_system}}.yml”
- [“vars/{{ansible\_distribution}}.yml”, “vars/empty.yml”]
- [“vars/{{ansible\_distribution}}\_{{ansible\_distribution\_major\_version}}.yml”, “vars/empty.yml”]

and it is not loading the correct files anymore, it loads just the “vars/{{ansible\_system}}.yml” and that’s it.
