Ok, so I have things in a format that run under 1.9 as well as v2/current 
devel and the behavior is very odd.  I've put together some sample playbook 
files to help demonstrate the behavior I am seeing:

https://github.com/therevmj/ansible-oddities/blob/master/play.yml

The comments in that file describing the behavior all apply to v2/current 
devel.  To summarize the comments, basically variable layering appears to 
be very much broken in v2, but how it breaks seems highly variable (but 
reproducible).

For version 1.9, the behavior is broken, but as far as I know right now it 
is always broken in the same way.  That is vars_files always override 
parameters.  But to be honest, I've mainly focused on testing against v2.

On Tuesday, June 9, 2015 at 8:29:28 PM UTC-7, benno joy wrote:
>
> also vars_files shouldnt have precendce over vars in an include, are you 
> testing this in v2 ? can you please checkout the latest devel version and 
> check.
>
>
>
>
> On Wed, Jun 10, 2015 at 8:45 AM, Giovanni Tirloni <[email protected] 
> <javascript:>> wrote:
>
>> I think you are missing a "- " before those includes.
>>
>> - name: blah
>>   hosts: blah
>>   ...
>> - include: blah.yml
>> - include: bleh.yml
>>
>> Ansible doesn't through an error if you specify the include at the same
>> level as name/hosts/etc... but it seem to produce an unexpected behavior
>> (the contents of the current playbook are completed replaced).
>>
>> You can do this:
>>
>> - include: "{{ ansible_distribution}}.yml"
>>
>>
>> On Tue, 09 Jun 2015 19:32 -0700, Michael Johnson <[email protected] 
>> <javascript:>>
>> wrote:
>> > Hm..
>> >
>> > I attempted to try this with the current devel branch from github and my
>> > examples don't work at all.  There seem to be major differences and thus
>> > I
>> > can't really test properly if this issue still exists.
>> >
>> > This leaves me with three questions:
>> >
>> > Is there something horribly wrong with the way I've written my example
>> > playbooks?
>> >
>> > Is it expected that parameters passed to included playbooks will be
>> > replace
>> > by values in the vars_files defined in the included playbook?
>> >
>> > If so this breaks the way I was planning on handling differences for
>> > different operating systems.
>> >
>> > I am planning on working more with ansible, but I'm sort of stalled out
>> > right now as I don't want to do things in a horribly broken way of based
>> > on
>> > a behavior that might actually be a bug.  Any feedback is appreciated.
>> >
>> > Thanks!
>> >
>> >
>> > On Monday, June 8, 2015 at 2:02:37 AM UTC-7, Michael Johnson wrote:
>> > >
>> > > I've been playing around with paramaterized playbook includes, and I 
>> think
>> > > I have discovered a bug, but perhaps it is expected behavior, so I 
>> thought
>> > > I would ask.
>> > >
>> > > The short version is that parameters do not override data from 
>> vars_files.
>> > >  I presume this is not the expected behavior?  I didn't have any luck
>> > > finding documentation that would tell me for sure either way.
>> > >
>> > > I've only tested on 1.9.0.1, so it is possible that it is fixed in 
>> dev,
>> > > but I've not had a change to test that.
>> > >
>> > > Now with much more detail...
>> > >
>> > > Let's say you have play.yml with the following:
>> > >
>> > > - hosts: all
>> > >   include: include.yml parameter=passed
>> > >
>> > > And then you have include.yml:
>> > >
>> > > - hosts: all
>> > >   vars:
>> > >     parameter: vars
>> > >   tasks:
>> > >     - debug:
>> > >         msg: parameter={{ parameter }}
>> > >
>> > > This results in what to me is the expected result (the parameter 
>> overrides
>> > > the value from 'vars':
>> > >
>> > > ok: [sun.apomorph.com] => {
>> > >
>> > >     "msg": "parameter=passed"
>> > >
>> > > }
>> > >
>> > >
>> > > However, if you create vars.yml with the following:
>> > >
>> > >
>> > > parameter: file
>> > >
>> > >
>> > > And then change include.yml to contain the following:
>> > >
>> > >
>> > > - hosts: all
>> > >
>> > >   vars:
>> > >
>> > >     parameter: vars
>> > >
>> > >   vars_files:
>> > >
>> > >     - vars.yml
>> > >
>> > >   tasks:
>> > >
>> > >     - debug:
>> > >
>> > >         msg: parameter={{ parameter }}
>> > >
>> > >
>> > > The result is not what I would expect (the value from vars_file is
>> > > utilized:
>> > >
>> > > TASK: [debug ]
>> > > ****************************************************************
>> > >
>> > > ok: [sun.apomorph.com] => {
>> > >
>> > >     "msg": "parameter=file"
>> > >
>> > > }
>> > >
>> > >
>> > >
>> > >
>> >
>> > --
>> > 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] <javascript:>.
>> > To post to this group, send email to [email protected] 
>> <javascript:>.
>> > To view this discussion on the web visit
>> > 
>> https://groups.google.com/d/msgid/ansible-project/bee3f4b2-8fcb-4d75-a0e7-e1b0c5af16cf%40googlegroups.com
>> .
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/1433906106.201974.291439441.457C266F%40webmail.messagingengine.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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/dfb7f8fb-86be-4154-95f1-b78b9025c240%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to