I’m attempting to create a ami on aws using Packer and Ansible. Every time that I try, the mysql init script claims that it failed to start mysql (by using service: name=mysql state=stopped and latter on service: name=mysql state=started). It appears that it can’t use the socket for some reason:
`
Jul 2 17:16:37 ip-172-31-33-157 /etc/init.d/mysql[19315]: 0 processes alive and ‘/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping’ resulted in
Jul 2 17:16:37 ip-172-31-33-157 /etc/init.d/mysql[19315]: #007/usr/bin/mysqladmin: connect to server at ‘localhost’ failed
Jul 2 17:16:37 ip-172-31-33-157 /etc/init.d/mysql[19315]: error: ‘Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)’
Jul 2 17:16:37 ip-172-31-33-157 /etc/init.d/mysql[19315]: Check that mysqld is running and that the socket: ‘/var/run/mysqld/mysqld.sock’ exists!
`
I’m able to log into the instance with the same user that is running the scripts and run the init script without any issues. I can stop it, start it and restart it and it works. I’m also able to use mysqladmin ping from the user that is running Ansible both regularly and with sudo. I’ve also run the Ansible script by logging in with that user and manually running the Ansible command (ansible-playbook minion.yml -c local -i inventory) and it fails with the same issue.
In case it matters I’m using the percona distribution 5.6 of mysql and Ansible 1.9.2.
Does anyone know what might be causing this?