Operating System Ubuntu

Getting Started With Salt (SaltStack) on Ubuntu 24.04 LTS

Set up a Salt master and a minion on Ubuntu 24.04 LTS from the Salt Project repository, verify the keys, then write and apply a first state with pillar data.

This guide sets up a Salt master and one minion, connects them securely, and walks through a first state (formula) and a first pillar. At the end you can run a command on every managed server from one place and describe a server's configuration in a file instead of typing it by hand.

The steps target Ubuntu 24.04 LTS. The Salt Project's list of supported operating systems covers Ubuntu 22.04 and 24.04 and Debian 11, 12 and 13; at the time of writing Ubuntu 26.04 LTS is not on that list, so use 24.04 (or Debian 13, where the same commands apply) until it is. Ubuntu 17.04 has been end-of-life since January 2018.

Requirements

  • Two servers running Ubuntu 24.04: one master and one minion. The examples use 203.0.113.10 for the master and 203.0.113.20 for the minion.
  • A user with sudo rights on both.
  • TCP ports 4505 and 4506 on the master reachable from the minions. Minions only make outbound connections, so they need no open ports.

Terms you will meet

  • Master: the server that sends commands and serves configuration files.
  • Minion: a managed server running the salt-minion agent.
  • State: a YAML file (.sls) describing how something should look, for example "this package is installed and this service is running". A collection of states for one piece of software is called a formula.
  • Pillar: data the master hands only to the minions it is meant for, such as host names, ports or secrets.
  • Grains: facts a minion reports about itself (OS, CPU, IP addresses).

Add the Salt repository (both servers)

Since Salt 3006 the project ships "onedir" packages that bundle their own Python, published from a repository hosted by Broadcom. Run these commands on the master and on every minion:

sudo apt update
sudo apt install -y curl gpg
sudo mkdir -m 755 -p /etc/apt/keyrings
curl -fsSL https://packages.broadcom.com/artifactory/api/security/keypair/SaltProjectKey/public | gpg --dearmor | sudo tee /etc/apt/keyrings/salt-archive-keyring.pgp > /dev/null
curl -fsSL https://github.com/saltstack/salt-install-guide/releases/latest/download/salt.sources | sudo tee /etc/apt/sources.list.d/salt.sources

The repository carries several major versions. Pin the 3008 LTS line, which the project recommends for production, so that a routine upgrade never jumps to another major release:

echo 'Package: salt-*
Pin: version 3008.*
Pin-Priority: 1001' | sudo tee /etc/apt/preferences.d/salt-pin-1001
sudo apt update

Keep the master and its minions on the same major version; when you upgrade, upgrade the master first.

Install and configure the master

sudo apt install -y salt-master

The master listens on ports 4505 and 4506 on all interfaces by default, so no configuration change is needed for a first setup. If you want it bound to one address, put the setting in a drop-in file rather than editing /etc/salt/master:

echo 'interface: 203.0.113.10' | sudo tee /etc/salt/master.d/network.conf

Enable and start the service:

sudo systemctl enable --now salt-master

If you use UFW, allow only your minions to reach the two ports:

sudo ufw allow from 203.0.113.20 to any port 4505,4506 proto tcp

Print the master's public key fingerprint. You need the master.pub value in the next step:

sudo salt-key -F master

Install and configure the minion

sudo apt install -y salt-minion

Tell the minion where its master is, give it a readable ID, and pin the master fingerprint so the minion refuses to talk to an impostor. Replace the fingerprint with the master.pub line you printed above:

echo 'master: 203.0.113.10' | sudo tee /etc/salt/minion.d/master.conf
echo 'id: web1' | sudo tee /etc/salt/minion.d/id.conf
echo "master_finger: 'aa:bb:cc:...'" | sudo tee /etc/salt/minion.d/finger.conf
sudo systemctl enable salt-minion
sudo systemctl restart salt-minion

A DNS name works in place of the IP address and makes it easier to move the master later. Without an id, the minion uses its host name.

Accept the minion key

On start the minion sends its public key to the master, which holds it until you accept it. On the master, list the keys:

sudo salt-key -L

web1 appears under Unaccepted Keys. Before accepting, compare fingerprints. On the minion:

sudo salt-call --local key.finger

On the master:

sudo salt-key --finger web1

If both match, accept the key:

sudo salt-key -a web1

salt-key -A accepts every pending key at once; only use it when you know exactly which machines are waiting. salt-key -d web1 removes a minion.

Verify and run commands

Ask every minion for its Salt version. A reply proves the connection works in both directions:

sudo salt '*' test.version

The first argument is the target, the second the function. A few more to try:

sudo salt 'web1' cmd.run 'uptime'
sudo salt 'web*' pkg.version openssh-server
sudo salt -G 'os:Ubuntu' grains.item osrelease

-G targets by grain, so the last command reaches every Ubuntu minion whatever its name.

Write your first state

States live under /srv/salt on the master. Create a small formula that installs Nginx and keeps it running:

sudo mkdir -p /srv/salt/nginx
sudo nano /srv/salt/nginx/init.sls
nginx:
  pkg.installed: []
  service.running:
    - enable: True
    - require:
      - pkg: nginx

Do a dry run first, then apply it:

sudo salt 'web1' state.apply nginx test=True
sudo salt 'web1' state.apply nginx

Salt reports each state as succeeded, changed or failed. Running it again changes nothing, because the server already matches the description.

To assign states to minions permanently, create /srv/salt/top.sls:

base:
  'web*':
    - nginx

After that, sudo salt '*' state.apply with no state name applies whatever the top file assigns to each minion.

Add pillar data

Pillar files live under /srv/pillar and use their own top file. Create both:

sudo mkdir -p /srv/pillar
sudo nano /srv/pillar/top.sls
base:
  'web1':
    - web
sudo nano /srv/pillar/web.sls
site:
  domain: example.com

Refresh and read it back:

sudo salt 'web1' saltutil.refresh_pillar
sudo salt 'web1' pillar.get site:domain

Inside a state or a managed template you read the same value with {{ pillar['site']['domain'] }}, which lets one formula serve many servers with different settings.

Maintenance

  • Salt upgrades arrive through apt within the pinned 3008 line. To move to a later major release, change the pin file and upgrade the master before the minions.
  • Logs are in /var/log/salt/master and /var/log/salt/minion. If a minion does not show up in salt-key -L, check its log and the firewall on the master.
  • Python libraries that your states or modules need must be installed into Salt's bundled Python with salt-pip, not the system pip.

The Salt install guide and the Salt user guide cover the next steps.

Frequently asked questions

Why not install salt-master from Ubuntu's own repository?

The Salt Project publishes and supports its own packages and documents that repository as the installation route. Its packages bundle the Python interpreter Salt was tested with, so a distribution Python upgrade cannot break Salt.

Can I manage a server without installing a minion?

Yes. The salt-ssh package runs states and commands over SSH with no agent on the target. It is slower than the minion transport and suits a handful of servers or machines where you cannot install software.

Is it safe to expose the master to the internet?

The Salt documentation treats an openly reachable master as a security risk. Restrict ports 4505 and 4506 to your minions' addresses, verify key fingerprints before accepting them, and leave auto_accept disabled.

Which Salt version should I run?

Use an LTS release for production. Salt 3008 is the current LTS line, released in May 2026; 3006 is the previous LTS and only receives security fixes until June 2027.

Share story:

Continue reading other guides on How VPS.