Issue 1:
Issue Type:

Bug Report

Ansible Version:

Ansible 1.8 (devel a1f09bd) last updated 2014/08/20 17:28:56 (GMT +400)

Environment:

Linux Ubuntu 12.04, Mac OS X

Summary:

There is an app_user variable which is defined in group_vars/all as all_user and in external variables file vars/staging.yml as staging_user. I've got weird win order for the variable when the second external variables file is used and it is not empty.

Steps To Reproduce:

I made a public repository with files for convenience https://github.com/hostmaster/ansible-bugreport

# group_vars/all
app_user: all_user

# inventory/staging
localhost ansible_connection=local

[all:vars]
deploy_env=staging

# vars/secrets/staging.yml
test_url: 'google.com'

# vars/staging.yml
app_user: staging_user

---
# test.yml
- hosts: localhost
gather_facts: no
vars_files:
- 'vars/{{ deploy_env }}.yml'
- 'vars/secrets/{{ deploy_env }}.yml'

tasks:
- local_action: debug var=deploy_env
- local_action: debug var=app_user

I have expected to get staging_user here but I've got all_user instead.

$ ansible-playbook -i inventory/staging test.yml

PLAY [localhost] **************************************************************
localhost: importing /Users/igor/Temp/ansible/test_run/vars/staging.yml
localhost: importing /Users/igor/Temp/ansible/test_run/vars/secrets/staging.yml

TASK: [debug var=deploy_env] **************************************************
ok: [localhost -> 127.0.0.1] => {
"deploy_env": "staging"
}

TASK: [debug var=app_user] ****************************************************
ok: [localhost -> 127.0.0.1] => {
"app_user": "all_user"
}

PLAY RECAP ********************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0

Now comment out the line in vars/secrets/staging.yml

# vars/secrets/staging.yml
# test_url: 'google.com'

$ ansible-playbook -i inventory/staging test.yml

PLAY [localhost] **************************************************************
localhost: importing /Users/igor/Temp/ansible/test_run/vars/staging.yml

TASK: [debug var=deploy_env] **************************************************
ok: [localhost -> 127.0.0.1] => {
"deploy_env": "staging"
}

TASK: [debug var=app_user] ****************************************************
ok: [localhost -> 127.0.0.1] => {
"app_user": "staging_user"
}

PLAY RECAP ********************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0

Expected Results:

ok: [localhost -> 127.0.0.1] => {

"app_user": "staging_user"

}

Actual Results:

ok: [localhost -> 127.0.0.1] => {

"app_user": "all_user"

}

Issue 2:
Issue Type: Bug Report

Ansible Version: 1.6.2 - 1.7.1

Environment: any

Summary:

Playbook level variable are ignored when we use vars_files with filename defined with {{ansible_os_family}}

If we import variable file with static name (RedHat.yml for example) - no issue

Steps To Reproduce:

Test playbook

---

- name: 'Test Precedence'
hosts: vagrantcentos
user: vagrant
sudo: yes

vars:
some_var: "foo"

vars_files:
- vars/{{ ansible_os_family }}.yml
#- vars/RedHat.yml
- vars/other_vars.yml

tasks:
- debug: msg={{some_var}}
tags:
- test

and additional files

group_vars/all

some_var: "bar"

vars/RedHat.yml

useless_var: "oops"

vars/other_vars.yml

other_var: "woot"

Expected Results:

debug message should be

"msg": "foo"

this result returned when I comment

- vars/{{ ansible_os_family }}.yml line

Actual Results:

Unexpectedly we got:

"msg": "bar"