Created
April 7, 2014 19:04
Sample Vagrantfile to run MySQL on a centos vm
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
# Ansible playbook file for installing and configuring a MySQL server and | |
# Zookeeper in a Vagrant/VirtualBox VM. | |
# | |
# See for http://docs.ansible.com/playbooks.html syntax and | |
# http://docs.ansible.com/list_of_all_modules.html for details on each "task" | |
# entry. | |
--- | |
- hosts: all | |
sudo: yes | |
tasks: | |
#################### MYSQL #################### | |
- name: ensure mysql-server is installed | |
yum: name=mysql-server state=present | |
notify: | |
- restart mysqld | |
- name: ensure mysql daemon is running and starts on boot | |
service: name=mysqld state=started enabled=true | |
# needed for the mysql_db task below | |
- name: ensure MySQL-python library is installed | |
yum: name=MySQL-python state=present | |
- name: ensure fcs database exists | |
mysql_db: name=fcs state=present | |
- name: ensure remote user for fcs exists | |
mysql_user: name=fcs password=fcs host=% priv=*.*:ALL,GRANT state=present | |
notify: | |
- restart mysqld | |
- name: ensure localhost user for fcs exists | |
mysql_user: name=fcs password=fcs host=localhost priv=*.*:ALL,GRANT state=present | |
notify: | |
- restart mysqld | |
handlers: | |
- name: restart mysqld | |
service: name=mysqld state=restarted | |
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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
# downloads a CentOS 6.5 base image for the VM from https://vagrantcloud.com/chef/centos-6.5 | |
# although the box is from the people that make Chef, we use Ansible below for provisioning the VM | |
config.vm.box = "chef/centos-6.5" | |
# forward port 3306 to port 3306 on the guest (for mysqld) | |
config.vm.network "forwarded_port", guest: 3306, host: 3306 | |
# Use ansible to install mysql and zookeeper on the VM | |
config.vm.provision "ansible" do |ansible| | |
ansible.playbook = "setup/playbook.yml" | |
ansible.verbose = "v" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment