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 学習者の迅速な成長を支援します!