-
-
Save mathhun/28f11620288cc873d1ba to your computer and use it in GitHub Desktop.
This file contains 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
[defaults] | |
hostfile = ./hosts |
This file contains 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
[web] | |
192.168.43.52 | |
[db] | |
192.168.43.53 |
This file contains 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
--- | |
- hosts: all | |
sudo: yes | |
vars: | |
username: akiyama | |
tasks: | |
- name: add a new user | |
user: name={{username}} state=present | |
- name: install libselinux-python | |
yum: name=libselinux-python state=latest | |
- hosts: web | |
sudo: yes | |
tasks: | |
- name: install apache | |
yum: name=httpd state=latest | |
- name: start apache and enabled | |
service: name=httpd state=started enabled=yes | |
- name: change owner | |
file: dest=/var/www/html owner=vagrant recurse=yes | |
- name: copy index.html | |
copy: src=index.html dest=/var/www/html/index.html owner=vagrant | |
- name: install php packages | |
yum: name={{item}} state=latest | |
with_items: | |
- php | |
- php-devel | |
- php-mbstring | |
- php-mysql | |
notify: | |
- restart apache | |
- name: copy hello.php | |
copy: src=./hello.php dest=/var/www/html/hello.php owner=vagrant | |
handlers: | |
- name: restart apache | |
service: name=httpd state=restarted | |
- hosts: db | |
sudo: yes | |
tasks: | |
- name: install mysql | |
yum: name={{item}} state=latest | |
with_items: | |
- mysql-server | |
- MySQL-python | |
- name: start mysql and enabled | |
service: name=mysqld state=started enabled=yes | |
- name: create database | |
mysql_db: name=mydb state=present | |
- name: create mysql user | |
mysql_user: name=dbuser password=dbpassword priv=mydb.*:ALL state=present |
This file contains 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 : | |
# All Vagrant configuration is done below. The "2" in Vagrant.configure | |
# configures the configuration version (we support older styles for | |
# backwards compatibility). Please don't change it unless you know what | |
# you're doing. | |
Vagrant.configure(2) do |config| | |
# The most common configuration options are documented and commented below. | |
# For a complete reference, please see the online documentation at | |
# https://docs.vagrantup.com. | |
# Every Vagrant development environment requires a box. You can search for | |
# boxes at https://atlas.hashicorp.com/search. | |
#config.vm.box = "chef/centos-6.5" | |
config.vm.define "host" do |node| | |
node.vm.box = "chef/centos-6.5" | |
node.vm.hostname = "host" | |
node.vm.network :private_network, ip: "192.168.43.51" | |
end | |
config.vm.define "web" do |node| | |
node.vm.box = "chef/centos-6.5" | |
node.vm.hostname = "web" | |
node.vm.network :private_network, ip: "192.168.43.52" | |
end | |
config.vm.define "db" do |node| | |
node.vm.box = "chef/centos-6.5" | |
node.vm.hostname = "db" | |
node.vm.network :private_network, ip: "192.168.43.53" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment