issues with mysql_user module, GRANT ALL not working

52 views
Skip to first unread message

Alex Nutts

unread,
Jul 30, 2018, 4:55:14 AM7/30/18
to Ansible Project
Dear community,


I'd like to apply this grant: GRANT ALL PRIVILEGES ON opennebula.* TO 'oneadmin' IDENTIFIED BY 'password' so I'm using the below listed role:


# roles/mariadb/tasks/users.yml
---

- name: Remove anonymous users
  mysql_user:
    name: ''
    host_all: true
    login_user: root
    login_password: "{{ mariadb_root_password }}"
    state: absent
  tags: mariadb

- name: Create the users
  mysql_user:
    name: oneadmin
    password: 'password'
    priv: 'opennebula.*:ALL'
    append_privs: yes
    login_user: root
    login_password: "{{ mariadb_root_password }}"
    state: present
  tags: mariadb


I run it ------------------- TASK [mariadb : Remove anonymous users] ************************************************************************************************************************* ok: [10.10.228.10] TASK [mariadb : Create the users] ******************************************************************************************************************************* ok: [10.10.228.10] ---------------- on the target host: MariaDB [(none)]> show grants for oneadmin; ERROR 1141 (42000): There is no such grant defined for user 'oneadmin' on host '%' MariaDB [(none)]> SELECT User, Host, Password FROM mysql.user; +----------+---------------------------------------------+-------------------------------------------+ | User | Host | Password | +----------+---------------------------------------------+-------------------------------------------+ | root | localhost | *697408D5AC32C63B9FBD5553BC305BB05F9E9B93 | | root | dssfsdfsdfsdffds | | | root | 127.0.0.1 | *697408D5AC32C63B9FBD5553BC305BB05F9E9B93 | | root | ::1 | *697408D5AC32C63B9FBD5553BC305BB05F9E9B93 | | oneadmin | localhost | *24E63683735E54D886487AD7025B8F6881B0B869 | | oneadmin | ::1 | *24E63683735E54D886487AD7025B8F6881B0B869 | +----------+---------------------------------------------+-------------------------------------------+


For some reason the GRANT ALL doesn't get applied when run with Ansible because if I run it manually I get:

MariaDB [(none)]> GRANT ALL PRIVILEGES ON opennebula.* TO 'oneadmin' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> show grants for oneadmin;
+---------------------------------------------------------------------------------------------------------+
| Grants for oneadmin@%                                                                                   |
+---------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'oneadmin'@'%' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19' |
| GRANT ALL PRIVILEGES ON `opennebula`.* TO 'oneadmin'@'%'                                                |
+---------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

Please help!
Thank you,
Alex


Reply all
Reply to author
Forward
0 new messages