Can Ansible Re-Install an application which was provisioned using Ansible and then removed manually?

Hello,

I’m totally new to Ansible so please pardon me for my silly question.

The question that I have is, can Ansible monitor a system/vm and detect whether an application/program (like tomcat/java/nginx) which was provisioned by Ansible, was removed by someone else and can it re-install that particular application when it detects such uninstalls? If we manually run the playbook then Ansible will re-install the application. But is there a way it automatically does this? Something like auto healing?

Can Ansible check the hosts for their desired state and when it detects a change, can it correct it automatically? Without needing to manually running the playbook again?

Hi Okmar,

Ansible itself does not include any kind of scheduling or regular runs. That is part of the agent-less approach that is one of Ansible's strengths. That does of course not mean that you can not accomplish what you are asking for, just that it's outside of the scope of Ansible itself.

These are some of the options that you have:
- Schedule regular (like hourly) ansible-pull runs via cron, that way your machine regularly pulls your playbooks and runs them locally. If you want to review playbook run logs centrally, you would need some sort of log collection on your hosts that ships them to a centralised place. https://docs.ansible.com/ansible/latest/cli/ansible-pull.html
- Use another system for scheduling regular playbook runs on your infrastructure. An example for this would be Continuous Delivery systems with scheduling features, like Jenkins or Gitlab. This has the advantage of having a centralised place for reviewing your playbook run logs. The Ansible ecosystem also has specialised software for this kind of management, with a much broader scope: https://www.ansible.com/products/awx-project

By the way, this mailing list is meant for development on the actual Ansible code, including Ansible modules. Please refer to the user mailing list in future: https://groups.google.com/forum/#!forum/ansible-project

Good luck,
//oolongbrothers

Thanks a lot for the explanation. It really helped. Going forward I’ll take care of posting to the correct mailing list. Thanks once again.