Created
January 12, 2015 13:07
-
-
Save lucachr/d6014f55360ed42dc224 to your computer and use it in GitHub Desktop.
An example playbook to install MySQL and configure the MySQL root password on Centos 6.x .
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all # Replace this with your database's host/group | |
vars: | |
mysql_password: xxxxxxxx # Replace this with your root mysql password | |
epel_repo: epel-release-6-8.noarch.rpm | |
sudo: yes | |
tasks: | |
# The EPEL repository is required to install Python pip | |
- name: Download EPEL-repo rpm for CentOS 6.x | |
get_url: dest=/tmp/{{ epel_repo }} | |
url=http://download.fedoraproject.org/pub/epel/6/{{ ansible_architecture }}/{{ epel_repo }} | |
- name: Install EPEL-repo rpm | |
yum: pkg=/tmp/{{ epel_repo }} state=installed | |
- name: Ensure Python pip is at the latest version | |
yum: pkg=python-pip state=latest | |
- name: Ensure MySQL server is at the latest version | |
yum: pkg=mysql-server state=latest | |
- name: Start mysqld, if not running | |
service: name=mysqld state=started | |
- name: Ensure MySQL-Python is at the latest version | |
yum: pkg=MySQL-python state=latest | |
- name: Install ConfigParser Python package | |
pip: name=configparser | |
# This step is required to run the template module | |
- name: Ensure libselinux-python is at the latest version | |
yum: pkg=libselinux-python state=latest | |
- name: Set the root user for MYSQL | |
mysql_user: name=root password={{ mysql_password }} | |
- name: Copy the ".my.cnf" file | |
template: src=my.cnf.j2 dest=~/.my.cnf mode=0600 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[client] | |
user=root | |
password={{ mysql_password }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment