States are much easier to understand when you see them in action, so let’s make one. States are described using YAML, and are simple to create and read.
To demonstrate what a Salt State is capable of, we've put a state file called
nettools.sls in the
/srv/salt directory on our Salt Master that looks like:
install_network_packages: pkg.installed: - pkgs: - rsync - lftp - curl
This state ensures that the rsync, lftp, and curl packages are installed on whatever minion we'll be targeting.
You can take a look at this file on the Master by running
cat /srv/salt/nettools.sls. As you can see, this is just a simple text file that can easily be modified if necessary. However, to save you some typing, we're providing a pre-built one here.
That's it! That is all there is to creating a Salt state. Let's head to the next step where we'll apply it.