How to execute a shell script and use the result in ansible
- 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 }}"
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 }}"