Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Salt Cookbook
  • Table Of Contents Toc
  • Feedback & Rating feedback
Salt Cookbook

Salt Cookbook

By : Anirban Saha
3.5 (2)
close
close
Salt Cookbook

Salt Cookbook

3.5 (2)
By: Anirban Saha

Overview of this book

If you are a professional associated with system and infrastructure management, looking at automated infrastructure and deployments, then this book is for you. No prior experience of Salt is required.
Table of Contents (13 chapters)
close
close
12
Index

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 the state to the minion with the following command:

    [root@salt-master ~]# salt 'salt-minion' state.sls apache.service saltenv=staging --state-output=terse
    salt-minion:
      Name: apache2 - Function: pkg.installed - Result: Changed...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech

Create a Note

Modal Close icon
You need to login to use this feature.
notes
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY