archive.extracted: unbreak on OpenBSD

On OpenBSD, using tar in "legacy" mode, all option flags except for -C and -I
must be contained within the first argument to tar and must not be prefixed by a
hyphen. Since the state automatically adds '-f', we are not running in legacy
mode and as such, all options must be prefixed by a hyphen.

* before
[INFO    ] Executing command ['tar', 'xz', '-f', '/path/to/file.tgz'] in directory '/path/to/extractdir'
[ERROR   ] Command '['tar', 'xz', '-f', '/path/to/file.tgz']' failed with return code: 1
[ERROR   ] stderr: tar: Failed open to read on /dev/rst0: Device not configured
<snip>
Failed:    1

* after
[INFO    ] Executing command ['tar', '-xz', '-f', '/path/to/file.tgz'] in directory '/path/to/extractdir'
<snip>
Succeeded: 1 (changed=1)
This commit is contained in:
Antoine Jacoutot 2016-07-10 10:43:08 +02:00
parent cce6bfaec8
commit c43bd8fabe

View File

@ -455,6 +455,9 @@ def extracted(name,
append_opt = append_opt.replace('x', '').replace('f', '')
tar_shortopts = tar_shortopts + append_opt
if __grains__['os'] == 'OpenBSD':
tar_shortopts = '-' + tar_shortopts
tar_cmd.append(tar_shortopts)
tar_cmd.extend(tar_longopts)
tar_cmd.extend(['-f', filename])