Hello,
I am new to trying to use Ansible via Vagrant and allot of issues trying to install Ansible, the following wored, but just want a Sanity check to see if i am following the right process. I prefer to do everything inside the VM… Using VMware Workstation,
# -*- mode: ruby -*-
# vi: set ft=ruby :code
Vagrant.configure("2") do |config|
# Use a VMware-compatible box
config.vm.box = "bento/ubuntu-20.04" # This is a VMware-compatible box
config.vm.network "private_network", type: "dhcp"
config.vm.synced_folder ".", "/vagrant", create: true
config.vm.define "ansibledemo"
config.vm.hostname = "ansibledemo"
# Specify the VMware provider
config.vm.provider "vmware_workstation" do |v|
# v.gui = true # Enable GUI if needed
v.memory = 2048 # Allocate 2GB of RAM
v.cpus = 2 # Allocate 2 CPUs
end
# Install Ansible on the guest machine
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y software-properties-common
apt-add-repository --yes --update ppa:ansible/ansible
apt-get install -y ansible
echo "The IP address of this machine is: $(hostname -I)"
echo "Python version is: $(python3 --version)"
echo "Pip version is: $(pip3 --version)"
echo "Ansible version is: $(ansible --version)"
SHELL
# Run the first_playbook.yml playbook
config.vm.provision "ansible_local" do |ansible|
ansible.playbook = "first_playbook.yml"
end
end
type or paste code here
type or paste code here