Last active
August 29, 2015 14:19
-
-
Save nutti/9d8ab00da9485689fa36 to your computer and use it in GitHub Desktop.
[Ansible] Vagrantで構築した仮想マシンに対してAnsibleを試した時のメモ ref: http://qiita.com/nutti/items/c57c4031c83680f17645
This file contains hidden or 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
$ yum install https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.2_x86_64.rpm |
This file contains hidden or 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
$ yum install https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.2_x86_64.rpm |
This file contains hidden or 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
$ vagrant version | |
Installed Version: 1.7.2 |
This file contains hidden or 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
$ vagrant version | |
Installed Version: 1.7.2 |
This file contains hidden or 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
$ yum install ansible |
This file contains hidden or 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
$ yum install ansible |
This file contains hidden or 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
$ cd ~/ansible | |
$ touch hosts |
This file contains hidden or 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
$ cd ~/ansible | |
$ touch hosts |
This file contains hidden or 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
[ansible-nodes] | |
192.168.100.10 ansible_ssh_user=vagrant ansible_ssh_private_key_file=.vagrant/machines/node1/virtualbox/private_key | |
192.168.100.11 ansible_ssh_user=vagrant ansible_ssh_private_key_file=.vagrant/machines/node2/virtualbox/private_key | |
192.168.100.12 ansible_ssh_user=vagrant ansible_ssh_private_key_file=.vagrant/machines/node3/virtualbox/private_key |
This file contains hidden or 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
[ansible-nodes] | |
192.168.100.10 ansible_ssh_user=vagrant ansible_ssh_private_key_file=.vagrant/machines/node1/virtualbox/private_key | |
192.168.100.11 ansible_ssh_user=vagrant ansible_ssh_private_key_file=.vagrant/machines/node2/virtualbox/private_key | |
192.168.100.12 ansible_ssh_user=vagrant ansible_ssh_private_key_file=.vagrant/machines/node3/virtualbox/private_key |
This file contains hidden or 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
$ cp ~/.ssh/config ~/.ssh/config.orig | |
$ vagrant ssh-config > ~/.ssh/config |
This file contains hidden or 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
$ cp ~/.ssh/config ~/.ssh/config.orig | |
$ vagrant ssh-config > ~/.ssh/config |
This file contains hidden or 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
$ ansible -i hosts ansible-nodes -m ping | |
192.168.100.10 | success >> { | |
"changed": false, | |
"ping": "pong" | |
} | |
192.168.100.11 | success >> { | |
"changed": false, | |
"ping": "pong" | |
} | |
192.168.100.12 | success >> { | |
"changed": false, | |
"ping": "pong" | |
} |
This file contains hidden or 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
$ ansible -i hosts ansible-nodes -m ping | |
192.168.100.10 | success >> { | |
"changed": false, | |
"ping": "pong" | |
} | |
192.168.100.11 | success >> { | |
"changed": false, | |
"ping": "pong" | |
} | |
192.168.100.12 | success >> { | |
"changed": false, | |
"ping": "pong" | |
} |
This file contains hidden or 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
$ ssh node1 | |
$ which gcc | |
/usr/bin/which: no gcc in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/vagrant/bin) | |
$ which gdb | |
/usr/bin/which: no gdb in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/vagrant/bin) | |
$ ssh node2 | |
$ which gcc | |
/usr/bin/which: no gcc in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/vagrant/bin) | |
$ which gdb | |
/usr/bin/which: no gdb in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/vagrant/bin) | |
$ ssh node3 | |
$ which gcc | |
/usr/bin/which: no gcc in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/vagrant/bin) | |
$ which gdb | |
/usr/bin/which: no gdb in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/vagrant/bin) |
This file contains hidden or 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
$ ssh node1 | |
$ which gcc | |
/usr/bin/which: no gcc in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/vagrant/bin) | |
$ which gdb | |
/usr/bin/which: no gdb in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/vagrant/bin) | |
$ ssh node2 | |
$ which gcc | |
/usr/bin/which: no gcc in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/vagrant/bin) | |
$ which gdb | |
/usr/bin/which: no gdb in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/vagrant/bin) | |
$ ssh node3 | |
$ which gcc | |
/usr/bin/which: no gcc in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/vagrant/bin) | |
$ which gdb | |
/usr/bin/which: no gdb in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/vagrant/bin) |
This file contains hidden or 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: ansible-nodes | |
sudo: yes | |
tasks: | |
- name: install gcc | |
yum: name=gcc state=installed | |
- name: install gdb | |
yum: name=gdb state=installed |
This file contains hidden or 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: ansible-nodes | |
sudo: yes | |
tasks: | |
- name: install gcc | |
yum: name=gcc state=installed | |
- name: install gdb | |
yum: name=gdb state=installed |
This file contains hidden or 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
$ ansible-playbook -i hosts playbook.yml | |
PLAY [ansible-nodes] ********************************************************** | |
GATHERING FACTS *************************************************************** | |
ok: [192.168.100.12] | |
ok: [192.168.100.11] | |
ok: [192.168.100.10] | |
TASK: [install gcc] *********************************************************** | |
changed: [192.168.100.11] | |
changed: [192.168.100.10] | |
changed: [192.168.100.12] | |
TASK: [install gdb] *********************************************************** | |
changed: [192.168.100.10] | |
changed: [192.168.100.11] | |
changed: [192.168.100.12] | |
PLAY RECAP ******************************************************************** | |
192.168.100.10 : ok=3 changed=2 unreachable=0 failed=0 | |
192.168.100.11 : ok=3 changed=2 unreachable=0 failed=0 | |
192.168.100.12 : ok=3 changed=2 unreachable=0 failed=0 |
This file contains hidden or 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
$ ansible-playbook -i hosts playbook.yml | |
PLAY [ansible-nodes] ********************************************************** | |
GATHERING FACTS *************************************************************** | |
ok: [192.168.100.12] | |
ok: [192.168.100.11] | |
ok: [192.168.100.10] | |
TASK: [install gcc] *********************************************************** | |
changed: [192.168.100.11] | |
changed: [192.168.100.10] | |
changed: [192.168.100.12] | |
TASK: [install gdb] *********************************************************** | |
changed: [192.168.100.10] | |
changed: [192.168.100.11] | |
changed: [192.168.100.12] | |
PLAY RECAP ******************************************************************** | |
192.168.100.10 : ok=3 changed=2 unreachable=0 failed=0 | |
192.168.100.11 : ok=3 changed=2 unreachable=0 failed=0 | |
192.168.100.12 : ok=3 changed=2 unreachable=0 failed=0 |
This file contains hidden or 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
$ ssh node1 | |
$ which gcc | |
/usr/bin/gcc | |
$ which gdb | |
/usr/bin/gdb | |
$ ssh node2 | |
$ which gcc | |
/usr/bin/gcc | |
$ which gdb | |
/usr/bin/gdb | |
$ ssh node3 | |
$ which gcc | |
/usr/bin/gcc | |
$ which gdb | |
/usr/bin/gdb |
This file contains hidden or 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
$ ssh node1 | |
$ which gcc | |
/usr/bin/gcc | |
$ which gdb | |
/usr/bin/gdb | |
$ ssh node2 | |
$ which gcc | |
/usr/bin/gcc | |
$ which gdb | |
/usr/bin/gdb | |
$ ssh node3 | |
$ which gcc | |
/usr/bin/gcc | |
$ which gdb | |
/usr/bin/gdb |
This file contains hidden or 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
$ vagrant halt |
This file contains hidden or 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
$ vagrant halt |
This file contains hidden or 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
$ cd ~/ | |
$ mkdir ansible | |
$ cd ansible |
This file contains hidden or 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
$ cd ~/ | |
$ mkdir ansible | |
$ cd ansible |
This file contains hidden or 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
$ vagrant destroy |
This file contains hidden or 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
$ vagrant destroy |
This file contains hidden or 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
$ vagrant init [名称] [box] |
This file contains hidden or 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
$ vagrant init [名称] [box] |
This file contains hidden or 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
$ vagrant init centos6.5_ansible http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.5_chef-provisionerless.box |
This file contains hidden or 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
$ vagrant init centos6.5_ansible http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.5_chef-provisionerless.box |
This file contains hidden or 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
$ cp Vagrantfile Vagrantfile.orig | |
$ diff Vagrantfile |
This file contains hidden or 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
$ cp Vagrantfile Vagrantfile.orig | |
$ diff Vagrantfile |
This file contains hidden or 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
15c15,29 | |
< config.vm.box = "centos6.5_ansible" | |
--- | |
> config.vm.define :node1 do |node| | |
> node.vm.box = "centos6.5_ansible" | |
> node.vm.network :private_network, ip: "192.168.100.10" | |
> end | |
> | |
> config.vm.define :node2 do |node| | |
> node.vm.box = "centos6.5_ansible" | |
> node.vm.network :private_network, ip: "192.168.100.11" | |
> end | |
> | |
> config.vm.define :node3 do |node| | |
> node.vm.box = "centos6.5_ansible" | |
> node.vm.network :private_network, ip: "192.168.100.12" | |
> end | |
> |
This file contains hidden or 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
$ vagrant up |
This file contains hidden or 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
$ vagrant up |
This file contains hidden or 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
$ vagrant status | |
Current machine states: | |
node1 running (virtualbox) | |
node2 running (virtualbox) | |
node3 running (virtualbox) |
This file contains hidden or 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
$ vagrant status | |
Current machine states: | |
node1 running (virtualbox) | |
node2 running (virtualbox) | |
node3 running (virtualbox) |
This file contains hidden or 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
$ vagrant ssh node1 | |
(vagrantで作成した仮想マシン) |
This file contains hidden or 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
$ vagrant ssh node1 | |
(vagrantで作成した仮想マシン) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment