1

First of all, I'm still an ansible newbie, so please excuse my ignorance.

I don't know if that's even possible, but I'm trying to get the URL produced by this command:

curl -s https://api.github.com/repos/Radarr/Radarr/releases | grep linux.tar.gz | grep browser_download_url | head -1 | cut -d \" -f 4

and use it in play to download the package:

here is my play:

  - name: download Radarr
    get_url:
      url: "{{ Radarr_exe_url }}" #should be the url from above
      dest: "{{ Radarr_data_path }}"
    become: true
    become_user: "{{ Radarr_user_name }}"
    notify:
      - Restart Radarr service

2 Answers 2

2
- name:               Get Radar exe url
  shell:              curl -s https://api.github.com/repos/Radarr/Radarr/releases | grep linux.tar.gz | grep browser_download_url | head -1 | cut -d \" -f 4
  register:           shell_output
- set_fact:
    Radarr_exe_url : "{{ shell_output.stdout }}"
Sign up to request clarification or add additional context in comments.

2 Comments

@KonstantinSuvorov any advice about the right way to parse it in bash?
I think I could've used jq better? but that isn't portable
2

Here is pure Ansible solution, as calling shell commands when there is module available considered bad practice:

- hosts: localhost
  gather_facts: no
  tasks:
    - uri:
        url: https://api.github.com/repos/Radarr/Radarr/releases
        return_content: yes
        body_format: json
      changed_when: no
      register: radarr_releases

    - set_fact:
        Radarr_exe_url: "{{ radarr_releases.json | json_query('[0].assets[].browser_download_url') | select('search','linux.tar.gz') | first }}"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.