On 28. juni 2017 18:21, Guy Matz wrote:
Peeps,
Hey!  I have an issue with the credstash plugin  . . .  if it can't
complete the lookup it simply vomits an AnsibleError, so it's not possible
to do something like:
{{ lookup('credstash', 'blah', 'bling') | default('Sane default here') }}

Anyone know of a way around this?  So that a failed lookup can have a
default?

I think you you need to split in two, something like this

  - set_fact:
      some_var: "{{ lookup('credstash', 'blah', 'bling') }}"
    ignore_errors: yes

  - set_fact:
      some_var: Sane default here
    when: some_var not defined



Another way

  - debug: msg="{{ lookup('credstash', 'blah', 'bling') }}"
    register: result
    ignore_errors: yes

  - debug: msg="Sane default here"
    when: result | failed


--
Kai Stian Olstad

--
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/fd046fff-22ef-e4d5-2e37-312eb6abb12b%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to