Without further ado, let's write our first state. All Salt-specific files that aren't Python files end in the extension
.sls. By default, the states are located in the
/srv/salt/ directory. We created this directory in the previous chapter, but if you didn't follow along there, make this directory now, as follows:
# mkdir -p /srv/salt # cd /srv/salt
Inside this directory, let's create a file named
apache.sls, as shown in the following line of code:
# vim apache.sls
Here are the contents of that file:
install_apache: pkg.installed: - name: apache2
State files are formatted using Yet Another Markup Language (YAML). The most common syntax errors in state files are forgetting the colons at the end of the first two lines, so watch out for that. More information about YAML can be found at http://www.yaml.org/. In addition, many simple YAML parsers can be found with a simple Google search. These can be very useful to detect simple syntax errors.
Let's run our state. To apply...