> > - include: showdist.yml host='localhost'
You have no variables here, so this is not an inventory variable substitution issue. But you would be setting a variable called "host" that has no special meaning for Ansible. Minor pet-peeve/process note -- when you say something doesn't work, share what it did, and what it expected to do. I don't know what "doesn't work" means 80% of the time. On Fri, Feb 21, 2014 at 3:22 PM, anatoly techtonik <[email protected]>wrote: > On Friday, February 21, 2014 10:59:38 PM UTC+3, Brian Coca wrote: >> >> include gets evaluated before hosts are included and you cannot use a >> inventory variable (host dependant) in the include. >> >> Think of it as a 'preprocessing macro' more than a task. >> > > I still don't get it. I have the file showdist.yml: > > --- >> - hosts: "{{ host | default('localhost') }}" >> tasks: >> - name: show OS version info >> debug: msg="{{ansible_distribution}} {{ansible_distribution_version}}" > > > Now I include it from main playbook.yml: > > --- >> - hosts: localhost >> - include: showdist.yml > > > It fails with: > > PLAY [otherhost] > ************************************************************** > skipping: no hosts matched > > But when I do this: > > --- >> - hosts: localhost >> - include: showdist.yml host='localhost' > > > It works. And I am surprised, because for more complicated file it didn't > work. > > -- > 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]. > For more options, visit https://groups.google.com/groups/opt_out. > -- 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]. For more options, visit https://groups.google.com/groups/opt_out.
