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
6,912 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
• 7,340 points

Related Questions In Ansible

0 votes
1 answer

How do I wget a file from web server using shell in the ansible playbook

Hey Ayaan, you could probably use this ...READ MORE

answered Jan 24, 2019 in Ansible by Anushri
4,178 views
0 votes
1 answer
0 votes
1 answer

How do I get an ENV variable and store it into a local variable - Ansible

Hey @Ninja, that is possible. What you ...READ MORE

answered Jan 24, 2019 in Ansible by Thomas
2,635 views
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, 2019 in Ansible by anonymous
3,276 views
+15 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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,059 views
+2 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 17, 2018 in Ansible by shubham
• 7,340 points
5,534 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP