Skip to content
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

Unarchive should support unpacking remote archives #6131

Closed
Bilge opened this issue Feb 23, 2014 · 24 comments
Closed

Unarchive should support unpacking remote archives #6131

Bilge opened this issue Feb 23, 2014 · 24 comments
Labels
feature This issue/PR relates to a feature request. m:unarchive This issue/PR relates to the unarchive module.

Comments

@Bilge
Copy link

Bilge commented Feb 23, 2014

If I wish to download an archive on the remote host using get_url then the unarchive module is unable to help me extract it since unarchive only extracts local archives. In its current implementation, the only way to achieve this is:

  • get_url the file on the remote host
  • fetch it back to the local host
  • unarchive it back to the remote host

This is incredibly wasteful and nigh on ridiculous. Unarchive should be able to extract remote archives.

@ansibot
Copy link
Contributor

ansibot commented Feb 23, 2014

Thanks for filing a ticket! I am the friendly GitHub Ansibot. I see you did not fill out your issue description based on our new issue template. Please copy the contents of this template and paste it into the description of your ticket.

Our system will automatically close tickets that do not have an issue template filled out within 7 days. Please note that due to large interest in Ansible, humans may not comment on your ticket if you ask them questions. Don't worry, you're still in the queue and the robots are looking after you.

@mpdehaan
Copy link
Contributor

First request -- Please don't call contributors contributions ridiculous -- I'm very thankful for unarchive, and it's true it could do more. However, because a personal itch hasn't been scratched doesn't mean there isn't a lot of value in a new module, and I'm thankful for it.

This feature idea is also slightly based on an assumption that the unarchive module must be handled in three step process. It's two. Download to the local host, push it to the remote. This requires an extra line or two,

  • get_url: http://foo dest=/path/to/file.tgz
  • unarchive: src=/path/to/file.tgz ...

Which is a little longer than normal, but it's not any more wasteful on bandwidth. It wastes an additional line in the playbook, but that's all.

@Bilge
Copy link
Author

Bilge commented Feb 23, 2014

get_url does not download to the local host, it downloads to the remote host, nor do I want to download to the local host so your steps would not be functionally equivalent even if it did work that way. Which it doesn't.

@mpdehaan
Copy link
Contributor

The get_url module will download to any host you run the play on, actually. You can do that in a local play, or use "delegate_to/local_action".

The play is a better approach.

@Bilge
Copy link
Author

Bilge commented Feb 23, 2014

I don't know what you're talking about but I thought I made it clear I don't want to download to the local host. The problem is that get_url works on the remote side and unarchive works on the local side. Therefore they cannot be used together directly.

@mpdehaan
Copy link
Contributor

Not directly, but they can in fact be used in conjunction.

- hosts: localhost
  tasks:
     - get_url: ...

- hosts: managed
  tasks:
      - unarchive: ...

@mpdehaan
Copy link
Contributor

If you don't need to download to the control machine, this is just two tasks in the same play

  tasks:
      - get-url: ...
      - unarchive: ...

There would be no fetch in either case.

@Bilge
Copy link
Author

Bilge commented Feb 23, 2014

get_url will always download to the remote machine because it only takes remote paths.
unarchive will always extract from a file on the local machine because it only operates on local paths.

To be clear, you can name remote and local anything you like. Master/slave, control/minion. Whatever you call it, these two modules cannot operate on the same file back to back.

Try testing your play. It doesn't make sense.

Also, aren't you like the main guy behind Ansible? If so I should just retire to SaltStack. Hatch never behaves like this when people try to offer useful suggestions on his tracker.

@mpdehaan
Copy link
Contributor

There's no argument going on here that I can tell, the ticket is still open and I'm trying to show you how to work around the problem without "fetch" above.

It's evident I did make an error in my last post, switch "unarchive" to "shell: tar -xvf creates=some/path" and you'd have the same result.

As I'm not liking where this thread is going we will be retiring this discussion however, please feel free to adopt another tool if you wish.

@Bilge
Copy link
Author

Bilge commented Feb 23, 2014

Wow.

@martinalig
Copy link

Any chances to see this opened again? I think its quite confusing that unarchive does not work remotely...

@GonzaloAlvarez
Copy link

+1 to reopen this again. I also believe it is quite confusing that unarchive works only with local files. Also, I think it is not a good practice to encourage playbook devs to have the tar files within the local dir, because you usually have your playbooks tracked with a version system tool (such as git) and it is not nice to have big binary files within.

@yauh
Copy link

yauh commented May 6, 2014

I am also in favor of having another attribute like localfile=true|false or source=local|remote to make this issue easily solvable. I spend quite a while figuring out why I couldn't perform a simple unarchive action until I read the docs more closely. It may become much more obvious with a simple switch to tell where the source is located.

@bcoca
Copy link
Member

bcoca commented May 6, 2014

from unarchive's docs, just set copy=false

Brian Coca
Stultorum infinitus est numerus
0110000101110010011001010110111000100111011101000010000001111001011011110111010100100000011100110110110101100001011100100111010000100001
Pedo mellon a minno

@yauh
Copy link

yauh commented May 6, 2014

@bcoca indeed this works fine for me.I guess I thought that either the archive is copied and then extracted or extracted over ssh onto the remote machine, depending on the setting. But it never occurred to me, that copy=false would actually look for a remote file instead of a local one.

So basically the functionality is there and the issue is solved for me :-)

@Bilge
Copy link
Author

Bilge commented May 6, 2014

It didn't occur to anyone else in this thread, either. The issue is not solved until the docs are rewritten to be clearer on this functionality.

@GonzaloAlvarez
Copy link

I tested it and it worked! :)
Anyhow, I agree the issue should be reopened until docs are updated...

@bcoca
Copy link
Member

bcoca commented May 6, 2014

I'm getting 404 on pull request attempts in github, but here is my proposed
change

bcoca@413a50f

@hoggle64
Copy link

hoggle64 commented Jun 5, 2014

It's still unclear to me - sorry:

I get this error:
src (or content) and dest are required

when I do this:
unarchive: copy=no src={{ item.key }}

I've also tried this with the same result:
unarchive: copy=no dest={{ item.key }}

So - how can I extract a file on the target system without transfering it first ?

Thanks clarification.

@bcoca
Copy link
Member

bcoca commented Jun 5, 2014

you need BOTH src and dest, i imagine you wan the following:

unarchive: copy=no src={{ item.key }} dest=/whererever/you/wantto/unarchive

Brian Coca
Stultorum infinitus est numerus
0110000101110010011001010110111000100111011101000010000001111001011011110111010100100000011100110110110101100001011100100111010000100001
Pedo mellon a minno

@hoggle64
Copy link

hoggle64 commented Jun 5, 2014

you're right.
src does not mean from the ansible machine.

That was a little confusing....

Thank you.

@ghost
Copy link

ghost commented Jul 10, 2014

Thanks for clarifying and providing this example, very helpful.

@xiaokli-in
Copy link

I tried to unarchive a zip, and assign the unziped file to user.

  • name: unzip file

    unarchive: src=/root/xxx.zip dest=/xxx/xx/ copy=no owner=someone group=somegroup

    sudo=yes

the assign of user did not work.

can anyboy help ?

@Atchuu
Copy link

Atchuu commented Jan 16, 2015

If anyone wants to skip this thread... here's the cliff notes.

OP asks
@mpdehaan responds with reasonable response, not fully understanding the request
OP insults @mpdehaan
repeat 27,000 times....
@mpdehaan closes issue.
community clarifies that the "copy" parameter satisfies this request.

To @mpdehaan and the community, thank you for saving me time. To OP, sorry your days suck so much...

@ansible ansible locked and limited conversation to collaborators Jan 16, 2015
@dagwieers dagwieers added the m:unarchive This issue/PR relates to the unarchive module. label Sep 27, 2017
@ansibot ansibot added the feature This issue/PR relates to a feature request. label Mar 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature This issue/PR relates to a feature request. m:unarchive This issue/PR relates to the unarchive module.
Projects
None yet
Development

No branches or pull requests