VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "ubuntu/jammy64" config.vm.provider "virtualbox" do |v| v.memory = 1024 v.cpus = 2 end N = 3 (1..N).each do |machine_id| config.vm.define "web#{machine_id}" do |machine| machine.vm.hostname = "web#{machine_id}" machine.vm.network "forwarded_port", guest: 80, host: "808#{machine_id+1}" machine.vm.network "private_network", ip: "192.168.56.#{machine_id+1}" # Only execute once the Ansible provisioner, # when all the machines are up and ready. if machine_id == N machine.vm.provision :ansible do |ansible| # Disable default limit to connect to all the machines ansible.limit = "all" ansible.playbook = "ansible/playbook.yaml" ansible.vault_password_file = "vault_pass" end end end end end