IaC

Saltstack Playground

SaltStack (Salt) is a fast, scalable infrastructure automation tool using Python-based state files for configuration management..

Get access to the Saltstack playground with one click

Welcome to the SaltStack Playground!

SaltStack (Salt) — the high-speed, Python-based infrastructure automation platform. Use masterless salt-call --local to apply states and manage configuration without a Salt Master.

What’s Pre-installed

  • Salt (latest stable via bootstrap script)
  • Shell: bash with vim, nano, git, curl, jq, python3, sudo

Quick Start

salt-call --local test.ping
salt-call --local grains.items | head -30
salt-call --local status.diskusage

Common Workflows

# Run modules (ad-hoc commands)
salt-call --local cmd.run "uname -a"
salt-call --local pkg.install vim
salt-call --local file.write /tmp/salt-demo.txt "Hello from Salt!"
salt-call --local file.read /tmp/salt-demo.txt

# Write and apply a state file
mkdir -p /srv/salt
cat > /srv/salt/demo.sls <<'EOF'
create_demo_file:
  file.managed:
    - name: /tmp/salt-state-demo.txt
    - contents: |
        Hello from Salt State!
    - mode: '0644'

show_demo_file:
  cmd.run:
    - name: cat /tmp/salt-state-demo.txt
    - require:
      - file: create_demo_file
EOF

sudo salt-call --local state.apply demo

Advanced Tips

# Grains (system facts)
salt-call --local grains.get os
salt-call --local grains.get ipv4

# Pillar (secure variables)
mkdir -p /srv/pillar
cat > /srv/pillar/top.sls <<'EOF'
base:
  '*':
    - common
EOF
cat > /srv/pillar/common.sls <<'EOF'
db_host: localhost
EOF
salt-call --local pillar.get db_host

# Apply highstate (all states)
salt-call --local state.highstate

Session Notes

  • Session lasts 1 hour.
  • Masterless mode — use salt-call --local for all commands.
  • Use sudo for commands that modify system files.