Last active
July 30, 2018 17:05
-
-
Save jovenbico/b8ce79ae8f42d25d038dee38aeb15e89 to your computer and use it in GitHub Desktop.
Vagrant getting started
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
[defaults] | |
host_key_checking = False | |
[ssh_connection] | |
ssh_args = -C -o ControlMaster=auto -o ControlPersist=60s -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes |
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
controller ansible_connection=local | |
node1 ansible_ssh_host=172.17.177.21 ansible_ssh_private_key_file=/vagrant/.vagrant/machines/node1/virtualbox/private_key | |
node2 ansible_ssh_host=172.17.177.22 ansible_ssh_private_key_file=/vagrant/.vagrant/machines/node2/virtualbox/private_key | |
[nodes] | |
node[1: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
--- | |
- hosts: nodes | |
remote_user: vagrant | |
tasks: | |
- name: test connection | |
ping: | |
- debug: | |
var: inventory_hostname |
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.configure("2") do |config| | |
config.vm.box = "ubuntu/trusty64" | |
config.vm.define "node1" do |machine| | |
machine.vm.network "private_network", ip: "172.17.177.21" | |
machine.vm.provider "virtualbox" do |v| | |
v.name = "mynode1" | |
end | |
end | |
config.vm.define "node2" do |machine| | |
machine.vm.network "private_network", ip: "172.17.177.22" | |
machine.vm.provider "virtualbox" do |v| | |
v.name = "mynode2" | |
end | |
end | |
config.vm.define 'controller' do |machine| | |
machine.vm.network "private_network", ip: "172.17.177.11" | |
machine.vm.provider "virtualbox" do |v| | |
v.name = "mycontroller" | |
end | |
machine.vm.provision :ansible_local do |ansible| | |
ansible.playbook = "playbook.yml" | |
ansible.verbose = true | |
ansible.install = true | |
ansible.limit = "all" # or only "nodes" group, etc. | |
ansible.inventory_path = "inventory/vagrant" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment