Activity log for bug #1923077

Date Who What changed Old value New value Message
2021-04-08 17:10:23 Bernie Hoeneisen bug added bug
2021-04-08 17:13:02 Bernie Hoeneisen description With MySQL version 8.0, the ansible mysql module runs into an error due while creating a new MySQL user with the option "encrypted: yes", when the MySQL user does not exist yet. The Bug appears to be in the 'user_add' function in file '/usr/lib/python3/dist-packages/ansible/modules/database/mysql/mysql_user.py' (see arrow below): ``` def user_add(cursor, user, host, host_all, password, encrypted, new_priv, check_mode): # we cannot create users without a proper hostname if host_all: return False if check_mode: return True if password and encrypted: ---> cursor.execute("CREATE USER %s@%s IDENTIFIED BY PASSWORD %s", (user, host, password)) <--- elif password and not encrypted: cursor.execute("CREATE USER %s@%s IDENTIFIED BY %s", (user, host, password)) else: cursor.execute("CREATE USER %s@%s", (user, host)) if new_priv is not None: for db_table, priv in iteritems(new_priv): privileges_grant(cursor, user, host, db_table, priv) return True ``` Ansible translates this to and tries to execute the following MySQL command which fails (here the output from mysql after retrying): ``` mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED BY PASSWORD "*123456789012345678901234567890"; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PASSWORD "*123456789012345678901234567890"' at line 1 ``` The MySQL following command actually does what I am trying to acomplis ``` mysql> CREATE USER 'bhoeneis'@'localhost' IDENTIFIED WITH mysql_native_password AS '*112B6255EF222A0E29C7F299DF6BB43048CDA254'; Query OK, 0 rows affected (0.01 sec) ``` With MySQL version 8.0, the ansible mysql module runs into an error while creating a new MySQL user with the option "encrypted: yes" (if the MySQL user does not exist yet). The Bug appears to be in the 'user_add' function in file '/usr/lib/python3/dist-packages/ansible/modules/database/mysql/mysql_user.py' (see arrow below): def user_add(cursor, user, host, host_all, password, encrypted, new_priv, check_mode):     # we cannot create users without a proper hostname     if host_all:         return False     if check_mode:         return True     if password and encrypted: ---> cursor.execute("CREATE USER %s@%s IDENTIFIED BY PASSWORD %s", (user, host, password)) <---     elif password and not encrypted:         cursor.execute("CREATE USER %s@%s IDENTIFIED BY %s", (user, host, password))     else:         cursor.execute("CREATE USER %s@%s", (user, host))     if new_priv is not None:         for db_table, priv in iteritems(new_priv):             privileges_grant(cursor, user, host, db_table, priv)     return True Ansible translates this to and tries to execute the following MySQL command which fails (here the output from mysql after retrying):   mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED BY PASSWORD "*123456789012345678901234567890";   ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PASSWORD "*123456789012345678901234567890"' at line 1 The following MySQL command actually does what I am trying to accomplish:   mysql> CREATE USER 'bhoeneis'@'localhost' IDENTIFIED WITH mysql_native_password AS '*112B6255EF222A0E29C7F299DF6BB43048CDA254';   Query OK, 0 rows affected (0.01 sec)
2021-04-08 17:14:24 Bernie Hoeneisen description With MySQL version 8.0, the ansible mysql module runs into an error while creating a new MySQL user with the option "encrypted: yes" (if the MySQL user does not exist yet). The Bug appears to be in the 'user_add' function in file '/usr/lib/python3/dist-packages/ansible/modules/database/mysql/mysql_user.py' (see arrow below): def user_add(cursor, user, host, host_all, password, encrypted, new_priv, check_mode):     # we cannot create users without a proper hostname     if host_all:         return False     if check_mode:         return True     if password and encrypted: ---> cursor.execute("CREATE USER %s@%s IDENTIFIED BY PASSWORD %s", (user, host, password)) <---     elif password and not encrypted:         cursor.execute("CREATE USER %s@%s IDENTIFIED BY %s", (user, host, password))     else:         cursor.execute("CREATE USER %s@%s", (user, host))     if new_priv is not None:         for db_table, priv in iteritems(new_priv):             privileges_grant(cursor, user, host, db_table, priv)     return True Ansible translates this to and tries to execute the following MySQL command which fails (here the output from mysql after retrying):   mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED BY PASSWORD "*123456789012345678901234567890";   ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PASSWORD "*123456789012345678901234567890"' at line 1 The following MySQL command actually does what I am trying to accomplish:   mysql> CREATE USER 'bhoeneis'@'localhost' IDENTIFIED WITH mysql_native_password AS '*112B6255EF222A0E29C7F299DF6BB43048CDA254';   Query OK, 0 rows affected (0.01 sec) With MySQL version 8.0, the ansible mysql module runs into an error while creating a new MySQL user with the option "encrypted: yes" (if the MySQL user does not exist yet). The Bug appears to be in the 'user_add' function in file '/usr/lib/python3/dist-packages/ansible/modules/database/mysql/mysql_user.py' (see arrow below): def user_add(cursor, user, host, host_all, password, encrypted, new_priv, check_mode):     # we cannot create users without a proper hostname     if host_all:         return False     if check_mode:         return True     if password and encrypted: ---> cursor.execute("CREATE USER %s@%s IDENTIFIED BY PASSWORD %s", (user, host, password)) <---     elif password and not encrypted:         cursor.execute("CREATE USER %s@%s IDENTIFIED BY %s", (user, host, password))     else:         cursor.execute("CREATE USER %s@%s", (user, host))     if new_priv is not None:         for db_table, priv in iteritems(new_priv):             privileges_grant(cursor, user, host, db_table, priv)     return True Ansible translates this to and tries to execute the following MySQL command which fails (here the output from mysql after retrying):   mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED BY PASSWORD "*123456789012345678901234567890";   ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PASSWORD "*123456789012345678901234567890"' at line 1 The following MySQL command actually does what I am trying to accomplish:   mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED WITH mysql_native_password AS '*123456789012345678901234567890';   Query OK, 0 rows affected (0.01 sec)
2021-04-08 17:49:04 Bernie Hoeneisen description With MySQL version 8.0, the ansible mysql module runs into an error while creating a new MySQL user with the option "encrypted: yes" (if the MySQL user does not exist yet). The Bug appears to be in the 'user_add' function in file '/usr/lib/python3/dist-packages/ansible/modules/database/mysql/mysql_user.py' (see arrow below): def user_add(cursor, user, host, host_all, password, encrypted, new_priv, check_mode):     # we cannot create users without a proper hostname     if host_all:         return False     if check_mode:         return True     if password and encrypted: ---> cursor.execute("CREATE USER %s@%s IDENTIFIED BY PASSWORD %s", (user, host, password)) <---     elif password and not encrypted:         cursor.execute("CREATE USER %s@%s IDENTIFIED BY %s", (user, host, password))     else:         cursor.execute("CREATE USER %s@%s", (user, host))     if new_priv is not None:         for db_table, priv in iteritems(new_priv):             privileges_grant(cursor, user, host, db_table, priv)     return True Ansible translates this to and tries to execute the following MySQL command which fails (here the output from mysql after retrying):   mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED BY PASSWORD "*123456789012345678901234567890";   ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PASSWORD "*123456789012345678901234567890"' at line 1 The following MySQL command actually does what I am trying to accomplish:   mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED WITH mysql_native_password AS '*123456789012345678901234567890';   Query OK, 0 rows affected (0.01 sec) With MySQL version 8.0, the ansible mysql module runs into an error while creating a new MySQL user with the option "encrypted: yes" (if the MySQL user does not exist yet). The Bug appears to be in the 'user_add' function in file '/usr/lib/python3/dist-packages/ansible/modules/database/mysql/mysql_user.py' (see arrow below): def user_add(cursor, user, host, host_all, password, encrypted, new_priv, check_mode):     # we cannot create users without a proper hostname     if host_all:         return False     if check_mode:         return True     if password and encrypted: ---> cursor.execute("CREATE USER %s@%s IDENTIFIED BY PASSWORD %s", (user, host, password)) <---     elif password and not encrypted:         cursor.execute("CREATE USER %s@%s IDENTIFIED BY %s", (user, host, password))     else:         cursor.execute("CREATE USER %s@%s", (user, host))     if new_priv is not None:         for db_table, priv in iteritems(new_priv):             privileges_grant(cursor, user, host, db_table, priv)     return True Ansible translates this to and tries to execute the following MySQL command which fails (here the output from mysql after retrying):   mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED BY PASSWORD "*123456789012345678901234567890";   ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PASSWORD "*123456789012345678901234567890"' at line 1 The following MySQL command actually does what I am trying to accomplish:   mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED WITH mysql_native_password AS '*123456789012345678901234567890';   Query OK, 0 rows affected (0.01 sec) --- ansible-playbook version: 2.9.9 python version = 3.8.6 (default, Jan 27 2021, 15:42:20) [GCC 10.2.0]
2021-04-14 13:57:55 Launchpad Janitor ansible (Ubuntu): status New Confirmed