Quick MySQL Box UsingVagrant and Ansible_MySQL

WBOY
풀어 주다: 2016-06-01 13:06:12
원래의
1099명이 탐색했습니다.

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
로그인 후 복사

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
로그인 후 복사

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

[client]user=rootpassword=password
로그인 후 복사

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.

원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!