# Complex conditionals in retry-until

**URL:** <https://forum.ansible.com/t/complex-conditionals-in-retry-until/23551>\
**Category:** Ansible Developer\
**Created:** [January 24, 2017, 4:17pm UTC](https://forum.ansible.com/t/complex-conditionals-in-retry-until/23551 "2017-01-24T16:17:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan\_Helyar](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@Dan\_Helyar](https://forum.ansible.com/u/Dan_Helyar)\
**Post date:** [January 24, 2017, 4:17pm UTC](https://forum.ansible.com/t/complex-conditionals-in-retry-until/23551/1 "2017-01-24T16:17:54Z")

</div>

I have the following ec2 task:

```auto

# Provision EC2 instances using variables set in the role vars file
- name: Provision EC2 instances
ec2:
assign_public_ip: yes
aws_access_key: "{{ aws_akey }}"
aws_secret_key: "{{ aws_skey }}"
count_tag:
inventory_group: "{{ item.group | default('') }}"
inventory_host: "{{ item.name }}"
Name: "{{ item.name }}"
exact_count: 1
group: "{{ item.security_group | default('') }}"
key_name: "{{ key_pair_name }}"
image: "{{ item.image_id }}"
instance_tags:
inventory_group: "{{ item.group | default('') }}"
inventory_host: "{{ item.name }}"
Name: "{{ item.name }}"
role: "{{ item.group | default('') }}"
instance_type: "{{ item.type }}"
monitoring: no
region: "{{ region }}"
vpc_subnet_id: "{{ vpc_subnet_id }}"
wait: no
zone: "{{ region }}{{ zone_letter }}"
register: created_instances
with_items:
- ["{{ instance_master }}"]
- "{{ instance_slaves }}"

```

However now and again this seems to yield some or all elements of `created_instances.results` with public\_ip=null, therefore I’d like to retry-until. However I can’t figure out how to write an `until` option for this. If pure python was possible it would look something like:

```auto
until: all([result.tagged_instances[0].public_ip != null for result in created_instances.results])

retries: 10
delay: 0

```

Is there any way to handle this?
