get_url makes downloaded file size 0 on second run

get_url zero’s the file on second run.

  • I run a playbook which downloads and runs a command file.
  • get_url works perfectly 1st time
  • I run the same playbook a second time and the downloaded file now has 0 size

ansible version info:
ansible [core 2.14.18] config file = /root/ansible.cfg configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python3.9/site-packages/ansible ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections executable location = /usr/bin/ansible python version = 3.9.21 (main, Jun 27 2025, 00:00:00) [GCC 11.5.0 20240719 (Red Hat 11.5.0-5)] (/usr/bin/python3) jinja version = 3.1.2 libyaml = True

  • my code!
---
# tasks file for agent_1_liner
# MAYBE BUG HERE - on second run file is 0 size
  - name: Download Instana Agent installer
    get_url:
      url: "https://setup.instana.io/agent"
      dest: "/tmp/setup_agent.sh"
      mode: '0700'

  - name: Install Instana Agent
    command:
      cmd: >
        ./setup_agent.sh
        -a "{{ instana_agent_key }}"
        -d "{{ instana_agent_endpoint_key }}"
        -t dynamic
        -e "{{ instana_agent_endpoint }}"
        -y
    become: true
    args:
      chdir: /tmp
      creates: /opt/instana/agent

  - name: Ensure Instana Agent is started and enabled
    systemd:
      name: instana-agent
      state: started
      enabled: true
    become: true
1 Like