Skip to content

jcyh0120/ansible-playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible-playground

Playground for ansible with macOS to try ansible commands and modules.

Install Ansible brew install ansible

Ansible node with multipass

Step1. Install multipass

For macOS simply brew install --cask multipass

Step2. Prepare ssh key

Create ssh key

ssh-keygen -C vmuser -f multipass-ssh-key

Add your ssh public key multipass-ssh-key.pub to cloud-init.yaml

Step3. Create multipass instance

multipass launch bionic -n vm1 --cloud-init cloud-init.yaml

Step4. Check ssh connection

Get instance IP address

multipass list

ssh connect to VM

ssh -i multipass-ssh-key vmuser@IP_ADDRESS

Step5. Add to Ansible inventory

replace VM1_IP_ADDRESS in inventory with vm1 IP address

Ansible ad-HOC-command

# 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"

Ansible playbook

# 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

Reference

About

ansible playground with multipass vm for macOS

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages