I’m working on a playbook to upgrade all our F5 devices but having trouble with the download of the ISO from Artifactory to the F5. When I run the play the file is downloaded but its downloaded to the Ansible control node not the F5. Here’s my play,
I'm working on a playbook to upgrade all our F5 devices but having trouble with the download of the ISO from Artifactory to the F5. When I run the play the file is downloaded but its downloaded to the Ansible control node not the F5. Here's my play,
---
- hosts:
- lab_f5
gather_facts: no
connection: local
vars_prompt:
- name: f5_user
prompt: "Enter F5 Username"
private: no
- name: f5_password
prompt: "Enter F5 Password"tasks:
- name: Shell download
shell: curl -vvvv -H 'X-JFrog-Art-API:api_key' -O https://artifactory.com/repo/F5/BIGIP-14.1.4.3-0.0.8.iso
args:
executable: /bin/bash
chdir: /shared/images
delegate_to: "{{ inventory_hostname }}"It doesn't seem to matter if I use the delegate_to statement or not. If I run the play I get a message that the /shared/images doesn't exists and if I remove the chdir or change the directory to something that exists on my Ansible control node it works but downloads the file to the control node not the F5.
You are using "connection: local" for lab_f5 host, so I think that inventory_hostname points to the Ansible controller.
Regards
Racke
Why use curl and not the dedicated get_url module?
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/get_url_module.html
Why use curl and not the dedicated get_url module?
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/get_url_module.html
Are you sure that F5 has a proper Python installed?
Regards
Racke
This appears to work. I did try the get_url module and got the same results the file was being downloaded to the Ansible control node. This issue I think with that was the connection: local. I could have tried it with the connection: ssh but I would have needed to make this part of the upgrade be its own playbook. Instead I did this and its working,
- name: Download ISO from Artifactory
uri:
method: “POST”
url: “https://{{ ansible_host | default(inventory_hostname) }}/mgmt/tm/util/bash”
user: “{{ lookup(‘env’, ‘F5_USER’) }}”
password: “{{ lookup(‘env’, ‘F5_PASSWORD’) }}”
body:
command: “run”
utilCmdArgs: “-c ‘cd /shared/images; curl -vvvv -H ‘X-JFrog-Art-API:api_key’ -O https://artifactory.com/repo/F5/BIGIP-14.1.4.3-0.0.8.iso’”
body_format: json
status_code: 200
validate_certs: no
timeout: 120
register: artifactory_download