Ansible get_url 如果目标文件不存在则失败

Ansible get_url Fails If Destination File Does Not Exist

使用get_url时,如果目标文件在本地不存在,则失败。如果我使用 vi 并创建其中没有任何内容的文件,则调用有效并且文件被替换。我添加了 force: yes 以鼓励它写出文件,但每次尝试都失败了,直到我创建了一个虚拟文件。

感谢任何帮助。

谢谢!

---
- 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 }}"

get_url模块在dest中采用绝对路径。 module's page 的一小段摘录。尝试像 /tmp./.

这样的绝对路径

| 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