How do I execute a shell script and then use the result in ansible

0 votes

I am new to Ansible so please excuse me if I am subtle.

I am trying to fetch the URL produced by this command but I don't know if it's possible to do that.

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

I want to 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
Can anyone help me with this?
Thanks


Apr 11, 2018 in Ansible by Atul
• 10,240 points
1,690 views

1 answer to this question.

0 votes
This can work out for you:
- 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 }}"
answered Apr 11, 2018 by shubham
• 6,890 points

Related Questions In Ansible

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
2 answers

How do you stop Ansible from creating .retry files in the home directory?

[defaults] ... retry_files_enabled = True # Create them ...READ MORE

answered Apr 5 in Ansible by anonymous
834 views
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
215 views
0 votes
1 answer
0 votes
1 answer

How to regex replace nested values in Ansible

I'm not aware of any built-in method ...READ MORE

answered Jun 16, 2018 in Ansible by shubham
• 6,890 points
1,139 views
0 votes
1 answer