Only execute task then certain URL is NOT reachable

15 views
Skip to first unread message

guenthe...@smarter-ecommerce.com

unread,
Aug 31, 2016, 1:04:18 PM8/31/16
to Ansible Project
Hi, 

I have a setup with Apache Mesos and Marathon. 
I also deploy a Elasticsearch with JSON to the Mesos Cluster via Ansible.
But this should only be done, when a certain endpont http://mesos...:8080/v2/apps/elasticserach
is NOT reachable. That indicates, that the module is already (or isn't) installed.

How can I do that in my main.yml?

regards
guenther

Kai Stian Olstad

unread,
Sep 2, 2016, 7:50:51 AM9/2/16
to ansible...@googlegroups.com
The principle is like this.

Use the uri[1] module to check the url and register[2] the output in a
variable.

Use when[3] to check the variable to determine if the task should run or
not.


[1] https://docs.ansible.com/ansible/uri_module.html
[2]
https://docs.ansible.com/ansible/playbooks_variables.html#registered-variables
[3] https://docs.ansible.com/ansible/playbooks_conditionals.html

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages