included task vars

When trying to get various groups of tasks working nicely from a master playbook… I find the following problem (this is for slapd+ssl):

slapd-install.yaml

  • hosts: all
    vars:
    openssl: …/openssl/
    tasks:
  • include: tasks/install.yaml
  • include: tasks/configure.yaml
  • include: ${openssl}/tasks/setup-cn.yaml cn=${service.slapd.fqdn}
  • include: ${openssl}/tasks/upload-ca.yaml cn=${service.slapd.fqdn}
  • include: ${openssl}/tasks/genkey.yaml cn=${service.slapd.fqdn}
  • include: ${openssl}/tasks/gencsr.yaml cn=${service.slapd.fqdn}

In the context of the playbook, I have what the openssl tasks call the $cn in a different var ($service.slapd.fqdn). I can’t find a way to pass that var on to the tasks as $cn. Even nicer would be if I could simply assign vars from vars:

  • hosts: all

vars:
openssl: …/openssl/
cn: ${service.slapd.fqdn}
tasks:

  • include: tasks/install.yaml
  • include: tasks/configure.yaml
  • include: ${openssl}/tasks/setup-cn.yam
  • include: ${openssl}/tasks/upload-ca.yaml
  • include: ${openssl}/tasks/genkey.yaml
  • include: ${openssl}/tasks/gencsr.yaml

Is there a reason why we would not want to template the values in these contexts?

Sorry, I am not understanding. Perhaps a case of having too much data and not being able to sort out what part of this is a feature request and what part of this is a symptom.

Can you summarize what the problem you are seeing is?

–Michael

Is there a reason why we would *not* want to template the values in these
contexts?

Being able to use vars inside of vars_files/includes seems like
something someone may try to do. I'm fine with making that possible.

Great! I’ll make it so.

Question, though. Will doing this break or alter this functionality:
http://ansible.github.com/playbooks2.html#conditional-execution

?

“this” being allowing:

vars:
foo: ${bar}

For the purpose of “aliasing” one var for another. Maybe you were only suggesting allowing this:

tasks:

  • include: tasks/foo.yaml foo=${bar}

Which shouldn’t cause any problems.

“this” being allowing:

vars:
foo: ${bar}

For the purpose of “aliasing” one var for another.

I’m pretty sure allowing the above is going to break stuff… so I’m going to drop that idea.

Maybe you were only suggesting allowing this:

tasks:

  • include: tasks/foo.yaml foo=${bar}

Which shouldn’t cause any problems.

this actually already works, but I was tricked ( :wink: ) into thinking it wasn’t. I’ll start a new thread on that issue.