download ISO from artifactory to F5

120 views
Skip to first unread message

Sharon Day

unread,
Jul 8, 2021, 9:48:00 AM7/8/21
to Ansible Project
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.

Any help or suggestions would be appreciated.

Stefan Hornburg (Racke)

unread,
Jul 8, 2021, 9:56:42 AM7/8/21
to ansible...@googlegroups.com
You are using "connection: local" for lab_f5 host, so I think that inventory_hostname points to the Ansible controller.

Regards
Racke

>
> Any help or suggestions would be appreciated.
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/063deb2e-9958-4a6f-b015-0bc3e5a76a02n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/063deb2e-9958-4a6f-b015-0bc3e5a76a02n%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

Dick Visser

unread,
Jul 8, 2021, 9:56:56 AM7/8/21
to ansible...@googlegroups.com
Why use curl and not the dedicated get_url module?
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/get_url_module.html
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/063deb2e-9958-4a6f-b015-0bc3e5a76a02n%40googlegroups.com.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Stefan Hornburg (Racke)

unread,
Jul 8, 2021, 10:05:57 AM7/8/21
to ansible...@googlegroups.com
On 08/07/2021 15:56, Dick Visser wrote:
> 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

Sharon Day

unread,
Jul 8, 2021, 11:26:03 AM7/8/21
to Ansible Project
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

Reply all
Reply to author
Forward
0 new messages