Skip to content

Ansible: unpack a file on the remote host - Ansible version 2.2

A while ago I posted about a nasty problem in the Ansible "unarchive" module: in version 2.0.x, if you do not specify "copy=no", Ansible will happily copy the file again from the Ansible host.

Turns out, that problem was fixed in version 2.2, but now the Playbook runs into an error:

fatal: [xxx]: FAILED! => {"changed": false, "failed": true, "msg": "parameters are mutually exclusive: ('copy', 'remote_src')"}

Even if "copy" is set to "no", Ansible no longer accepts both parameters.

 

Ok, let's make Ansible happy, double the lines and add where conditions:

For older Ansible versions:

- name: unzip test archive (Ansible < 2.2)
  unarchive: src=/tmp/test.zip dest=/tmp/test-tmp-install remote_src=yes copy=no
  when: ansible_version.full | version_compare('2.2.0.0', operator='<', strict=False)

 

And for newer versions:

- name: unzip test archive (Ansible >= 2.2)
  unarchive: src=/tmp/test.zip dest=/tmp/test-tmp-install remote_src=yes copy=no
  when: ansible_version.full | version_compare('2.2.0.0', operator='>=', strict=False)

 

Trackbacks

ads' corner on : Ansible: unpack a file on the remote host

Show preview
Trying to unpack a file on the remote host using Ansible might end in an error message: fatal: [192.168.0.188]: FAILED! =&gt; {&quot;failed&quot;: true, &quot;msg&quot;: &quot;ERROR! file or module does not exist: /tmp/test.zip&quot;} I'm using Ansible 2.0.0.2 here, and h Comments ()

Comments

Display comments as Linear | Threaded

No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.
Form options