Skip to content

Instantly share code, notes, and snippets.

@michaelkrupp
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelkrupp/4d65c10be2bef1a22b3b to your computer and use it in GitHub Desktop.
Save michaelkrupp/4d65c10be2bef1a22b3b to your computer and use it in GitHub Desktop.
patching salt via salt
<%
from distutils.version import StrictVersion
saltversion = StrictVersion(grains.get('saltversion', 'UNKNOWN_VERSION'))
saltversion_min = StrictVersion(pillar.get('bootstrap.salt.min_version'))
saltpatches = pillar.get('bootstrap.salt.patches', { })
%>
Make sure we're not running an outdated version
% if saltversion < saltversion_min:
'Abort if running old salt release version':
test.fail_without_changes:
- name: "Salt versions before '${saltversion_min}' are not supported"
# Apply patches when neccessary
% elif saltversion in saltpatches.keys():
<%
saltpath = grains.get('saltpath')
patchdir = "${saltpath}/.patches/"
%>
'Create salt patch cache directory':
file.directory:
- name: "${patchdir}"
- makedirs: true
- mode: 700
% for patch in saltpatches[saltversion]:
% for commit_id, patch_sha in patch.iteritems():
<% patch_file = "${patchdir}/${commit_id}.patch" %>
"Download salt patch ${commit_id}":
file.managed:
- name: "${patch_file}"
- mode: 400
- source: "https://github.com/saltstack/salt/commit/${commit_id}.patch"
- source_hash: "sha1=${patch_sha}"
- require:
- file: "${patchdir}"
"Apply salt patch ${commit_id}":
cmd.run:
- name: patch -s -p2 -r - -i "${patch_file}" -N
- cwd: "${saltpath}"
- require:
- file: "${patch_file}"
- unless: patch -s -p2 -r - -i "${patch_file}" -R -f --dry-run
% endfor
% endfor
% endif
config:
min_version: '2014.1.0'
# bootstrap.salt
# patches:
# [salt_version]:
# - [github_commit_id]: [md5-checksum]
#
patches:
'2014.1.0':
- 881f2a1a242c8cf4f1f384d9985d9d12c544e605: 1d0749a7352f83826f9cbffe6dec0fcb
- b3320f9fe4a0016e3b02fc3b676e5c46e0d918e5: 82c574c06f9c9612b3ce3fa2fa123b26
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment