Playground for ansible with macOS to try ansible commands and modules.
Install Ansible
brew install ansible
Step1. Install multipass
For macOS simply
brew install --cask multipass
Create ssh key
ssh-keygen -C vmuser -f multipass-ssh-key
Add your ssh public key multipass-ssh-key.pub
to cloud-init.yaml
multipass launch bionic -n vm1 --cloud-init cloud-init.yaml
Get instance IP address
multipass list
ssh connect to VM
ssh -i multipass-ssh-key vmuser@IP_ADDRESS
replace VM1_IP_ADDRESS in inventory with vm1 IP address
# PING the target node
ansible webserver -m ping
# Apt Update (use --become to get permission)
ansible webserver -m apt -a update_cache=true --become
# Run shell
ansible webserver -m shell -a "echo hello world"
# Run playbook
ansible-playbook playbook.yml
# Check nginx website
curl {{IP_ADDRESS}}
# Copy index.html to nginx (Modify anything in index.html)
ansible-playbook --tags copyweb playbook.yml