Last active
November 10, 2015 21:34
-
-
Save lorengordon/88e0fc8ee8f9fe312b2f to your computer and use it in GitHub Desktop.
Salt state to extract zip archive on Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{%- 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