-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible issue with archive.tar #7244
Comments
If you run the tests suite with your changes, you'll notice that is will not pass. Code similar to yours was already removed, see here. |
Here's a simple example why: >>> def foo(a, b, options=None, *args):
... print 'A', a
... print 'B', b
... print 'options', options
... print 'args', args
...
>>> foo(1, 2, 3)
A 1
B 2
options 3
args ()
>>> foo(1, 2, options=3)
A 1
B 2
options 3
args ()
>>> foo(1, 2, 4, options=3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: foo() got multiple values for keyword argument 'options'
>>> As a side-note, you should also avoid using the string module, there are some deprecated functions there, |
Also, have a look. root@pedro-ubuntu-test:~# ls -lah /tmp/tarfile.tar.gz
ls: cannot access /tmp/tarfile.tar.gz: No such file or directory There's no tar file yet. root@pedro-ubuntu-test:~# salt-call archive.tar czf /tmp/tarfile.tar.gz /etc
[INFO ] Package debconf-utils is not installed.
[INFO ] Executing command 'tar -czf /tmp/tarfile.tar.gz /etc' in directory '/root'
local:
- tar: Removing leading `/' from member names Does it exist? root@pedro-ubuntu-test:~# ls -lah /tmp/tarfile.tar.gz
-rw-r--r-- 1 root root 637K Sep 14 15:20 /tmp/tarfile.tar.gz Yep, it does. Let's see it's contents. root@pedro-ubuntu-test:~# tar -ztvf /tmp/tarfile.tar.gz
drwxr-xr-x root/root 0 2013-09-14 10:38 etc/
-rw-r--r-- root/root 267 2012-07-03 17:07 etc/legal
-rw-r--r-- root/root 880 2013-03-07 02:00 etc/hosts.deny
drwxr-xr-x root/root 0 2012-10-24 00:32 etc/lsb-base/
-rw-r--r-- root/root 73 2013-03-07 01:55 etc/shells
-rw-r--r-- root/root 45 2012-06-17 19:08 etc/bash_completion
drwxr-xr-x root/root 0 2013-09-08 10:33 etc/subversion/
-rw-r--r-- root/root 6692 2013-06-21 22:12 etc/subversion/config
-rw-r--r-- root/root 7679 2013-06-21 22:12 etc/subversion/servers
-rw-r--r-- root/root 887 2012-07-03 15:11 etc/rpc
-rw-r--r-- root/root 99 2013-04-19 08:47 etc/lsb-release
drwxr-xr-x root/root 0 2013-07-12 21:09 etc/rc3.d/
lrwxrwxrwx root/root 0 2013-07-12 21:09 etc/rc3.d/S20nova-agent -> ../init.d/nova-agent
lrwxrwxrwx root/root 0 2013-03-07 01:55 etc/rc3.d/S99rc.local -> ../init.d/rc.local
-rw-r--r-- root/root 677 2013-01-30 12:58 etc/rc3.d/README
lrwxrwxrwx root/root 0 2013-03-07 02:00 etc/rc3.d/S70dns-clean -> ../init.d/dns-clean
lrwxrwxrwx root/root 0 2013-07-12 21:07 etc/rc3.d/S14xe-linux-distribution -> ../init.d/xe-linux-distribution
lrwxrwxrwx root/root 0 2013-03-07 01:55 etc/rc3.d/S75sudo -> ../init.d/sudo
lrwxrwxrwx root/root 0 2013-03-07 01:55 etc/rc3.d/S99ondemand -> ../init.d/ondemand
lrwxrwxrwx root/root 0 2013-03-07 02:00 etc/rc3.d/S50rsync -> ../init.d/rsync
lrwxrwxrwx root/root 0 2013-03-07 02:00 etc/rc3.d/S70pppd-dns -> ../init.d/pppd-dns
lrwxrwxrwx root/root 0 2013-03-07 02:01 etc/rc3.d/S99grub-common -> ../init.d/grub-common
lrwxrwxrwx root/root 0 2013-03-07 01:55 etc/resolv.conf.1378629434.bak~ -> ../run/resolvconf/resolv.conf
-rw-r--r-- root/root 346 2012-05-01 02:08 etc/discover-modprobe.conf
-rw-r--r-- root/root 92 2012-10-28 03:43 etc/host.conf
------------------------- removed for simplicity -------------------------
lrwxrwxrwx root/root 0 2013-09-08 08:43 etc/alternatives/java.1.gz -> /usr/lib/jvm/java-7-openjdk-amd64/jre/man/man1/java.1.gz
lrwxrwxrwx root/root 0 2013-09-08 08:40 etc/alternatives/fakeroot.fr.1.gz -> /usr/share/man/fr/man1/fakeroot-sysv.1.gz
lrwxrwxrwx root/root 0 2013-03-07 01:57 etc/alternatives/rename.1.gz -> /usr/share/man/man1/prename.1.gz
lrwxrwxrwx root/root 0 2013-03-07 02:00 etc/alternatives/editor.1.gz -> /usr/share/man/man1/nano.1.gz
lrwxrwxrwx root/root 0 2013-03-07 02:00 etc/alternatives/telnet.1.gz -> /usr/share/man/man1/telnet.netkit.1.gz
lrwxrwxrwx root/root 0 2013-09-08 08:43 etc/alternatives/servertool.1.gz -> /usr/lib/jvm/java-7-openjdk-amd64/jre/man/man1/servertool.1.gz
lrwxrwxrwx root/root 0 2013-09-08 08:40 etc/alternatives/cpp -> /usr/bin/cpp It worked... root@pedro-ubuntu-test:~# tar --version
tar (GNU tar) 1.26
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by John Gilmore and Jay Fenlason. What is your distro? |
distro info:CentOS release 6.4 (Final) kernel info:Linux client 2.6.32-358.14.1.el6.x86_64 #1 SMP Tue Jul 16 23:51:20 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux tar info: salt info: so,when i run "salt 'client' archive.tar czf /tmp/tarfile.tar.gz /etc", and i edited “/usr/lib/python2.6/site-packages/salt/modules/archive.py” of 'client' minion, like this: master run result: minion output: so sourcefiles=null,and cwd='/etc'? why? |
Please try to use more descriptive issue names. I have edited the name of this post to better reflect its details. |
@terminalmage OK,thx. |
UP~ |
Sorry, I don't understand what you're trying to say. |
Looking at https://github.com/saltstack/salt/blob/v0.16.0/salt/modules/archive.py#L19, there are two positional arguments ( As it was already explained by @s0undt3ch, in the develop branch this function has been changed. This fix will be in 0.17.0. Testing from the latest code in the develop branch, the command you used works. As this has been fixed, I am closing this. |
OK,thx |
archive.tar cannot be used to untar a file in its current form as it requires 'sources' which is not required in untar. Am I missing something here? |
@mahul you're missing archive.untar. 😄 |
Heh, stupid of me.... forget that @mahul |
Properly support decompressing `tar` files. Refs #7244.
@mahul The 0.17.1 version of salt will include the fix which allows you to properly decompress tar files. Thanks for your report. |
@s0undt3ch - thanks very much! |
Anytime! |
when i run "salt 'clent' archive.tar czf /home/tarfile.tar.gz /etc"
return this message:
clent:
- tar: Cowardly refusing to create an empty archive
- Try
tar --help' or
tar --usage' for more information.I edited “/usr/lib/python2.6/site-packages/salt/modules/archive.py” file.it is OK now.
- def tar(options, tarfile, cwd=None, template=None, *sources):
+ import string
and zip function also have the same problem.
The text was updated successfully, but these errors were encountered: