Ansible: Quick Start - 1
Get started with Ansible in under 1 minute — ideal for homelab setups and automation testing.
Install Ansible
# On RHEL
sudo dnf install -y ansible-core
# On macOS
brew install ansible
Run an Ansible Playbook
Example Remote Host
Field | Value |
---|---|
Username | neo |
Hostname | node2 |
IP | 192.168.50.205 |
OS | Fedora |
Password | <expected that you know> |
My playbook
tee ping.yaml > /dev/null <<EOL
---
- name: Test Connection Playbook
hosts: all
gather_facts: true
max_fail_percentage: 0
tasks:
- name: Ping hosts
ansible.builtin.ping:
EOL
Run the Playbook
# Run with `login password` prompt
ansible-playbook --ask-pass -u neo -i 192.168.50.205, ping.yaml
# Run with 'login password' & 'sudo password' prompt
ansible-playbook --ask-pass --ask-become-pass -u neo -i 192.168.50.205, ping.yaml
Try Ad-hoc Commands
Need to use all
# Ping remote node
ansible all -i 192.168.50.205, -u neo -m ping
# Run shell command
ansible all -i 192.168.50.205, -u neo -m shell -a "uptime"
Note the trailing comma
,
— this tells Ansible you’re passing a literal list of hosts, not an inventory file.
This gets you running fast with Ansible on macOS or RHEL. You can later scale by adding inventories, roles, and vaults.