IaC

Ansible Playground

Ansible is an agentless automation tool for configuration management, application deployment, and task orchestration using YAML playbooks..

Get access to the Ansible playground with one click

Welcome to the Ansible Playground!

Ansible — the agentless automation engine. Write YAML playbooks to configure systems, deploy apps, and orchestrate workflows without installing agents on targets.

What’s Pre-installed

  • Ansible (latest from Alpine apk)
  • Python 3 with pip
  • Shell: bash with vim, nano, git, curl, jq, openssh-client

Quick Start

ansible --version
ansible localhost -m ping -c local

Common Workflows

# Run an ad-hoc command
ansible localhost -m command -a "uname -a" -c local

# Write and run a playbook
cat > playbook.yml <<'EOF'
---
- hosts: localhost
  connection: local
  tasks:
    - name: Create a directory
      file:
        path: /tmp/ansible-demo
        state: directory
    - name: Write a file
      copy:
        content: "Hello from Ansible!"
        dest: /tmp/ansible-demo/hello.txt
    - name: Show the file
      command: cat /tmp/ansible-demo/hello.txt
      register: result
    - debug: msg="{{ result.stdout }}"
EOF

ansible-playbook -i localhost, -c local playbook.yml

Advanced Tips

# Use roles for reusability
ansible-galaxy init myrole
ls myrole/

# Dynamic inventory
ansible-inventory --list -i /etc/ansible/hosts

# Vault: encrypt sensitive data
ansible-vault encrypt_string 'mysecret' --name 'db_password'

# Check mode (dry run)
ansible-playbook -i localhost, -c local --check playbook.yml

Session Notes

  • Session lasts 1 hour.
  • Run against localhost with -c local to avoid needing SSH keys.