NFSの設定方法1(Vagrant Ansible)


作りたいイメージ

In your local machine

mkdir nfs_lesson
cd nfs_lesson
vagrant box add "centos_6.6" https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.0.0/centos-6.6-x86_64.box
vagrant init
vi Vagrantfile
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.provider "virtualbox" do |vb|
    vb.memory = "256"
  end

  config.vm.define "host" do |node|
    node.vm.box = "centos_6.6"
    node.vm.hostname = "host"
    node.vm.network :private_network, ip: "192.168.43.60"
  end

  config.vm.define "web1" do |node|
    node.vm.box = "centos_6.6"
    node.vm.hostname = "web1"
    node.vm.network :private_network, ip: "192.168.43.61"
  end

  config.vm.define "web2" do |node|
    node.vm.box = "centos_6.6"
    node.vm.hostname = "web2"
    node.vm.network :private_network, ip: "192.168.43.62"
  end

  config.vm.define "nfs" do |node|
    node.vm.box = "centos_6.6"
    node.vm.hostname = "nfs"
    node.vm.network :private_network, ip: "192.168.43.63"
  end

end
vagrant up

Set up SSH in Host

vagrant ssh host
vi ~/.ssh/config
Host web1
  HostName 192.168.43.61
Host web2
  HostName 192.168.43.62
Host nfs
  HostName 192.168.43.63
chmod 600 ~/.ssh/config
ssh-keygen -t rsa
ssh-copy-id web1

password is vagrant

ssh-copy-id web2
ssh-copy-id nfs

Install Ansible in Host

wget https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo rpm -Uvh epel-release-6-8.noarch.rpm
sudo yum install -y ansible
vi hosts
[web]
192.168.43.61
192.168.43.62

[nfs]
192.168.43.63

If it fail, please try it again

ansible -vvvv all -i hosts -m ping