Hello guys. I’m new to vagrant. Tell me how to create a simple test environment from several servers?
Hey there,
you might find the getting started guide useful. It’ll take you through bringing up your first machine and show what kind of ways Vagrant can customize it.
Vagrant doesn’t provide a way to generate a Vagrantfile from already existing infrastructure. However, if you already have automation for provisioning your servers they should be able to be plugged into Vagrant pretty easily.
A minimal Vagrantfile might looks something like:
Vagrant.configure("2") do |config|
# Choose which box to use
config.vm.box = "hashicorp/bionic64"
# By default vagrant will sync the current directory to the guest. Disable it
config.vm.synced_folder ".", "/vagrant", disabled: true
# Run an ansible playbook against the machine
config.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook.yml"
end
end
You can use the vagrant cli to bring up this machine, that will be provisioned with ansible by running vagrant up
.
Hope this helps as a starting point! Happy to answer a more pointed question as well.
2 Likes
Thank you very much!!