# Issues with mysql\_user module

**URL:** <https://forum.ansible.com/t/issues-with-mysql-user-module/19579>\
**Category:** Ansible Project\
**Created:** [October 21, 2015, 5:48pm UTC](https://forum.ansible.com/t/issues-with-mysql-user-module/19579 "2015-10-21T17:48:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joseph\_DJOMEDA](https://avatars.discourse-cdn.com/v4/letter/j/13edae/32.png) [@Joseph\_DJOMEDA](https://forum.ansible.com/u/Joseph_DJOMEDA)\
**Post date:** [October 21, 2015, 5:48pm UTC](https://forum.ansible.com/t/issues-with-mysql-user-module/19579/1 "2015-10-21T17:48:00Z")

</div>

Hello Guys,

It looks like I am still not able to have this done as explained on the mysql\_user documentation.

Here is my tasks and output [pastie.org](http://pastie.org/10498138) . Kindly help me see what I am doing wrong.

Best Regards,

---

<div class="post-metadata">

**Author:** ![jean-yves](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jean-yves](https://forum.ansible.com/u/jean-yves)\
**Post date:** [October 21, 2015, 7:11pm UTC](https://forum.ansible.com/t/issues-with-mysql-user-module/19579/2 "2015-10-21T19:11:38Z")

</div>

Perhaps you should use “check\_implicit\_admin” option in your mysql\_user use. The first time you run your playbook the password is not set I think. The notify I think is wrong… You should have mysql started to be able to change the password, so it should be more a restart than a start Regards,

---

<div class="post-metadata">

**Author:** ![Joseph\_DJOMEDA](https://avatars.discourse-cdn.com/v4/letter/j/13edae/32.png) [@Joseph\_DJOMEDA](https://forum.ansible.com/u/Joseph_DJOMEDA)\
**Post date:** [October 22, 2015, 9:47am UTC](https://forum.ansible.com/t/issues-with-mysql-user-module/19579/3 "2015-10-22T09:47:53Z")

</div>

Hello Jean-Yves

I have implemented your suggestions and it still didn’t work. Kindly check the updated files on [http://pastie.org/10499468](http://pastie.org/10499468)

thanks for you help

---

<div class="post-metadata">

**Author:** ![jean-yves](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jean-yves](https://forum.ansible.com/u/jean-yves)\
**Post date:** [October 22, 2015, 10:00am UTC](https://forum.ansible.com/t/issues-with-mysql-user-module/19579/4 "2015-10-22T10:00:55Z")

</div>

The following playbook works for me and is idempotent :

#Notes: - Change password for root@localhost last, to not loose access to mysql  
# - If password already changed read it from .my.cnf (Example : second run of this playbook)  
- name: Set root password  
&nbsp;&nbsp;&nbsp;mysql\_user: name=root host={{ item }} check\_implicit\_admin=yes password={{ inst\_mysql\_standalone\_rootpassword }}  
&nbsp;&nbsp;&nbsp;with\_items:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- "{{ ansible\_fqdn }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- 127.0.0.1  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- localhost

- name: Modify options of ~/.my.cnf  
&nbsp;&nbsp;&nbsp;ini\_file: dest=~/.my.cnf section=client option={{ item.option }} value={{ item.value }} mode=600  
&nbsp;&nbsp;&nbsp;with\_items :  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- { option: 'user', value: 'root'}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- { option: 'password', value: "{{ inst\_mysql\_standalone\_rootpassword }}"}

- name: remove anonymous access  
&nbsp;&nbsp;&nbsp;mysql\_user: name="" host={{ item }} check\_implicit\_admin=yes password={{ inst\_mysql\_standalone\_rootpassword }} state=absent  
&nbsp;&nbsp;&nbsp;with\_items:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- "{{ ansible\_fqdn }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- 127.0.0.1  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- "::1"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- localhost  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- "%"

- name: Remove test database  
&nbsp;&nbsp;&nbsp;mysql\_db: name=test state=absent

Regards,

---

<div class="post-metadata">

**Author:** ![Joseph\_DJOMEDA](https://avatars.discourse-cdn.com/v4/letter/j/13edae/32.png) [@Joseph\_DJOMEDA](https://forum.ansible.com/u/Joseph_DJOMEDA)\
**Post date:** [October 22, 2015, 12:36pm UTC](https://forum.ansible.com/t/issues-with-mysql-user-module/19579/5 "2015-10-22T12:36:13Z")

</div>

Hi All,

I am starting to pull my hair now. I am using vagrant by the way and it’s ubuntu trusty with 1GB ram. I am not sure if this even helps . latest tasks are on [http://pastie.org/10499745](http://pastie.org/10499745)

Anybody else having the same behavior?

Best Regards,

---

<div class="post-metadata">

**Author:** ![Matthew\_Macdonald-Wa](https://avatars.discourse-cdn.com/v4/letter/m/f1d935/32.png) [@Matthew\_Macdonald-Wa](https://forum.ansible.com/u/Matthew_Macdonald-Wa)\
**Post date:** [November 4, 2015, 4:00pm UTC](https://forum.ansible.com/t/issues-with-mysql-user-module/19579/6 "2015-11-04T16:00:09Z")

</div>

Hi,

Did you get a fix for this?

I’ve noticed that if I install on CentOS and therefore have a blank root password by default, then I run into this issue whilst trying to set the root password.

Under Ubuntu, we use debconf-set-selections and pre-seed the root password and this appears to work fine.

FWIW, this is my task in my rhel/centos specific tasks file:

- name: Create the mysql\_root\_password based on the variables  
mysql\_user:  
name: root  
password: “{{ mysql\_root\_password }}”  
host: “{{ item }}”  
check\_implicit\_admin: yes  
when: mysqlserver == True  
with\_items:
- “{{ ansible\_hostname }}”
- 127.0.0.1
- ::1
- localhost

I’m running Ansible 1.9.4 from EPEL.

Cheers,

Matt
