# -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| # You can search for the a linux flavor that suits your requirements. config.vm.box = "bento/ubuntu-22.04" # Folders to mount on the VM. The structure is "host", "guest" folders. config.vm.synced_folder "./", "/home/vagrant/src" config.vm.hostname = 'vagrant-demo' config.vm.provider "virtualbox" do |vb| # Resources that will be allocated for this VM. Choose wisely. vb.memory = "8192" vb.cpus = 2 # https://github.com/blinkreaction/boot2docker-vagrant/issues/13 vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] vb.customize ["modifyvm", :id, "--ioapic", "on"] end # Add here the host port you would like to use to access the VM through ssh. # Different VM's running at the same time should use different ports. config.vm.network :forwarded_port, guest: 22, host: 2224, id: "ssh" # Add here your own port mapping. config.vm.network "forwarded_port", guest: 9090, host: 9082 config.vm.provision "shell", inline: <<-SHELL # Installing required applications and dependencies. # Vagrant has some "providers" to facilitate the installation of some tools, # but it is alway better to have control over the version we are installing. # We install docker, terraform and aws cli apt-get update apt-get install -y\ ca-certificates \ curl \ gnupg \ lsb-release groupadd docker usermod -aG docker vagrant mkdir -p /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null apt-get update apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin apt-get update && apt-get install -y gnupg software-properties-common curl curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add - apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" apt-get update && apt-get install -y terraform apt-get install -y unzip curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip ./aws/install SHELL # We can run scripts to make configurations or install software and set ENV variables. # config.vm.provision "shell", path: "PATH/install_script_1.sh", # env: {"ENV1" => "0", # "ENV2" => "Somevalue", # } # config.vm.provision "shell", path: "PATH/install_script_2.sh"" end