I am facing a similar problem. Did you ever get this resolved?

Thanks,
Rami

On Tuesday, March 10, 2015 at 2:52:14 PM UTC-7, Leonardo Visconti wrote:
>
> Hi everyone,
>
> I've been debugging some proof of concepts and got stuck with this.
>
> Whenever I use the "when" condition in conjunction with "with_sequence", 
> the former won't work.
>
> Am I looking at a bug or is this behavior on purpose? Would you recommend 
> a different approach?
>
> Currently running ansible 1.7.2.
>
> Thanks in advance,
>
> Leo
>
> ---
>
> Example playbook:
>
> - hosts: localhost
>
>   vars:
>     - to_launch_instances_number: '3'
>     - current_instances_number: '5'
>
>   tasks:
>     - name: "Simple debug test"
>       debug: msg="Debug current instances {{current_instances_number}} to 
> launch instances {{to_launch_instances_number}}"
>
>     - name: "Debug greater then"
>       debug: msg="Condition says greater then"
>       when: "{{ to_launch_instances_number | 
> version_compare(current_instances_number, '>') }}"
>
>     - name: "Echo when greater than with sequence"
>       shell: "echo {{ item }}"
>       when: "{{ to_launch_instances_number | 
> version_compare(current_instances_number, '>') }}"
>       with_sequence: start="{{current_instances_number}}" 
> end="{{to_launch_instances_number}}"
>
> Here's the output:
>
> PLAY [127.0.0.1] 
> **************************************************************
>
> GATHERING FACTS 
> ***************************************************************
> ok: [127.0.0.1]
>
> TASK: [Simple debug test] 
> *****************************************************
> ok: [127.0.0.1] => {
>     "msg": "Debug current instances 5 to launch instances 3"
> }
>
> TASK: [Debug greater then] 
> ****************************************************
> skipping: [127.0.0.1]
>
> TASK: [Echo when greater than with sequence] 
> **********************************
> fatal: [127.0.0.1] => can't count backwards
>
> FATAL: all hosts have already failed -- aborting
>
> PLAY RECAP 
> ********************************************************************
>            to retry, use: --limit @/home/cloudopen/rolling-deploy.retry
>
> 127.0.0.1                  : ok=2    changed=0    unreachable=1    failed=0
>
>

-- 
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-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/0011a321-b6f5-4154-b4e9-092c3f470a7c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to