Sorry, I forgot to mention that it fails in the configuration step, because
the e2c variable is only set in the provisioning step.
Anyway, I got it working with the include statement.
- include: provisioning.yml
when: ebs_single_provisioning
- include: configuration.yml
when: ebs_single_configuration
Best regards,
Christian
Am Dienstag, 29. März 2016 16:40:46 UTC+2 schrieb Christian Kaps:
>
> 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/2703d92f-ba1f-4c4f-8ba0-9d205cf301b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.