Thursday, January 26, 2023

unable to find /root/.my.cnf. Exception message: (1698, \"Access denied for user 'root'@'localhost

 While running Ansible 2.14.1, i am getting the error

"unable to find /root/.my.cnf. Exception message: (1698, \"Access denied for user 'root'@'localhost

Solution to fix is :

You need to login to the server and find the mysqld.sock file. In my Ubuntu22 machine its /var/run/mysqld/mysqld.sock

I need to update this in my playbook as

- name: Create Application database
mysql_db: name=employee_db state=present login_unix_socket=/var/run/mysqld/mysqld.sock

- name: Create Database User
name : db_user
password: Passw0rd
priv: '*.*:ALL'
login_unix_socket: /var/run/mysqld/mysqld.sock
state: present

Monday, January 2, 2023

ansible ssh key path in different location - Part 2

 Normally we will add the private key of the server in our .ssh/authorized keys, right?

But i want to keep the ssh key in a different location.

I created a folder called "centos" and i am planning to keep all the ansible files related to this project under this folder.


In this folder, I fist created an inventory file.

shivinvijai@Shivins-MacBook-Pro centos % cat inventory 

[myservers] ansible_user=opc ansible_ssh_private_key_file=/Users/shivinvijai/Desktop/Learnings/Ansilbe/ssh-key-2023-01-01.key

shivinvijai@Shivins-MacBook-Pro centos %

I specify my username and path to the ssh key file.

Now, I going to do a test, here i am using my own inventory file so the command will be this

shivinvijai@Shivins-MacBook-Pro centos % ansible -i inventory  -m ping myservers | SUCCESS => {

    "ansible_facts": {

        "discovered_interpreter_python": "/usr/libexec/platform-python"


    "changed": false,

    "ping": "pong"


Sunday, January 1, 2023

ansible host file location mac

 This is my first experience in MAC as an ansible control node. The FIX is listed in this link

This will fix your issue, for me its working fine.

Setting up my MAC as a Control node for my Ansible study - Part 1

 Here is my requirement, I am using my MAC so i need to develop Ansible playbooks in my MAC book.

I used PIP to install ansible in my mac book. After installation i am not able to do any ansible commands and I fixed the issue using this link (

After this, when you try to add hosts or ansible.cfg file, you may not find this in your mac.

I checked $HOME/.ansible folder and i can't find it.

I downloaded a sample configuration of ansible.cfg to the $HOME/.ansible folder

Then i created a hosts file which is defined in the inventory section of the ansible.cfg file.

localhost              ansible_connection=local

Then I tried a test using this command.

 ansible -i $HOME/.ansible/hosts -m ping all

localhost | SUCCESS => {

    "ansible_facts": {

        "discovered_interpreter_python": "/opt/homebrew/bin/python3.11"


    "changed": false,

    "ping": "pong"


After install ansible using pip in mac, I can't able to issue any ansible commands

 I installed ansible in my Mac using PIP. After installation i am not able to execute any ansible commands.

Fix :

Only for current session, you can export the path

export PATH="/Users/<username>/Library/Python/3.10/bin:$PATH"

For making it permeant, you need to open the file

vi ~/.zshrc (If not present, feel free to create it)

export PATH="/Users/<username>/Library/Python/3.10/bin:$PATH:

Source it,

source ~/.zshrc

After this, i could able to use ansible commands in my Mac