I think your problem is that you are checking item.key. Item.key is always defined, as that is the name of the key. You want to check if item.value is something.
I would check something like: when: item.value That should be sufficient. On Sunday, January 17, 2016, Pierre Mavro <[email protected]> wrote: > Nobody has an idea :-( ? > > Le mercredi 13 janvier 2016 14:04:03 UTC+1, Pierre Mavro a écrit : >> >> Hi, >> >> I'm trying to find a way to grab RabbitMQ plugins when an URL is >> specified as value of a key (because some of them are include but not >> activated with RabbitMQ, while others are not included). >> >> I'd like to have a single dict containing both and in the case where a >> value is not specified, it's implicitly included in RabiitMQ. Here is what >> I've got: >> >> rabbitmq_plugins: >> rabbitmq_management: >> rabbitmq_delayed_message_exchange: ' >> http://www.rabbitmq.com/community-plugins/v3.6.x/rabbitmq_delayed_message_exchange-0.0.1.ez >> ' >> >> >> >> And in the role I've: >> >> - name: download and install additionnal plugins >> get_url: url={{item.value}} dest={{rabbitmq_plugins_folder}} owner=root >> group=root mode=0644 >> with_dict: rabbitmq_plugins >> when: "item.key is defined" >> >> >> >> Unfortunately it fails like this: >> ok: [10.200.0.18] => (item={'key': 'rabbitmq_delayed_message_exchange', >> 'value': ' >> http://www.rabbitmq.com/community-plugins/v3.6.x/rabbitmq_delayed_message_exchange-0.0.1.ez >> '}) >> failed: [10.200.0.18] => (item={'key': 'rabbitmq_management', 'value': >> 'None'}) => {"failed": true, "item": {"key": "rabbitmq_management", >> "value": "None"}} >> msg: unknown url type: None >> >> >> >> If I modify the when statement like this: when: "item.key is defined or >> item.value is not Null", I got: >> >> fatal: [10.200.0.18] => Failed to template {% if item.key is defined or >> item.value is not Null %} True {% else %} False {% endif %}: template >> error while templating string: no test named 'Null' >> >> Any idea how I can make it work properly ? >> >> 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] > <javascript:_e(%7B%7D,'cvml','ansible-project%[email protected]');> > . > To post to this group, send email to [email protected] > <javascript:_e(%7B%7D,'cvml','[email protected]');>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/b7af98f6-3fae-4556-919b-fc0b26c20b8d%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/b7af98f6-3fae-4556-919b-fc0b26c20b8d%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Matt Martz @sivel sivel.net -- 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/CAD8N0v-ay8i8SCfXr95Uz4deEy5nR6J80m2SpUkhfC%2Bz%2BNowrg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
