Home > Database > Mysql Tutorial > body text

Quick MySQL Box UsingVagrant and Ansible_MySQL

WBOY
Release: 2016-06-01 13:06:12
Original
1099 people have browsed it

I needed a quick and minimal MySQL box to use for some development work. I didn't want this box to be laden with a full LAMP stack (plus a myriad of other tools PHP'ers seem to need in their endeavors). Unfortunately, I didn't find one. This forced me to create one, which I share with you now.

The Vagrant file is simple:

# -*- mode: ruby -*-# vi: set ft=ruby :VAGRANTFILE_API_VERSION = "2"Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|config.vm.box = "2creatives-centos64"config.vm.box_url = "https://github.com/2creatives/" +"vagrant-centos/releases/download/v0.1.0/" +"centos64-x86_64-20131030.box"config.vm.network "forwarded_port", guest: 3306, host: 3306config.vm.network "private_network", ip: "192.168.24.42"config.vm.provider "virtualbox" do |vb| vb.customize ["modifyvm", :id, "--memory", "2048"]endconfig.vm.provision "ansible" do |ansible|ansible.playbook = "playbook.yml"ansible.verbose = "vv"ansible.sudo = trueendend
Copy after login

And the playbook:

---- hosts: allvars:root_db_password: passwordgather_facts: Truetasks:- name: Install MySQLyum: name=mysql-server state=installed- name: Install MySQL-pythonyum: name=MySQL-python state=installed- name: Ensure MySQL is runningservice: name=mysqld state=started enabled=true- name: Ensure IPTables is not runningservice: name=iptables state=stopped enabled=false- name: Copy the my.cnfcopy: src=my.cnf dest=/root/.my.cnf owner=root mode=0600- name: Update MySQL Root Passwordmysql_user: name=root host=$item password=$root_db_passwordwith_items:- $ansible_hostname- 192.168.24.1- 127.0.0.1- ::1- localhost- name: Annonymous Users not in MySQLmysql_user: name='' host=$item state=absentwith_items:- localhost- $inventory_hostname- name: Test Database is Removedmysql_db: name=test state=absent
Copy after login

And finally, you will notice we are copying a local instance ofmy.cnfto the virtual machine:

[client]user=rootpassword=password
Copy after login

As I said, it's very minimal.

You can clone the deployment from this repository:https://github.com/rclayton/vagrant-mysql

Also, I want to thankLorin Hochsteinfor a portion of the Ansible config (particularly saving me some time on removing some of the default gruff.

Richard Clayton–Unrepentant Thoughts on Software and Management.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!