We have seen setting up the database. The following code snippet shows how we can harden the MySQL service by binding it to localhost and the required interfaces for interacting with the application. It then removes the anonymous user and test databases:
- name: delete anonymous mysql user for localhost mysql_user: user: "" state: absent login_password: "{{ mysql_root_password }}" login_user: root