Creating Reusable State Files
Andrew Mallett · Apress eBooks · 2021
So far, we have seen that Salt has been pretty easy to use, the underlying Python subsystems helping us differentiate the various needs of the underlying OS. However, we have chosen carefully to install packages with matching names on both Ubuntu and Red Hat–based systems, like CentOS Stream. We will have encountered more problems ensuring that the Vim text editor was installed. The package to install is simply vim on Debian-based systems and vim-enhanced on Red Hat–based systems. This extends into many services too; if we want to install the Apache web server, we need the packages apache2 on Debian and httpd on Red Hat. The service names also differ on each system. For simplicity, we have avoided these issues, but it is time to face these problems head-on and see how using templating languages like Jinja can help to resolve the issues. We will also learn how we can use other renderers and discover that we can write our State files in Python directly.