From 34076282db42f2d4f4c63f1ea49c22abef226245 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Mon, 8 Feb 2016 16:42:56 +0100 Subject: [PATCH] mysql-server: Only remove root@localhost when not active --- roles/mysql-server/tasks/main.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/roles/mysql-server/tasks/main.yml b/roles/mysql-server/tasks/main.yml index 645a32c..dff91e3 100644 --- a/roles/mysql-server/tasks/main.yml +++ b/roles/mysql-server/tasks/main.yml @@ -104,7 +104,7 @@ priv="*.*:ALL,GRANT" state=present -- name: Remove unwanted MySQL "root" accounts +- name: Remove unwanted MySQL "root" accounts (1/2) tags: - mysql - mysql-users @@ -116,6 +116,19 @@ 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" -- 2.39.2