Skip to content

Instantly share code, notes, and snippets.

@tsubakimoto
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubakimoto/58f82400f052a1b3653e to your computer and use it in GitHub Desktop.
Save tsubakimoto/58f82400f052a1b3653e to your computer and use it in GitHub Desktop.
```ruby
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "chef/centos-6.5"
config.vm.define "host" do |node|
node.vm.hostname = "host"
node.vm.network :private_network, ip: "192.168.56.200"
node.vm.provision "shell", inline: <<-EOT
yum update -y
wget https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh epel-release-6-8.noarch.rpm
yum install -y ansible
EOT
end
config.vm.define "web" do |node|
node.vm.hostname = "web"
node.vm.network :private_network, ip: "192.168.56.201"
end
end
```
@tsubakimoto
Copy link
Author

~/.ssh/config

Host web
  HostName 192.168.56.201

@tsubakimoto
Copy link
Author

~/hosts

[web]
192.168.56.201

@tsubakimoto
Copy link
Author

~/ansible.cfg

[defaults]
hostfile = ./hosts

@tsubakimoto
Copy link
Author

~/playbook.yml

---
- hosts: web
  sudo: yes
  tasks:
    - name: system update
      command: yum update
    - 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: install mysql
      yum: name=mysql-server state=latest
    - name: start mysql and enabled
      service: name=mysqld state=started enabled=yes
    - name: install libraries
      yum: name={{item}} state=latest
      with_items:
        - gcc-c++.x86_64
        - glib2-devel.x86_64
        - cairo-devel.x86_64
        - libpng-devel.x86_64
        - giflib-devel.x86_64
        - libjpeg-devel.x86_64
        - libtiff-devel.x86_64
        - libexif-devel.x86_64
        - httpd-devel.x86_64
        - bison.x86_64
        - gettext.x86_64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment