Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@sparsick
Last active January 19, 2021 23:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sparsick/ee5aa272b046e0ea77dd41ef08134893 to your computer and use it in GitHub Desktop.
Save sparsick/ee5aa272b046e0ea77dd41ef08134893 to your computer and use it in GitHub Desktop.
Ansible Local Testenvironment Setup for Windows based on Vagrant and Virtualbox
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
config.vm.define "managed-node" do |ubuntu|
ubuntu.vm.box = "bento/ubuntu-18.04"
ubuntu.vm.network "private_network", ip: "192.168.33.11"
ubuntu.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get install python -y
SHELL
end
config.vm.define "control-node" do |vbox|
vbox.vm.box = "bento/ubuntu-18.04"
vbox.vm.synced_folder ".", "/vagrant"
vbox.vm.provision "shell", inline: <<-SHELL
sudo apt-get update -y
sudo apt-get install -y software-properties-common
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update -y
sudo apt-get install -y ansible
SHELL
vbox.vm.provision "shell", privileged: false, inline: <<-SHELL
ssh-keygen -t rsa -q -f "/home/vagrant/.ssh/id_rsa" -N ""
ssh-keygen -R 192.168.33.11
ssh-keyscan -t rsa -H 192.168.33.11 >> /home/vagrant/.ssh/known_hosts
sshpass -p 'vagrant' ssh-copy-id -i /home/vagrant/.ssh/id_rsa.pub vagrant@192.168.33.11
SHELL
end
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
# vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
# vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment