centos-7.0
vagrant box add centos7 http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-7.0_chef-provisionerless.box
centos-6.5
vagrant box add chef/centos-7.0
centos-7.0
[16:57:05 - 15-03-01] /Users/toripiyo/vagrant/ansible7 % cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define :node1 do |node|
node.vm.box = "chef/centos-7.0"
node.vm.network :forwarded_port, guest: 22, host: 2001, id: "ssh"
node.vm.network :private_network, ip: "192.168.33.11"
end
config.vm.define :node2 do |node|
node.vm.box = "chef/centos-7.0"
node.vm.network :forwarded_port, guest: 22, host: 2002, id: "ssh"
node.vm.network :forwarded_port, guest: 80, host: 8000, id: "http"
node.vm.network :private_network, ip: "192.168.33.12"
end
end
centos-6.5
[19:18:05 - 15-03-01] /Users/toripiyo/vagrant/ansible % cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define :node1 do |node|
node.vm.box = "chef/centos-6.5"
node.vm.network :forwarded_port, guest: 22, host: 2001, id: "ssh"
node.vm.network :private_network, ip: "192.168.33.11"
end
config.vm.define :node2 do |node|
node.vm.box = "chef/centos-6.5"
node.vm.network :forwarded_port, guest: 22, host: 2002, id: "ssh"
node.vm.network :forwarded_port, guest: 80, host: 8000, id: "http"
node.vm.network :private_network, ip: "192.168.33.12"
end
end
vagrant up
*vagrant version 1.7.2 is recommended
[21:08:32 - 15-02-21] /Users/toripiyo/vagrant/ansible % vagrant ssh-config node1 > ssh_config
[21:08:49 - 15-02-21] /Users/toripiyo/vagrant/ansible % vagrant ssh-config node2 >> ssh_config
[21:12:23 - 15-02-21] /Users/toripiyo/vagrant/ansible % scp -F ssh_config ~/.vagrant.d/insecure_private_key node1:.ssh/id_rsa
insecure_private_key
##set up ansible
install python and ansible
vagrant ssh node1
sudo yum install bzip2-devel sqlite-devel git patch gcc zlib zlib-devel readline readline-devel openssl openssl-devel
mkdir ansible
cd ansible
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
exec $SHELL
pyenv install 2.7.9
pyenv local 2.7.9
pip install ansible
ansible --version
echo 192.168.33.12 > hosts
ansible --ask-pass -i hosts 192.168.33.12 -m ping -c paramiko
SSH password:
192.168.33.12 | success >> {
"changed": false,
"ping": "pong"
}
ansible setup playbook
a-simple-insecure-way-to-use-ansible