Ansibleとはなにか?

サーバー構成

Vagrantでサーバーを起動

$ cd ~/Documents/MyVagrant
$ mkdir ansible_lessons
$ cd ansible_lessons
$ vagrant init bento/centos-6.7
$ vi Vagrantfile
config.vm.box = "bento/centos-6.7"
config.vm.define "host" do |node|
  node.vm.box = "bento/centos-6.7"
  node.vm.hostname = "host"
  node.vm.network :private_network, ip: "192.168.43.51"
end

config.vm.define "web" do |node|
  node.vm.box = "bento/centos-6.7"
  node.vm.hostname = "web"
  node.vm.network :private_network, ip: "192.168.43.52"
end

config.vm.define "db" do |node|
  node.vm.box = "bento/centos-6.7"
  node.vm.hostname = "db"
  node.vm.network :private_network, ip: "192.168.43.53"
end
$ vagrant up
...
...
==> host: Successfully added box 'bento/centos-6.7' (v2.2.7) for 'virtualbox'!
...
...
$ vagrant status
Current machine states:

host                      running (virtualbox)
web                       running (virtualbox)
db                        running (virtualbox)

This environment represents multiple VMs. The VMs are all listed
above with their current state. For more information about a specific
VM, run `vagrant status NAME`.

Ansibleをインストールしてみよう

$ vagrant ssh host
[vagrant@host ~]$ wget https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
[vagrant@host ~]$ sudo rpm -Uvh epel-release-6-8.noarch.rpm
[vagrant@host ~]$ sudo yum -y install ansible
[vagrant@host ~]$ $ ansible --version
ansible 2.1.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides

トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS