← Back to saltstack/salt

How to Deploy & Use saltstack/salt

SaltStack Deployment and Usage Guide

Prerequisites

  • Python 3.6+ (required for SaltStack)
  • Operating System: Linux (recommended), macOS, or Windows
  • Systemd: Required for service management on Linux systems
  • Network Access: Required for downloading dependencies and connecting to Salt master/minion
  • Administrative Privileges: Needed for installation and service management

Installation

From Source

  1. Clone the repository:
git clone https://github.com/saltstack/salt.git
cd salt
  1. Install dependencies:
python3 -m pip install -r requirements/base.txt
  1. Install Salt:
python3 setup.py install

Using Package Managers

Ubuntu/Debian:

sudo apt-get update
sudo apt-get install salt-master salt-minion

RHEL/CentOS:

sudo yum install salt-master salt-minion

macOS (using Homebrew):

brew install saltstack

Configuration

Master Configuration

Edit /etc/salt/master (or C:\salt\conf\master on Windows):

interface: 0.0.0.0
publish_port: 4505
ret_port: 4506
file_roots:
  base:
    - /srv/salt
pillar_roots:
  base:
    - /srv/pillar

Minion Configuration

Edit /etc/salt/minion (or C:\salt\conf\minion on Windows):

master: saltmaster.local
id: minion_id

Environment Variables

  • SALT_MASTER_HOST: Master server address (optional)
  • SALT_MINION_ID: Minion identifier (optional)
  • SALT_CONFIG_DIR: Custom configuration directory path (optional)

Build & Run

Development Environment

  1. Start Salt Master:
salt-master --log-level=info
  1. Start Salt Minion:
salt-minion --log-level=info
  1. Accept Minion Key:
salt-key -A
  1. Test Connection:
salt '*' test.ping

Production Environment

  1. Enable and start services:
# On Systemd systems
sudo systemctl enable salt-master
sudo systemctl start salt-master

sudo systemctl enable salt-minion
sudo systemctl start salt-minion
  1. Configure firewall rules:
# Allow Salt traffic
sudo ufw allow 4505
sudo ufw allow 4506

Deployment

Cloud Platforms

AWS EC2:

  • Use SaltStack's salt-cloud module for automated deployment
  • Configure AWS credentials in /etc/salt/cloud.providers.d/aws.conf

DigitalOcean:

  • Use salt-cloud with DigitalOcean driver
  • Configure API token in cloud provider configuration

Google Cloud:

  • Use salt-cloud with GCE driver
  • Configure service account credentials

Container Deployment

Docker:

docker run -d --name salt-master -p 4505:4505 -p 4506:4506 salt-master
docker run -d --name salt-minion salt-minion

Kubernetes:

  • Use Helm charts for SaltStack deployment
  • Configure StatefulSets for master and DaemonSets for minions

Troubleshooting

Common Issues

1. Minion fails to connect to master:

# Check connectivity
nc -zv saltmaster.local 4505
nc -zv saltmaster.local 4506

# Restart services
sudo systemctl restart salt-minion

2. Authentication errors:

# List pending keys
salt-key -L

# Accept specific key
salt-key -a minion_id

# Delete problematic key
salt-key -d minion_id

3. Module import errors:

# Check Python path
python3 -c "import sys; print(sys.path)"

# Verify dependencies
python3 -m pip list | grep -E "(salt|pyyaml|jinja2)"

4. Service management issues:

# Check systemd status
systemctl status salt-master
systemctl status salt-minion

# Check logs
journalctl -u salt-master
journalctl -u salt-minion

Debug Mode

Enable verbose logging:

salt-master -l debug
salt-minion -l debug

Network Issues

Check firewall rules:

# On Ubuntu/Debian
sudo ufw status

# On RHEL/CentOS
sudo iptables -L

Verify DNS resolution:

nslookup saltmaster.local