set default when using an undefined variable in "with_sequence"

219 views
Skip to first unread message

David Neudorfer

unread,
Aug 14, 2015, 10:51:28 AM8/14/15
to Ansible Project
What is the proper way to set a default for helios_web1b.count?

Currently this task:

- name: create identifier sequence for tagging web1b
  no_log
: true
  debug
: msg="{{ item }}"
  with_sequence
:
    start
=0
    count
="{{ helios_web1b.count }}"
    format
=%02d
 
register: sequence

results in:

TASK: [helios_aws_multi | create identifier sequence for tagging web1b] *******
fatal
: [localhost] => unknown error parsing with_sequence arguments: u'start=0 count="{{ helios_web1b.count }}" format=%02d'


FATAL
: all hosts have already failed -- aborting

I tried:

- name: create identifier sequence for tagging web1b
  no_log
: true
  debug
: msg="{{ item }}"
  with_sequence
:
    start
=0
    count
="{{ helios_web1b.count | default ('2') }}"
    format
=%02d
 
register: sequence

Nothing has worked so far. Any ideas would be awesome. Thank you.

Brian Coca

unread,
Aug 14, 2015, 11:50:00 AM8/14/15
to Ansible Project
{{ (helios_web1b|default(2)).count | default ('2') }}"
> --
> 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 ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/9f53c2fa-114b-464f-9694-77eac7370c59%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca
Reply all
Reply to author
Forward
0 new messages