Book Image

Salt Cookbook

By : Anirban Saha
Book Image

Salt Cookbook

By: Anirban Saha

Overview of this book

Table of Contents (18 chapters)
Salt Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Managing files


One of the very basic and important tasks in infrastructure management is to manage files. In this recipe, you will learn how to manage files and its variants such as directories and symlinks using Salt.

How to do it...

  1. Configure a minion called salt-minion. Create a new state directory called apache.

  2. In the apache directory, create the following directory structure:

    [root@salt-master ~]# mkdir –p /opt/salt- cookbook/staging/apache/files/apache_root/{produxts,services,b log,about}
    

    Also create an /opt/salt-cookbook/staging/apache/files/index.html file with some test HTML content in it.

  3. Create and edit /opt/salt-cookbook/staging/apache/init.sls to have the following contents:

    httpd_source:
      file.managed:
        - name: /opt/httpd-2.4.10.tar.gz
        - source: http://mirror.nus.edu.sg/apache//httpd/httpd- 2.4.10.tar.gz
        - source_hash: http://www.apache.org/dist/httpd/httpd- 2.4.10.tar.gz.md5
    
    extract_httpd_source:
      archive:
        - extracted
        - name: /opt/
        - source: /opt/httpd...