Scenario / Questions
In order to let checks appear in Uchiwa when a new sensu-client is added, the
sensu-api need to be restarted. At the moment there are 5 clients and one server. Everytime a new sensu-client is added using ansible the checks do not appear in Uchiwa. At the moment, I need to login to the sensu-server and restart the services. How to automate this using ansible?
According to this documentation there are handlers:
handlers: - name: restart memcached service: name=memcached state=restarted listen: "restart web services" - name: restart apache service: name=apache state=restarted listen: "restart web services"
that could be called using notify:
tasks: - name: restart everything command: echo "this task will restart the web services" notify: "restart web services"
so that the service will be restarted if a change occurs in for example the config, but how to notify a remote service, e.g. notify service on IP-B from IP-A?
Find below all possible solutions or suggestions for the above questions..
listen is a 2.2 new feature which is not released as of writing, so I won’t use it)
A notify is just like a regular tasks (or so) except it is triggered by an event, so basically you could do something like that, this is kind of ugly (and insecure as the machine should have ssh access to the remote servers) but should work.
handlers: - name: restart my remote service command: ssh user@myserver -- service restart myservice
But Ansible has a more elegant manner to handle this with
handlers: - name: restart my remote service service: name=myserver state=restarted delegate_to: myserver
What it does, it the handler task will be executed on the server(s) you’ve have delegate the task.
and then plug-in to your task as you told in the question.
Kubernetes Free Online Tutorial, Kubernetes Beginner Tutorial
DevOps Free Online Tutorial, DevOps Beginner Tutorial
Ansible Free Online Tutorial, Ansible Beginner Tutorial
Docker Free Online Tutorial, Docker Beginner Tutorial
Openstack Free Online Tutorial, Openstack Beginner Tutorial
Disclaimer: This has been sourced from a third party syndicated feed through internet. We are not responsibility or liability for its dependability, trustworthiness, reliability and data of the text. We reserves the sole right to alter, delete or remove (without notice) the content in its absolute discretion for any reason whatsoever.