Renoir Boulanger Un geek social et Linuxien de nature

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

When you need to adjust a file with a specific code modification and you are sure the file will not change over time, patch is a viable solution. This tutorial shows how to create a patch, sign it, and make sure it is applied.

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

Comments are closed.