Created
December 24, 2013 00:17
-
-
Save ihassin/8106956 to your computer and use it in GitHub Desktop.
Ansible script to install mySQL
This file contains hidden or 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: webservers | |
user: vagrant | |
sudo: true | |
vars_files: | |
- vars.yml | |
tasks: | |
- name: Install MySQL | |
action: apt pkg=$item state=installed | |
with_items: | |
- mysql-server-core-5.5 | |
- mysql-client-core-5.5 | |
- libmysqlclient-dev | |
- python-mysqldb | |
- mysql-server | |
- mysql-client | |
- name: Start the MySQL service | |
action: service name=mysql state=started | |
- name: Remove the test database | |
mysql_db: name=test state=absent | |
- name: Create deploy user for mysql | |
mysql_user: user="deploy" host="%" password={{mysql_root_password}} priv=*.*:ALL,GRANT | |
- name: Ensure anonymous users are not in the database | |
mysql_user: user='' host=$item state=absent | |
with_items: | |
- 127.0.0.1 | |
- ::1 | |
- localhost | |
- name: Copy .my.cnf file with root password credentials | |
template: src=templates/.my.cnf dest=/etc/mysql/my.cnf owner=root mode=0600 | |
- name: Update mysql root password for all root accounts | |
mysql_user: name=root host={{item}} password={{mysql_root_password}} | |
with_items: | |
- 127.0.0.1 | |
- ::1 | |
- localhost |
this is great. ๐
Thanks.
can you tell me for which OS this code is intended?
linux family
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is great. ๐
Thanks.
can you tell me for which OS this code is intended?