Thanks. I didn't notice "host="$server_hostname"" thing as the play ended 
before that task. The task which failed is "name: update mysql root 
password for all root accounts".

On Thursday, July 17, 2014 6:03:56 PM UTC+5:30, Michael DeHaan wrote:
>
> Minor pet peeve - That's not an idempotency failure, you have trouble 
> logging into a MySQL database.
>
> I will stick voodoo pins into those that made use of that word so commonly 
> confused :)   Not your vault of course.
>
> I do notice you are using horribly dated Ansible syntax with
>
> "host="$server_hostname""
>
> Variables look like {{ server_hostname }} not $server_hostname
>
> This may be your problem.
>
>
> On Thu, Jul 17, 2014 at 7:40 AM, Chinmaya Patanaik <[email protected] 
> <javascript:>> wrote:
>
>> Hi,
>>
>> I am trying to incorporate mysql secure installation using Ansible 
>> playbook. I followed the below links.
>>
>> 1. 
>> http://stackoverflow.com/questions/16444306/ansible-idempotent-mysql-installation-playbook
>> 2. https://groups.google.com/forum/#!topic/ansible-project/-jSfGwpk5J8
>>
>> Target Server - Amazon Linux AMI(YUM based distro)
>>
>> My Playbook looks like this.
>>
>> ---
>>
>> - name: Install mysql using yum
>>   action: yum pkg={{item}} state=latest
>>   with_items:
>>
>>       - MySQL-python
>>
>>       - mysql
>>       - mysql-server
>>     
>> - name: Start the mysql server
>>
>>   service: name=mysqld state=running enabled=yes
>>
>> - name: copy .my.cnf file with root password credentials
>>
>>   template: src=my.cnf.j2 dest=/root/.my.cnf owner=root mode=0600
>>
>>
>> # 'localhost' needs to be the last item for idempotency, see
>> # 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 
>> }}
>>   with_items:
>>     - '{{ ansible_hostname }}'
>>      - 127.0.0.1
>>       - ::1
>>       - localhost
>>
>> - name: delete anonymous MySQL server user for $server_hostname
>>   action: mysql_user user="" host="$server_hostname" state="absent"
>>
>> - name: delete anonymous MySQL server user for localhost
>>   action: mysql_user user="" state="absent"
>>
>> - name: remove the MySQL test database
>>   action: mysql_db db=test state=absent
>>
>> My cnf file is -
>>
>> $cat roles/database/templates/.my.cnf.j2
>> [client] user=root password={{ mysql_root_password }}
>>
>>
>>
>> and My variable file is -
>>
>> $cat roles/database/vars/main.yml
>> user: root mysql_root_password: *******
>>
>>
>> But when I run the playbook, I am getting the following error.
>>
>> msg: unable to connect to database, check login_user and login_password 
>> are correct or ~/.my.cnf has the credentials 
>>
>> I am doing exactly the same as mentioned in the above 2 links. I even 
>> tried to perform the conf file copy task before root password change task. 
>> But I am still unable to run it successfully.
>>
>>
>> I would really appreciate any kind of help.
>>
>> Thanks,
>> Chinmaya
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/cf9ca391-f2b2-4c6f-b342-01df409912e5%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/cf9ca391-f2b2-4c6f-b342-01df409912e5%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b149659b-f218-4bca-ad60-9bea19e5a0fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to