Yes this is expected. Register always stores the state of the task, but you
can just check the .skipped value in your when: statement.
 On Jun 24, 2014 3:12 PM, "PePe Amengual" <[email protected]> wrote:

> Hi there
>
>  I'm running into an issue that I don't know if it is a expected behaviour
> or a bug....
>  I have a play with two task both of them have the conditional "when" and
> both of them use the same variable name as a register like so :
>
>
> - name: Forcing Termination of instances
>   hosts: localhost
>   connection: local
>   tasks:
>
>     - name: Finding instances to terminate base on Build Number
>       #shell: aws ec2 --output=json --region eu-west-1
> describe-instances|jq '.Reservations[].Instances[] |
> select(contains({Tags':' [{Key':' "terminate_me"}]}))'|jq -r ".InstanceId"
>       shell: aws ec2 --output=json --region eu-west-1 describe-instances
> --filter "Name=tag:jenkins_build,Values={{ jenkins_build }}"
> "Name=instance-state-name,Values=running"|jq -r
> ".Reservations[].Instances[].InstanceId"
>       register: ec2_instancesIDs
>       when: with_jenkins_build
>
>     - name: Finding instances to terminate after Failed job run
>       #shell: aws ec2 --output=json --region eu-west-1
> describe-instances|jq '.Reservations[].Instances[] |
> select(contains({Tags':' [{Key':' "terminate_me"}]}))'|jq -r ".InstanceId"
>       shell: aws ec2 --output=json --region eu-west-1 describe-instances
> --filter "Name=tag:terminate_me,Values=true"
> "Name=instance-state-name,Values=running"|jq -r
> ".Reservations[].Instances[].InstanceId"
>       register: ec2_instancesIDs
>       when: no_build_number
>
>     - debug: var=ec2_instancesIDs
>
>  I noticed in debug mode that even if the task is being skipped the
> variable is being set anyway so if I run the cleanup jenkins job and I use
> the jenkins build number and I call ansible like so :
>
>  ansible-playbook -vvvv --tags cleanup --extra-vars no_build_number=false
> cleanup=true with_jenkins_build=true jenkins_build=70
> jmeter/loadtools/site.yml
>
> The ec2_instancesIDs value ends to be :
>
> TASK: [debug var=ec2_instancesIDs] 
> ********************************************
> ok: [localhost] => {
>     "ec2_instancesIDs": {
>         "changed": false,
>         "skipped": true
>     }
> }
>
>
> Because the last task is being skipped.
>
> is this a expected behaviour ?
>
> 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/445e4ea3-e7be-4af1-90ca-5bf2900c425f%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/445e4ea3-e7be-4af1-90ca-5bf2900c425f%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/CAMFyvFhYRXYP6iHGpSaOzu5cAcziNsGq-yJV02o_mmqZqmJoXg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to