How to create a patch and ensure it is applied within Salt Stack

Tags
  • salt-stack
  • techniques

Quick tutorial on how to create a patch and ensure it is applied using salt stack.

Procedure

Creating a patch

  1. Create a copy of original file

    cp file file.orig

  2. Modify file, and test

  3. Create a md5 sum of the modified file for later use

    cat file | md5sum

  4. Revert modification, then prepare patch
    mv file file.mod
    cp file.orig file

  5. Create diff

    diff -Naur file file.mod > file.patch
    

Create Salt stack manifest block in appropriate state file

Add a block similar to this as a patch state definition. Make sure it is refered at least in your top.sls

    /usr/share/ganglia-webfrontend/auth.php:
      file.patch:
        - source: salt://monitor/auth.php.patch
        - hash: md5=480ef2ae17fdfee85585ab887fa1ae5f

References