Re: retry loop in ansible ?

Axel Rau <[email protected]> Mon, 8 Jan 2024 19:43:30 +0100
Newsgroups gmane.comp.telephony.pbx.asterisk.user
Message-ID <[email protected]>
--===============0444065481920708193==
Content-Type: multipart/alternative;
	boundary="Apple-Mail=_D6F9E776-B572-4041-821D-74D94DF0D7C3"


--Apple-Mail=_D6F9E776-B572-4041-821D-74D94DF0D7C3
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8

Hi,

> Am 08.01.2024 um 18:16 schrieb C. Maj <[email protected]>:
>=20
> On 12/6/23 02:08, Axel Rau wrote:
>> I have a simple config with some phones ringing simultaneously.
>> Some of them are softphones (zoiper apps on iPhone w/o push =
notification).
>> If such an app did bot register in time, it has no chance to pick up =
the call.
>> If I could configure a retry loop checking for registered candidates,
>> say once a second until one phone takes the call, this would allow me
>> to pick up the call with zoiper app registered late.
>> How could this be done in ansible?
>=20
> Did you mean asterisk ?
Yes.=20
>=20
> If so, then you might look into the While()/EndWhile() applications, =
combined with timeouts to Dial() application, starting with something =
very basic such as the following:
>=20
> same =3D n,Set(tries=3D0)
> same =3D n,While($[${INC(tries)}<99])
> same =3D n,Set(PUSH(team,&)=3D${PJSIP_DIAL_CONTACTS(1234)})
> same =3D n,Set(PUSH(team,&)=3D${PJSIP_DIAL_CONTACTS(5678)})
> same =3D n,Dial(${team},10)
> same =3D n,Wait(1)
> same =3D n,EndWhile()
>=20
> ...at most that would be 11 seconds in between registration of x5678 =
and the next time it gets called when x1234 is not answering.
Thanks a lot for this example.

>=20
> Other approaches might involve Queue()'s with some ChannelRedirect()'s =
or even Bridge()'s, maybe AGI/ARI, etc.
>=20
> BTW the Asterisk Forums are a great place to post these kinds of =
questions in the future: https://community.asterisk.org

I will try this in the future,

Regards, Axel
=E2=80=94
PGP-Key: CDE74120  =E2=98=80 mobile: +49 160 7568212
computing @ chaos claudius


--Apple-Mail=_D6F9E776-B572-4041-821D-74D94DF0D7C3
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=utf-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: after-white-space;" =
class=3D"">Hi,<br class=3D""><div><br class=3D""><blockquote type=3D"cite"=
 class=3D""><div class=3D"">Am 08.01.2024 um 18:16 schrieb C. Maj &lt;<a =
href=3D"mailto:[email protected]" =
class=3D"">[email protected]</a>&gt;:</div><br =
class=3D"Apple-interchange-newline"><div class=3D""><div class=3D"">On =
12/6/23 02:08, Axel Rau wrote:<br class=3D""><blockquote type=3D"cite" =
class=3D"">I have a simple config with some phones ringing =
simultaneously.<br class=3D"">Some of them are softphones (zoiper apps =
on iPhone w/o push notification).<br class=3D"">If such an app did bot =
register in time, it has no chance to pick up the call.<br class=3D"">If =
I could configure a retry loop checking for registered candidates,<br =
class=3D"">say once a second until one phone takes the call, this would =
allow me<br class=3D"">to pick up the call with zoiper app registered =
late.<br class=3D"">How could this be done in ansible?<br =
class=3D""></blockquote><br class=3D"">Did you mean asterisk ?<br =
class=3D""></div></div></blockquote>Yes.&nbsp;<br class=3D""><blockquote =
type=3D"cite" class=3D""><div class=3D""><div class=3D""><br class=3D"">If=
 so, then you might look into the While()/EndWhile() applications, =
combined with timeouts to Dial() application, starting with something =
very basic such as the following:<br class=3D""><br class=3D"">same =3D =
n,Set(tries=3D0)<br class=3D"">same =3D =
n,While($[${INC(tries)}&lt;99])<br class=3D"">same =3D =
n,Set(PUSH(team,&amp;)=3D${PJSIP_DIAL_CONTACTS(1234)})<br class=3D"">same =
=3D n,Set(PUSH(team,&amp;)=3D${PJSIP_DIAL_CONTACTS(5678)})<br =
class=3D"">same =3D n,Dial(${team},10)<br class=3D"">same =3D =
n,Wait(1)<br class=3D"">same =3D n,EndWhile()<br class=3D""><br =
class=3D"">...at most that would be 11 seconds in between registration =
of x5678 and the next time it gets called when x1234 is not =
answering.<br class=3D""></div></div></blockquote><div>Thanks a lot for =
this example.</div><br class=3D""><blockquote type=3D"cite" =
class=3D""><div class=3D""><div class=3D""><br class=3D"">Other =
approaches might involve Queue()'s with some ChannelRedirect()'s or even =
Bridge()'s, maybe AGI/ARI, etc.<br class=3D""><br class=3D"">BTW the =
Asterisk Forums are a great place to post these kinds of questions in =
the future: <a href=3D"https://community.asterisk.org" =
class=3D"">https://community.asterisk.org</a><br =
class=3D""></div></div></blockquote></div><div class=3D""><div =
dir=3D"auto" style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); =
letter-spacing: normal; text-align: start; text-indent: 0px; =
text-transform: none; white-space: normal; word-spacing: 0px; =
-webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: =
break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" =
class=3D""><div dir=3D"auto" style=3D"caret-color: rgb(0, 0, 0); color: =
rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; word-spacing: 0px; =
-webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: =
break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" =
class=3D""><div dir=3D"auto" style=3D"caret-color: rgb(0, 0, 0); color: =
rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; word-spacing: 0px; =
-webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: =
break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" =
class=3D""><div style=3D"color: rgb(0, 0, 0); letter-spacing: normal; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: =
break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" =
class=3D""><div style=3D"color: rgb(0, 0, 0); letter-spacing: normal; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: =
break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" =
class=3D""><div style=3D"color: rgb(0, 0, 0); font-family: Helvetica; =
font-style: normal; font-variant-ligatures: normal; =
font-variant-position: normal; font-variant-caps: normal; =
font-variant-numeric: normal; font-variant-alternates: normal; =
font-variant-east-asian: normal; font-weight: normal; letter-spacing: =
normal; line-height: normal; orphans: 2; text-align: -webkit-auto; =
text-indent: 0px; text-transform: none; white-space: normal; widows: 2; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: =
break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" =
class=3D""><div class=3D"">I will try this in the future,</div><div =
class=3D""><br class=3D""></div><div class=3D"">Regards, Axel</div><div =
class=3D"">=E2=80=94<br class=3D""><span style=3D"text-align: =
-webkit-auto;" class=3D"">PGP-Key:&nbsp;CDE74120 &nbsp;=E2=98=80 mobile: =
+49 160 7568212</span></div><div class=3D"">computing @ chaos =
claudius</div></div></div></div></div></div></div>
</div>
<br class=3D""></body></html>=

--Apple-Mail=_D6F9E776-B572-4041-821D-74D94DF0D7C3--


--===============0444065481920708193==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

LS0gCl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f
X19fX19fX19fX19fX19fXwotLSBCYW5kd2lkdGggYW5kIENvbG9jYXRpb24gUHJvdmlkZWQgYnkg
aHR0cDovL3d3dy5hcGktZGlnaXRhbC5jb20gLS0KCkNoZWNrIG91dCB0aGUgbmV3IEFzdGVyaXNr
IGNvbW11bml0eSBmb3J1bSBhdDogaHR0cHM6Ly9jb21tdW5pdHkuYXN0ZXJpc2sub3JnLwoKTmV3
IHRvIEFzdGVyaXNrPyBTdGFydCBoZXJlOgogICAgICBodHRwczovL3dpa2kuYXN0ZXJpc2sub3Jn
L3dpa2kvZGlzcGxheS9BU1QvR2V0dGluZytTdGFydGVkCgphc3Rlcmlzay11c2VycyBtYWlsaW5n
IGxpc3QKVG8gVU5TVUJTQ1JJQkUgb3IgdXBkYXRlIG9wdGlvbnMgdmlzaXQ6CiAgIGh0dHA6Ly9s
aXN0cy5kaWdpdW0uY29tL21haWxtYW4vbGlzdGluZm8vYXN0ZXJpc2stdXNlcnM=

--===============0444065481920708193==--