O'Reilly logo

Salt Cookbook by Anirban Saha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Managing services

After packages and files, services are the entities to look out for in infrastructure management. For any system or application software, after the package is installed and the configuration files are modified, the next task is to make sure that the service is running and serves its purpose. In this recipe, you will learn how to manage services using Salt.

How to do it...

We will use the same minion and state directory as the previous recipe:

  1. Create and edit the /opt/salt-cookbook/staging/apache/service.sls file to have the following entries:
    {% if grains['lsb_distrib_id'] == "CentOS" %}
    httpd:
    {% elif grains['lsb_distrib_id'] == "Ubuntu" %}
    apache2:
    {% endif %}
      pkg:
        - installed
      service:
        - running
        - enable: True
        - reload: True
  2. Apply ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required