]> arthur.barton.de Git - AnsibleRoles.git/blobdiff - roles/mysql-server/tasks/main.yml
mysql-server: Only remove root@localhost when not active
[AnsibleRoles.git] / roles / mysql-server / tasks / main.yml
index 645a32c3693d02b470af8f53a5c65ba46af99ef6..dff91e3722f79e1a810a0e89722aad79f9e1eae6 100644 (file)
     priv="*.*:ALL,GRANT"
     state=present
 
-- name: Remove unwanted MySQL "root" accounts
+- name: Remove unwanted MySQL "root" accounts (1/2)
   tags:
     - mysql
     - mysql-users
     state=absent
   with_items:
     - "{{ ansible_hostname }}"
-    - "localhost"
     - "127.0.0.1"
     - "::1"
+
+- name: Remove unwanted MySQL "root" accounts (2/2)
+  tags:
+    - mysql
+    - mysql-users
+  mysql_user: >
+    login_user={{ mysql_server_ansible_user }}
+    login_password={{ mysql_server_ansible_password }}
+    host={{ item }}
+    name=root
+    state=absent
+  with_items:
+    - "localhost"
+  when: mysql_server_root_host != "localhost"