New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include fails to expand host variables #2290

Closed
mmoya opened this Issue Mar 3, 2013 · 4 comments

Comments

Projects
None yet
3 participants
@mmoya
Contributor

mmoya commented Mar 3, 2013

The playbook:


---
- hosts: localhost
  vars:
    - othertasks:
       - othertask1
       - othertask2
  tasks:
    - name: debug
      debug: msg="tasks/$item.yml"
      with_items: $othertasks

    - include: tasks/$item.yml
      with_items: $othertasks

this works as long as othertasks is defined inline.

When othertasks is removed from playbook and defined in the inventory file or in host_vars, debug continues working but include fails.

Error is ERROR: file not found: ./tasks/$othertasks.yml.

@dhozac

This comment has been minimized.

Contributor

dhozac commented Mar 3, 2013

This is one of the limitations of using include and with_items. It only works for global data, i.e. vars: or vars_files: without variables. I'm working on that, but that is how it works right now.

@mpdehaan

This comment has been minimized.

Contributor

mpdehaan commented Mar 4, 2013

Include + with_items has been a frequent question as of late.

I've temporarily removed it from the docs until we can find a way to
address it more consistently (as I hate being asked the same questions, as
it's usually a sign the software needs to be better! And here is one
example where it does).

On Sun, Mar 3, 2013 at 4:44 PM, Daniel Hokka Zakrisson <
notifications@github.com> wrote:

This is one of the limitations of using include and with_items. It only
works for global data, i.e. vars: or vars_files: without variables. I'm
working on that, but that is how it works right now.


Reply to this email directly or view it on GitHubhttps://github.com//issues/2290#issuecomment-14356205
.

@mpdehaan mpdehaan closed this Mar 4, 2013

@mpdehaan

This comment has been minimized.

Contributor

mpdehaan commented Mar 4, 2013

A way to fix this, BTW, is to just use the lists inside the task includes.

@mmoya

This comment has been minimized.

Contributor

mmoya commented Mar 4, 2013

FTR, the same behaviour is exposed without using a lookup plugin, ie include: $foo works when foo is declared inline and fails otherwise.

@mpdehaan didn't understand what you mean with: inside the task includes, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment