geerlingguy / ansible-role-mysql

Ansible Role - MySQL
https://galaxy.ansible.com/geerlingguy/mysql/
MIT License
1.05k stars 865 forks source link

Operation CREATE USER failed for '********'@'%'\" #403

Closed misilot closed 4 years ago

misilot commented 4 years ago

Hello, I am running into a CREATE USER failure on a second run:

I have the following config:

  roles:
    - role: geerlingguy.mysql
      become: yes
      vars:
        mysql_root_password_update: true
        mysql_config_include_files:
          - src: ../roles/another-role/files/role-config.conf
        mysql_databases:
          - name: "{{ database }}"
            encoding: utf8mb4
            collation: utf8mb4_0900_ai_ci
        mysql_users:
          - name: "user"
            host: "%"
            password: "password"
            encrypted: no
            priv: "{{ database }}.*:ALL"
            append_privs: no
            state: present

On first run, everything is fine:

But if I re-provision: (commented out the no_log option)

TASK [geerlingguy.mysql : Ensure MySQL users are present.] ********************************************************************************************
[WARNING]: Module did not set no_log for update_password
failed: [ec2-server.compute-1.amazonaws.com] (item={'name': ' user', 'host': '%', 'password': '*****', 'encrypted': 'no', 'priv': 'database.*:ALL', 'append_privs': False, 'state': 'present'}) => {"ansible_loop_var": "item", "changed": false, "item": {"append_privs": false, "encrypted": "no", "host": "%", "name": " user", "password": "'*****',", "priv": "database.*:ALL", "state": "present"}, "msg": "(1396, \"Operation CREATE USER failed for 'database'@'%'\")"}

Any ideas what I can be doing wrong here? Environment

Host: Ubuntu 20.04
Ansible: 2.9.10
Guest: Ubuntu 20.04
MySQL: 8.0.20-0ubuntu0.20.04.1
misilot commented 4 years ago

Never mind, I ended up having a space in the username.

user: " {{ username }}"