Ansible unarchive module error: path does not exist

I was working on deploying files to a host via Ansible’s unarchive module when I ran into an error message:

path /tmp/datafiles/ does not exist

Here’s the relevant portion of my Ansible role’s task/main.yml:

- name: copy datafiles
  unarchive:
    src: datafiles.tar.gz
    dest: /tmp
    owner: root
    group: datauser

Here’s the full result of running that task:

TASK [datafiles : copy datafiles] *******************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "path /tmp/datafiles/ does not exist", "path": "/tmp/datafiles/", "state": "absent"}

The error message confused me. The datafiles directory shouldn’t need to exist!

The problem was completely unrelated to the error message. I had specified a group, datauser, that did not exist on the target host. Once I removed the group parameter, the task ran without error. (Another option would be to ensure that the specified group exists on the target host.)

One thought on “Ansible unarchive module error: path does not exist”

  1. Thank you! I had a bad group setting as well and was perplexed by the error output.

Leave a Reply

Your email address will not be published. Required fields are marked *