added initial workstation to vagrantfile

This commit is contained in:
jon brookes 2025-08-06 08:40:16 +01:00
parent f39f98b319
commit b12749a3f0

View file

@ -6,6 +6,53 @@
# backwards compatibility). Please don't change it unless you know what # backwards compatibility). Please don't change it unless you know what
# you're doing. # you're doing.
Vagrant.configure("2") do |config| 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 # VM 1 Configuration
config.vm.define "vm1" do |vm1| config.vm.define "vm1" do |vm1|
vm1.vm.box = "ubuntu/jammy64" vm1.vm.box = "ubuntu/jammy64"