Last active
November 7, 2024 13:12
-
-
Save sparsick/ee5aa272b046e0ea77dd41ef08134893 to your computer and use it in GitHub Desktop.
Ansible Local Testenvironment Setup for Windows based on Vagrant and Virtualbox
This file contains 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
# -*- 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 [email protected] | |
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