Managing multiple systems in parallel with SaltStack
Managing Users
If you manage several systems but do not use a directory service, you still might want to manage users centrally. Unsurprisingly, Salt offers a module, pw_user
, that lets you add new users, delete user accounts, and modify individual attributes, such as the home directory [14]; you can even rename existing users. Listing 3 shows how you can create a new user with the user
, rather than the pw_user
, keyword. Before deleting a specific user, you could first list the users on all the systems.
Listing 3
Creating a New User
Note that Salt offers a module (ssh
) to manage the SSH service, so when creating users you can combine modules if you need to generate an SSH key for a new user (ssh-keygen -t rsa
) and roll it out to all the existing systems. The module's documentation [15] demonstrates how that works. If you want to do more than just monitor your systems (e.g., collect status information), take a look at the status
module [16]. Running status.all_status
returns all status data (a lot) for the minion specified. To access the hard disk data in a targeted way, use status.diskusage
, and to check the load status, use status.loadavg
.
If Salt does not offer a module for a functionality of interest, you can simply run shell commands on the systems by using the cmdmod
module [17], which takes the form cmd.<function>
. The cmd.run
pair takes a command you pass in between double or single quotes (Figure 5) and returns the output. Make sure you run the functions from this module with cmd
and not with cmdmod
.
More than Modules
In addition to modules, Salt offers a few commands that cover other functionality. The salt-cp
command, for example, copies data from the master to the minions (Listing 4, first line), allowing you to maintain /etc/hosts
, /etc/motd
, or other configuration files centrally. However, this command was only intended as an emergency solution. Generally, you will be able to manipulate existing files in the most targeted way with the file
module or use the management module for configuration files.
Listing 4
Other SaltStack Commands
The salt-run
command interacts with Salt; for example, it can be used to create a list of unreachable minions:
sudo salt-run manage.down
On Salt, every use of a module is dubbed a job, and salt-run
lets you generate a list of the last jobs (Listing 4, second line). If you would like to see the output of a certain Salt job again, specify the job ID (Listing 4, last line). For the individual commands, salt-run
makes use of its own modules, called "runners" [18].
Conclusions
SaltStack offers almost unlimited system management possibilities because of its large number of integrated modules. Even without the use of in-house configuration management, your computers will be very much under your command, regardless of whether you need to manage users, keep your systems up to date, or just get an overview of particular servers.
Even in heterogeneous networks with Windows machines, you can use Salt. Thanks to its built-in software administration, you can install standard programs like Firefox on Windows clients, and other functions from Linux are also available. Salt proves to be a versatile talent: It makes the use of many tools and DIY scripts redundant.
Infos
- SaltStack project: http://SaltStack.com/community/
- ZeroMQ: http://zeromq.org/
- Windows minions: https://docs.SaltStack.com/en/latest/topics/installation/windows.html
- Supported operating systems: https://docs.SaltStack.com/en/latest/topics/tutorials/salt_bootstrap.html#supported-operating-systems
- Opening ports for Salt: https://docs.SaltStack.com/en/latest/topics/tutorials/firewall.html
test
module: https://docs.SaltStack.com/en/latest/ref/modules/all/salt.modules.test.html- Targeting minions: https://docs.SaltStack.com/en/latest/topics/targeting/
- Defining grains: https://docs.SaltStack.com/en/latest/topics/targeting/grains.html
- Built-in Salt modules: https://docs.SaltStack.com/en/develop/ref/modules/all/index.html
- Writing your own modules: https://docs.SaltStack.com/en/latest/ref/modules/
pkg
module: https://docs.SaltStack.com/en/latest/ref/modules/all/salt.modules.pkg.html- Package module for Apt-based systems: https://docs.SaltStack.com/en/latest/ref/modules/all/salt.modules.aptpkg.html#module-salt.modules.aptpkg
file
module: https://docs.SaltStack.com/en/latest/ref/modules/all/salt.modules.file.html- User management with Salt: https://docs.SaltStack.com/en/latest/ref/modules/all/salt.modules.pw_user.html
- SSH commands: https://docs.SaltStack.com/en/latest/ref/modules/all/salt.modules.ssh.html
status
module: https://docs.SaltStack.com/en/latest/ref/modules/all/salt.modules.status.html- Shell commands with Salt: https://docs.SaltStack.com/en/develop/ref/modules/all/salt.modules.cmdmod.html
- Integrated runner modules: https://docs.SaltStack.com/en/latest/ref/runners/all/index.html
« Previous 1 2 3
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Gnome 48 Debuts New Audio Player
To date, the audio player found within the Gnome desktop has been meh at best, but with the upcoming release that all changes.
-
Plasma 6.3 Ready for Public Beta Testing
Plasma 6.3 will ship with KDE Gear 24.12.1 and KDE Frameworks 6.10, along with some new and exciting features.
-
Budgie 10.10 Scheduled for Q1 2025 with a Surprising Desktop Update
If Budgie is your desktop environment of choice, 2025 is going to be a great year for you.
-
Firefox 134 Offers Improvements for Linux Version
Fans of Linux and Firefox rejoice, as there's a new version available that includes some handy updates.
-
Serpent OS Arrives with a New Alpha Release
After months of silence, Ikey Doherty has released a new alpha for his Serpent OS.
-
HashiCorp Cofounder Unveils Ghostty, a Linux Terminal App
Ghostty is a new Linux terminal app that's fast, feature-rich, and offers a platform-native GUI while remaining cross-platform.
-
Fedora Asahi Remix 41 Available for Apple Silicon
If you have an Apple Silicon Mac and you're hoping to install Fedora, you're in luck because the latest release supports the M1 and M2 chips.
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.