Skip to content

Instantly share code, notes, and snippets.

@Shinichi-Nakagawa
Created February 10, 2015 15:30
Show Gist options
  • Save Shinichi-Nakagawa/39dd25f92cebba45a7be to your computer and use it in GitHub Desktop.
Save Shinichi-Nakagawa/39dd25f92cebba45a7be to your computer and use it in GitHub Desktop.
- hosts: retrosheet
user: vagrant
sudo: yes
vars:
host: "localhost"
mysql_database: "retrosheet"
mysql_schema_sql: "/vagrant/schema.sql"
vars_prompt:
mysql_root_db_password: "MySQL root password"
mysql_app_db_password: "MySQL app password"
tasks:
- name: Apt install packages
apt: update_cache=yes pkg={{ item }}
with_items:
- git
- python-pip
- python-mysqldb
- mysql-server-5.6
- name: MySQL root user settings
mysql_user: name=root password={{ mysql_root_db_password }}
- name: MySQL create database
mysql_db: login_user=root login_password={{ mysql_root_db_password }} name={{ mysql_database }} state=present encoding=utf8
- name: MySQL create schema
mysql_db: login_user=root login_password={{ mysql_root_db_password }} name={{ mysql_database }} target={{ mysql_schema_sql }} state=import
- name: MySQL create app user
mysql_user: login_user=root login_password={{ mysql_root_db_password }} name=app password={{ mysql_app_db_password }} priv=retrosheet.*:ALL,GRANT host=% state=present
- name: Apt upgrade
apt: upgrade=dist
- name: copy my.cnf
copy: src=my.cnf dest=/etc/mysql/my.cnf owner=root mode=0600
- name: Restart the MySQL service
service: name=mysql state=restarted enabled=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment