iColor
iColor

Reputation: 270

Ansible fetch file from remote and keep on control node?

Let's say I have this compile role and it's last task fetches the compiled binaries from a build server.

- name: "fetch release tar"
  fetch:
    src: "{{ project_path }}/rel/{{ app_name }}/releases/{{ app_version }}/{{ app_name }}.tar.gz"
    dest: "~/releases/"
    flat: yes

Once this role completes, Ansible seems to clean up the release directory, presumably because these files are temporary? Is there a way fetch can make this permanent?

Upvotes: 1

Views: 720

Answers (1)

Bruce P
Bruce P

Reputation: 20749

Tilde expansion is handled by the login shell (bash, zsh, ksh, etc.). Ansible does not perform any tilde expansion on its own, so using one in the dest parameter as you have results in undefined behavior.

You should either hardcode a full path for your destination, or as an alternative you can make use of the expanduser filter that was added in Ansible 1.5 to perform this tilde expansion inside your playbook.

Upvotes: 1

Related Questions