I have a role which contains tasks that are executed based on a variable 
set in a playbook. In my case I have a *provisioning* playbook and a 
*configuration* playbook. Both share a role named `ebs_single`. In this 
role I've tasks which should be executed only in the *provisioning* step 
and some other tasks which should be executed in the *configuration* step. 

- name: Some provisioning task
  *...*
  with_items: "{{ ec2.instances }}"
  register: ec2_volumes
  when: ebs_single_provisioning


- name: Some configuration task
  *...*
  when: ebs_single_configuration


Prior to 2.0 this wasn't an issue, because I've used a bare variable in 
`with_items`:

with_items: ec2.instances


But now if I try to fix the deprecation warning, I get an error that the 
variable `ec2` is not found.

I'm not sure if this is an issue or if it's by design. But how can I use 
such a concept with Ansible 2.0?

I've tried to default the variable if it's not set. But this doesn't work. 
I think also this would be the wrong way to fix this issue, because in the 
provisioning step an error should be thrown if the variable doesn't exists.

with_items: "{{ ec2.instances|default(omit) }}"


Any suggestions?

Best regards,
Christian

-- 
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/ef1e1a49-de17-4920-8d1d-7910e069797d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to