Last active
February 24, 2020 17:01
-
-
Save Stephanevg/8e5ab68de93842fea13c64ed84570d4c to your computer and use it in GitHub Desktop.
vagrant file to provision an Ansible server with a windows client (server)
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.provision "shell", inline: "echo Hello" | |
config.vm.define "ansiblesrv" do |ansiblesrv| | |
ansiblesrv.vm.box = "centos/7" | |
ansiblesrv.vm.provision "shell", inline: <<-SHELL | |
sudo yum update | |
sudo yum install ansible -y | |
sudo yum install epel-release -y | |
sudo yum install python-pip -y | |
sudo pip install --upgrade pip | |
sudo pip install pywinrm | |
sudo yum install ansible -y | |
echo "**" | |
curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo | |
sudo yum install powershell -y | |
echo "********** Vagrant configuration done! Displaying versions *********" | |
python --version | |
ansible --version | |
pip --version | |
pip list | grep pywinrm | |
echo "********** You can now start to use ansible :) *********" | |
SHELL | |
ansiblesrv.vm.hostname = "ansible-server" | |
ansiblesrv.vm.network :private_network, ip: "10.0.0.10" | |
end | |
config.vm.define "winsrv" do |winsrv| | |
winsrv.vm.box = "gusztavvargadr/windows-server" | |
winsrv.vm.box_version = "1809.0.1912-standard" | |
winsrv.vm.communicator = "winrm" | |
winsrv.vm.guest = :windows | |
winsrv.vm.hostname = "win-srv" | |
winsrv.vm.network :private_network, ip: "10.0.0.11" | |
winsrv.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true, host_ip: "127.0.0.1" | |
winsrv.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true, host_ip: "127.0.0.1" | |
winsrv.vm.network :forwarded_port, guest: 22, host: 2222, id: "ssh", auto_correct: true, host_ip: "127.0.0.1" | |
winsrv.winrm.username = "vagrant" | |
winsrv.winrm.password = "vagrant" | |
winsrv.vm.provider :virtualbox do |vbox, override| | |
override.vm.network :private_network, ip: "10.10.13.14" | |
vbox.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] | |
vbox.gui = true | |
vbox.customize ["modifyvm", :id, "--vram", 32] | |
vbox.customize ["modifyvm", :id, "--memory", "1024"] | |
vbox.customize ["modifyvm", :id, "--audio", "none"] | |
vbox.customize ["modifyvm", :id, "--clipboard", "bidirectional"] | |
vbox.customize ["modifyvm", :id, "--draganddrop", "hosttoguest"] | |
vbox.customize ["modifyvm", :id, "--usb", "off"] | |
# linked clones for speed and size | |
vbox.linked_clone = true if Vagrant::VERSION >= '1.8.0' | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment