Simple Playbook for taking mysql dump
---
#This playbook is used to take mysql dump
#Here we have to use mysql_db module
- hosts: test
tasks:
- name: Taking mysql dump
mysql_db: state=dump login_user=root login_password=test name=test target=/tmp/test.sql
To run this
ansible-playbook -i host-file mysqlbackup.yml -k
To fire mysql commands i.e dump and other queries we have to install MYSQL-python package.
When we run Playbook for Mysql Dump we will get below error
TASK: [Taking mysql dump] *****************************************************
failed: [XXX.XXX.XXX.XXX] => {"failed": true}
msg: the python mysqldb module is required
FATAL: all hosts have already failed -- aborting
To resolve this issue we have to install MYSQL-python package
1) Install python-pip package
yum -y install python-pip
2) Then install MYSQL-python package
pip install MYSQL-python
If you are getting below error then
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-nqoOz1/MySQL-python/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-TZ8GC0-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-nqoOz1/MySQL-python
---
#This playbook is used to take mysql dump
#Here we have to use mysql_db module
- hosts: test
tasks:
- name: Taking mysql dump
mysql_db: state=dump login_user=root login_password=test name=test target=/tmp/test.sql
To run this
ansible-playbook -i host-file mysqlbackup.yml -k
To fire mysql commands i.e dump and other queries we have to install MYSQL-python package.
When we run Playbook for Mysql Dump we will get below error
TASK: [Taking mysql dump] *****************************************************
failed: [XXX.XXX.XXX.XXX] => {"failed": true}
msg: the python mysqldb module is required
FATAL: all hosts have already failed -- aborting
To resolve this issue we have to install MYSQL-python package
1) Install python-pip package
yum -y install python-pip
2) Then install MYSQL-python package
pip install MYSQL-python
If you are getting below error then
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-nqoOz1/MySQL-python/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-TZ8GC0-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-nqoOz1/MySQL-python
Install
yum install mysql-devel.x86_64
and
yum install python-devel
3) Now try to run again
pip install MYSQL-python
It Should work
No comments:
Post a Comment