Hi Hagai,

We've recently added the ability to omit parameters if they are not defined
via the "| default(omit)" filter. The documentation regarding this is here:
http://docs.ansible.com/playbooks_variables.html#omitting-undefined-variables-and-parameters.
This will be included in 1.8, so for now with 1.7 you will still have to
default the parameter to some value if it is not defined.

The reason we now disallow what you're doing in your example is the fact
that someone could try to inject additional parameters into the module
arguments via variables, so Ansible now expects a consistent number of
parameters both before and after the templating of module params is done.

Let us know if you have any further questions regarding this.

Thanks!

On Wed, Sep 17, 2014 at 9:14 AM, Hagai Kariti <[email protected]> wrote:

> Hi
> I have a usecase in which I want to pass some parameters to a module only
> if I have a variable defined with value for them. If I don't, I want the
> module to use its default value for these parameters. In ansible 1.5.5 (I
> know, old as hell), I could do this:
>
> module: {% if value is defined %}param={{value}}{% endif %}
>
> However later versions of ansible seem to have removed it due to security
> concerns (which I don't understand, but that's a different topic :) ). How
> should I go about doing that in Ansible 1.7? Do I have to keep my own
> default values?
>
> Thanks
>
> --
> 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/8aa00f58-62f8-4bc4-a243-306dcaebbefc%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/8aa00f58-62f8-4bc4-a243-306dcaebbefc%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAMFyvFjC5wTxKZ2rozu_y55zKkU%3Dy-p9MBdUFPcmPe8XsdwvcQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to