Ansible way to stop a service only if it needs to be upgraded
问题 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. I came up with this: - name: "Check if MariaDB needs to be upgraded" shell: "yum check-update MariaDB-server|grep MariaDB|wc -l" register: needs_update - name: "Stop mysql service" service: name: mysql state: stopped when: needs_update.stdout == "1" Is there a better way to do this then by executing a shell command? When running