From b12749a3f01fcd5762be7ae6eb64a6f5f49c7e76 Mon Sep 17 00:00:00 2001 From: jon brookes Date: Wed, 6 Aug 2025 08:40:16 +0100 Subject: [PATCH] added initial workstation to vagrantfile --- vagrant/dev/ubuntu/Vagrantfile | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/vagrant/dev/ubuntu/Vagrantfile b/vagrant/dev/ubuntu/Vagrantfile index d2e882c..76a89ee 100644 --- a/vagrant/dev/ubuntu/Vagrantfile +++ b/vagrant/dev/ubuntu/Vagrantfile @@ -6,6 +6,53 @@ # backwards compatibility). Please don't change it unless you know what # you're doing. Vagrant.configure("2") do |config| + + config.vbguest.auto_update = false + + + # Ansible Controller/Workstation Configuration + config.vm.define "workstation" do |ws| + ws.vm.box = "ubuntu/jammy64" + ws.vm.hostname = "ansible-workstation" + ws.vm.synced_folder ".", "/vagrant" + + # Fixed private network IP + ws.vm.network "private_network", ip: "192.168.56.10" + + ws.vm.provider "virtualbox" do |vb| + vb.memory = "1024" # Less memory needed for control node + vb.cpus = 1 + end + + ws.vm.provision "shell", inline: <<-SHELL + sudo apt-get update + sudo apt-get install -y software-properties-common + sudo apt-add-repository --yes --update ppa:ansible/ansible + sudo apt-get install -y ansible git vim + + # Set up ansible environment for vagrant user + sudo -u vagrant mkdir -p /home/vagrant/.ansible + sudo -u vagrant touch /home/vagrant/.ansible/ansible.cfg + + # Create workspace and SSH directories + sudo -u vagrant mkdir -p /home/vagrant/ansible + sudo -u vagrant mkdir -p /home/vagrant/.ssh + sudo chmod 700 /home/vagrant/.ssh + + # Copy the Vagrant private keys (these will be synced by Vagrant) + for i in {1..3}; do + sudo -u vagrant cp /vagrant/.vagrant/machines/vm$i/virtualbox/private_key /home/vagrant/.ssh/vm${i}_key + sudo chmod 600 /home/vagrant/.ssh/vm${i}_key + done + + + + # Disable host key checking for easier learning + echo "[defaults]" > /home/vagrant/.ansible/ansible.cfg + echo "host_key_checking = False" >> /home/vagrant/.ansible/ansible.cfg + SHELL + end + # VM 1 Configuration config.vm.define "vm1" do |vm1| vm1.vm.box = "ubuntu/jammy64"