So, I have a batch of playbooks that include tasks where the filenames are 
determined by variables;

 - include: tasks/mytask-{{onevar}}-{{anothervar}}.yml

This was working up through ansible 1.7.2.   As of ansible 1.8.0 (and also 
tested on ansible 1.8.1) this stopped working;  the variables are no longer 
interpreted, and ansible exits complaining with a message:

   1. ERROR: file could not read: 
   /root/work/playbooks/tasks/bar-{{platform}}.yml
   

Below are the bits to reproduce:

   1. foo.yml:
   2. - hosts: slave
   3.   user: root
   4.  
   5.   vars:
   6.     platform: rpm
   7.  
   8.   tasks:
   9.     - include: "tasks/bar-{{platform}}.yml"
   10.  
   11. tasks/bar-rpm.yml:
   12. - name: install OS package dependencies
   13.   action: yum pkg={{item}} state=installed
   14.   with_items:
   15.     - wget
   16.     - ntpdate
   17.  
   18.  
   19. hosts.inv:
   20. [slave]
   21. sc-cluster-20-04
   22. sc-cluster-20-05
   23. sc-cluster-20-06
   


The above case works on all ansible versions up through 1.7.2, and breaks 
on 1.8.0+.  I searched on here a bit regarding this, and found the 
suggestion that variables as part of include filenames would only work if 
passed in as extra vars, as only those would be resolvable early enough.  I 
tested that on 1.7.2 by taking out the "vars:" section and passing the 
value in as an extra var on the command-line.  That test worked on 1.7.2 
and earlier, but does not work in 1.8.0+.  

Is there any means where this functionality should actually work in 1.8.x?

-- 
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/c2604edb-dc50-4770-82e1-d638e099b766%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to