0

When using get_url, it fails if the destination file does not exist locally. If I us vi and create the file with nothing in it, then the call works and the file is replaced. I added force: yes to encourage it to write out the file, but every attempt failed until I created a dummy file.

Any help is appreciated.

Thank you!

---
- name: Download HashiCorp Installation Archive File
  hosts: 127.0.0.1

  vars:
    vault:
      distro:  'linux'
      version: '1.5.4'
    user:
      group: 'rcouch'
      name:  'rcouch'
  
  tasks:

    # https://releases.hashicorp.com/vault/1.5.4/vault_1.5.4_linux_amd64.zip
    - name: Download Binary
      get_url:
        url:      "https://releases.hashicorp.com/vault/{{ vault.version }}/vault_{{ vault.version }}_{{ vault.distro }}_amd64.zip"
        checksum: "sha256:https://releases.hashicorp.com/vault/{{ vault.version }}/vault_{{ vault.version }}_SHA256SUMS"
        force:    yes
        dest:     "vault_{{ vault.version }}_{{ vault.distro }}_amd64.zip"
        owner:    "{{ user.group }}"
        group:    "{{ user.name }}"
        mode:     0755
      register: vault_download
  
    - name: Display Vault Download
      debug:
        msg:
        - "vault_download: {{ vault_download }}"

1 Answers1

3

The get_url module takes an absolute path in dest. A small excerpt from the module's page. Try an absolute path like /tmp or ./.

| dest | Absolute path of where to download the file to. |

  tasks:
  - get_url:
      url: https://releases.hashicorp.com/vault/1.5.4/vault_1.5.4_linux_amd64.zip
      dest: ./vault_1.5.4_linux_amd64.zip
seshadri_c
  • 6,906
  • 2
  • 10
  • 24
  • 1
    seshadri_c, Thank you! That was exactly it. I need to slow down while I "RTFM"! The absolute path worked perfectly. Thank you, Rob – IT Serenity Oct 22 '20 at 14:34