Issues with mysql_user module

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 . Kindly help me see what I am doing wrong.

Best Regards,

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,

Hello Jean-Yves

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

thanks for you help

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
   mysql_user: name=root host={{ item }} check_implicit_admin=yes password={{ inst_mysql_standalone_rootpassword }}
   with_items:
     - "{{ ansible_fqdn }}"
     - 127.0.0.1
     - localhost

- name: Modify options of ~/.my.cnf
   ini_file: dest=~/.my.cnf section=client option={{ item.option }} value={{ item.value }} mode=600
   with_items :
     - { option: 'user', value: 'root'}
     - { option: 'password', value: "{{ inst_mysql_standalone_rootpassword }}"}

- name: remove anonymous access
   mysql_user: name="" host={{ item }} check_implicit_admin=yes password={{ inst_mysql_standalone_rootpassword }} state=absent
   with_items:
     - "{{ ansible_fqdn }}"
     - 127.0.0.1
     - "::1"
     - localhost
     - "%"

- name: Remove test database
   mysql_db: name=test state=absent

Regards,

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

Anybody else having the same behavior?

Best Regards,

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