# RFE: retries and multiple addresses for a host

**URL:** <https://forum.ansible.com/t/rfe-retries-and-multiple-addresses-for-a-host/13001>\
**Category:** Ansible Project\
**Created:** [June 21, 2013, 2:45am UTC](https://forum.ansible.com/t/rfe-retries-and-multiple-addresses-for-a-host/13001 "2013-06-21T02:45:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Seth\_Vidal](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@Seth\_Vidal](https://forum.ansible.com/u/Seth_Vidal)\
**Post date:** [June 21, 2013, 2:45am UTC](https://forum.ansible.com/t/rfe-retries-and-multiple-addresses-for-a-host/13001/1 "2013-06-21T02:45:13Z")

</div>

Okay - I know this is awful and edgecase-y but I'm going to try to  
make it seem like it is not:

1. I'd like to be able to allow retries. So that if you get a failure  
in some task it can try again. Either due to the task failing or due to  
your connection failing. I know it's sticky - but I think kinda do-able  
and it might help people on crappy connections.

2. Is there any way to have ansible have more than one ip for a single  
host. I'd like to be able support an alternative route. I know this is  
ridiculously edgecase-y but I thought it might be worth a shot. The  
case is I have 2 routes - one via public ip, one via vpn. If I have a  
choice I want to use the vpn, but if the vpn isn't up yet (b/c ansible  
hasn't touched the system, yet :)) I want to use the other public ip.

I haven't started looking at the code I was just thinking about whether  
or not this is even interesting.

thoughts?  
-sv

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [June 21, 2013, 3:00am UTC](https://forum.ansible.com/t/rfe-retries-and-multiple-addresses-for-a-host/13001/2 "2013-06-21T03:00:57Z")

</div>

hmm, like this?

1. a ‘attempts’ property for the connection plugins (default 1).

2. ansible\_ssh\_host and host name resolution taking a ‘list’ instead of just 1 value, iterating over the list until it succeeds\* I currently use external/internal DNS servers to achieve this, VPN server gives me the diff IP for the same host, diff hosts files might also work (hosts, hosts\_vpn) but it is a manual selection.

---

<div class="post-metadata">

**Author:** ![Seth\_Vidal](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@Seth\_Vidal](https://forum.ansible.com/u/Seth_Vidal)\
**Post date:** [June 21, 2013, 3:11am UTC](https://forum.ansible.com/t/rfe-retries-and-multiple-addresses-for-a-host/13001/3 "2013-06-21T03:11:35Z")

</div>

> hmm, like this?
> 
> 1) a 'attempts' property for the connection plugins (default 1).

Does this exist? did i just miss it?

> 2) ansible\_ssh\_host and host name resolution taking a 'list' instead  
> of just 1 value, iterating over the list until it succeeds  
> \* I currently use external/internal DNS servers to achieve this, VPN  
> server gives me the diff IP for the same host, diff hosts files might  
> also work (hosts, hosts\_vpn) but it is a manual selection.

right - It would need to be a list - I'd put the vpn first - if that  
doesn't connect - use the public.

I really want to refer to the host by a single hostname but connect to  
it via ansible by the better option.

-sv

---

<div class="post-metadata">

**Author:** ![Lorin\_Hochstein1](https://avatars.discourse-cdn.com/v4/letter/l/ce73a5/32.png) [@Lorin\_Hochstein1](https://forum.ansible.com/u/Lorin_Hochstein1)\
**Post date:** [June 21, 2013, 3:24am UTC](https://forum.ansible.com/t/rfe-retries-and-multiple-addresses-for-a-host/13001/4 "2013-06-21T03:24:43Z")

</div>

I could really use this. In my use case, I'm using Ansible to manage some  
instances inside of an OpenStack cloud. With the version of OpenStack I'm  
running, I can't access the instances from floating IPs if I'm inside of  
another OpenStack instances, and I can only access the instance from  
floating IPs if I'm outside of the instances.

Being able to specify both IPs and have ansible use the first one that  
works would be wonderful.

Lorin

---

<div class="post-metadata">

**Author:** ![Chris\_Bennett](https://avatars.discourse-cdn.com/v4/letter/c/e19adc/32.png) [@Chris\_Bennett](https://forum.ansible.com/u/Chris_Bennett)\
**Post date:** [June 21, 2013, 3:27am UTC](https://forum.ansible.com/t/rfe-retries-and-multiple-addresses-for-a-host/13001/5 "2013-06-21T03:27:44Z")

</div>

Hi Seth,

> I really want to refer to the host by a single hostname but connect to  
> it via ansible by the better option.

You may have considered it already, but if the public IP of the host is  
reachable over the VPN as well, you could add a static route over the VPN path  
when it's up.

If the public IP isn't routable over the VPN, you could use iptables  
DNAT to rewrite:

&nbsp;&nbsp;iptables -t nat -A OUTPUT -d \<ext\_ip\> -p 22 -j DNAT --to-destination \<vpn\_ip\>

Chris

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [June 21, 2013, 3:35am UTC](https://forum.ansible.com/t/rfe-retries-and-multiple-addresses-for-a-host/13001/6 "2013-06-21T03:35:57Z")

</div>

@Seth,

no it doesn’t exist, just throwing out there possible implementations

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [June 22, 2013, 5:40pm UTC](https://forum.ansible.com/t/rfe-retries-and-multiple-addresses-for-a-host/13001/7 "2013-06-22T17:40:06Z")

</div>

So I’ve already talked a little bit about wanting to do very basic retires on a task by task basis, but connection level retries would be different, and likely need to be implemented in the connection plugin.

If you want to take a shot at it, it might be reasonably self contained.

It is also true that maybe a comma seperated list of hostnames could be handled there as well, but I’m not positive.

I think the real question here is can it be done in a way that keeps the code mostly maintainable, and then there’s a _BIT_ an issue with that needing to be done for all connection plugins.

So really it seems like it needs to be done in a layer right above the connection plugin, like connection.py

---

<div class="post-metadata">

**Author:** ![Jeremy\_Schneider](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@Jeremy\_Schneider](https://forum.ansible.com/u/Jeremy_Schneider)\
**Post date:** [August 13, 2013, 5:13pm UTC](https://forum.ansible.com/t/rfe-retries-and-multiple-addresses-for-a-host/13001/8 "2013-08-13T17:13:27Z")

</div>

I’ve searched the group a little and can’t find this discussion. Also don’t see anything in the docs. Is it possible to config a particular task to automatically retry N times on failure? I have a use case where it would be extremely useful (deploying a monitoring agent using the vendor’s deploy script which fails % of the time from random issues like HTTP connections to the master monitoring server where it downloads bits).

-Jeremy
