--- - name: Remove remote root account (localhost-only) community.mysql.mysql_user: name: root host: "{{ ansible_fqdn }}" state: absent - name: Remove remote root account (::1) community.mysql.mysql_user: name: root host: ::1 state: absent - name: Remove remote root account (127.0.0.1) community.mysql.mysql_user: name: root host: 127.0.0.1 state: absent - name: Set root password for root@localhost community.mysql.mysql_user: name: root host: localhost password: "{{ mysql_root_password }}" state: present - name: Create my.cnf ansible.builtin.template: src: my.cnf.j2 dest: /root/.my.cnf owner: root group: root mode: 0600