Download file to ansible controller instead to remote machine

Viewed 840

I'm having two machines one is the ansible controller where I execute my playbooks from and the other one is the remote machine (target) which I would like to install/update. The important thing is that the controller runs within the corporate network but the target is outside that network (only accessible via ssh).

So I need to download a file (from within the corporate network) and copy it to the target node.

I've tried to use: ansible.builtin.get_url to download the file but unfortunately it will do that on the remote (target) machine which has of course no access to the corporate network.

Does someone has a tip/idea ?

Update: Using ansible [core 2.11.6]

1 Answers

To download something to the local Ansible Controller you may use the following approach.

- name: Download something to Ansible Controller
  delegate_to: localhost
  get_url:
    url: "https://{{ ansible_user }}:{{ ansible_password }}@files.example.com/installer.rpm"
    dest: "/tmp/{{ ansible_user }}"
    owner: "{{ ansible_user }}"
  tags: download,local

Please take note that according Controlling where tasks run: delegation and local actions, delegate_to is not a parameter of module get_url but of the task.

Related