Sorry, I am using Ansible 1.9.4 on CentOS 7.1.

/ Thomas


On Wednesday, November 11, 2015 at 4:48:09 PM UTC+1, 
[email protected] wrote:
>
> Hello,
> I have a problem with conditional variable imports. I am trying to set a 
> variable based on operatingsystem release. For 'Solaris10' I want one value 
> and for all others I want another another value.
>
> In this example I have two servers:
>
> $ ansible server1 -m setup | grep -E 
> 'ansible_os_family|ansible_distribution_version'
>         "ansible_distribution_version": "10",
>         "ansible_os_family": "Solaris",
> $ ansible server2 -m setup | grep -E 
> 'ansible_os_family|ansible_distribution_version'
>         "ansible_distribution_version": "11.2",
>         "ansible_os_family": "Solaris",
>
>
> I am trying to mimic the construct from this example: 
> http://docs.ansible.com/ansible/playbooks_conditionals.html#conditional-imports
>
> $ cat vars/defaults.yml
> ---
> homeprefix: /blah
>
>
> $ cat vars/Solaris10.yml
> ---
> homeprefix: /export/home
>
>
> $ cat debug.yml
> ---
> - hosts: dbservere1:dbservere3
>   vars_files:
>     - [ "vars/{{ ansible_os_family }}{{ 
> ansible_distribution_version}}.yml", "vars/defaults.yml" ]
>
>
>   tasks:
>
>
>   - debug: msg="vars/{{ ansible_os_family }}{{ 
> ansible_distribution_version }}.yml"
>   - debug: msg={{ homeprefix }}
>
>
> I was now expecting to have "server1" import the file "vars/Solaris10.yml" 
> and "server2" import the file "vars/defaults.yml" but instead both servers 
> are importing the "vars/defaults.yml".
>   
> $ ansible-playbook debug.yml
>
>
> PLAY [server1:server2] **************************************************
>
>
> GATHERING FACTS 
> ***************************************************************
> ok: [server1]
> ok: [server2]
>
>
> TASK: [debug msg="vars/{{ ansible_os_family }}{{ 
> ansible_distribution_version }}.yml"] ***
> ok: [server1] => {
>     "msg": "vars/Solaris10.yml"
> }
> ok: [server2] => {
>     "msg": "vars/Solaris11.2.yml"
> }
>
>
> TASK: [debug msg={{ homeprefix }}] 
> ********************************************
> ok: [server1] => {
>     "msg": "/blah"
> }
> ok: [server2] => {
>     "msg": "/blah"
> }
>
>
> PLAY RECAP 
> ********************************************************************
> server1                 : ok=3    changed=0    unreachable=0    failed=0
> server2                 : ok=3    changed=0    unreachable=0    failed=0
>
>
>
>
> Can someone point me to my error?
>
> Cheers,
> Thomas
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/4ae25e15-d35b-440f-86da-1a143393440e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to