In an ansible playbook I want to stop MariaDB if an upgrade is needed (restart from the RPM package does not always work in my situation). I\'m quite new to ansible.
The best way to handle this is use a "handler" eg something along the lines of
tasks:
- name: Update db
yum: name=MariaDB-server state=latest
notify:
- stop db
handlers:
- name: stop db
service: name=MariaDB-server state=stopped
You can specify multiple handlers if you need to do multiple things, but if you just want to restart the db, use restarted instead of stopped
http://docs.ansible.com/ansible/playbooks_best_practices.html