Install MySQL with ansible on ubuntu -


I have a problem installing MySQL with a legitimate Ubuntu,

This is my MySQL is part

  --- - Name: MySQL install appropriate: Name: "{{item}}" with_items: - python-mysqldb - mysql- server - name: copy .my File credentials template with cnf root password: src: templates / root / .my.cnf dest: ~ / .my.cnf Owner: Route Mode: 0600 - Name: Start MySQL Service Service: Name: mysql Status: Enabled Is: right # 'localhost' To be the last item for Idempotency, # http://ansible.cc/docs/modules.html#mysql-user-name: Update mysql root password for all root accounts mysql_user: name: root host: "{{Item}}" password: "{{mysql_root_password}}" personal: "*. *: ALL, grant" with_items: - "{{ansible_hostname}}" - 127.0.0.1 - :: 1 - localhost  

and I have this error

  failed: [default] = & gt; (Object = vagina-Ubuntu-dependable-64) = & gt; {"Failed": true, "item": "vagrant-ubuntu-trusty-64"} msg: unable to connect to the database, check login_user and login_password or credentials of ~ / .my.cnf have failed: [default] = & Gt; (Item = 127.0.0.1) = & gt; {"Failed": true, "item": "127.0.0.1"}: Unable to connect to the database, login_user and login_password is correct or the credentials of ~ / .my.cnf are unsuccessful: [default] = & Gt; (Object = :: 1) = & gt; {"Failed": true, "item": ":: 1"} msg: Unable to connect to the database, check login_user and login_password or credentials of ~ / .my.cnf have failed: [default] = & gt; (Item = localhost) = & gt; {"Unsuccessful": true, "item": "localhost"} msg: unable to connect to database, login_sir and login_password are correct or have credentials of ~ / .my.cnf  

Mine. Cnf is

  [customer] user = root password = {{mysql_root_password}}  

and while copying to server

<

I do not understand why, ~ / .my.cnf is created

project

thanks

When mysql-server is installed without a head, there is no password therefore To work, .my.cnf should work, there should be an empty password line that I have to do with .my.cnf :

  [ Client] user = root password =  

I have tested it for I . My.cnf is a little bit weird for keeping it in the root of its code in its vagrant user directory and is readable as root only.

After ensuring that the password was empty in .my.cnf , I was able to set the password correctly for those root references that note that after this Fails to run, as the .my.cnf will need to be updated, so this idempotency test fails.

There is a note on the responsive mysql_user module page that suggests writing a password and writing then .my.cnf file. If you do this, you need a where section mysql_user action (possibly with the file state before it).

Use even more elegant check_implicit_admin with login_user and login_password .

The third way is, maybe check_implicit_admin makes it even easier.

Showing above, some fresh server. It is very proud to note that .my.cnf is unnecessary for all of this.

  --- - Host: mysql vars: mysql_root_password: fart Functions: - Name: install MySQL apt: Name = {{item}} update_cache = yes cache_valid_time = 3600 state = present sudo : Yes with_items: - python-mysqldb - mysql- server # - name: copy cnf # copy: src = .my.cnf dest = ~ / .my .cnf owner = ubuntu mode = 0644 # sudo: yes - name: MySQL service Start: sudo: yes service: name: mysql status: enabled enabled: true - name: update mysql root password for all root accounts sudo: yes mysql_user: name: "{{item}}" password: "{{ Mysql_root_password}} "login_user: root login_password:" {{mysql_root_password}} "check_implicit_admin: yes personal:" *. *: ALL, grant "with_it Ems: - "{{Ansible_hostname}}" - 127.0.0.1 - :: 1 - Localhost  

(edit-my.cnf has been deleted)


Comments