Skip to content

Instantly share code, notes, and snippets.

@lorengordon
Last active November 10, 2015 21:34
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 lorengordon/88e0fc8ee8f9fe312b2f to your computer and use it in GitHub Desktop.
Save lorengordon/88e0fc8ee8f9fe312b2f to your computer and use it in GitHub Desktop.
Salt state to extract zip archive on Windows
{%- load_yaml as myarchive %}
name: 'C:\minionpath\to\save\my\archive.zip'
source: 'path/from/the/salt/master/to/my/archive.zip'
source_hash: 'hash_of_source_archive'
extract_dir: 'C:\minionpath\to\extract\my\archive.zip\'
{%- endload %}
# Get the zip archive
GetZipArchive:
file.managed:
- name: {{ myarchive.name }}
- source: {{ myarchive.source }}
- source_hash: {{ myarchive.source_hash }}
- makedirs: True
# Clean the extract directory
ExtractDirectory:
file.directory:
- name: {{ myarchive.extract_dir }}
- clean: True
- onchanges:
- file: GetZipArchive
# Extract the zip archive
ExtractArchiveContent:
cmd.run:
- name: '
new-object -com shell.application | % {
$_.namespace("{{ myarchive.extract_dir }}").copyhere($_.namespace("{{ myarchive.name }}").items(), 0x14)
}'
- shell: powershell
- require:
- file: ExtractDirectory
- onchanges:
- file: GetZipArchive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment