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]>
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].
> 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/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].
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/1433906106.201974.291439441.457C266F%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to