With Ansible please advise how i could download the latest release binary from Github repository. As per my current understanding the steps would be: a. get URL of latest release b. download the release
For a. I have something like which does not provide the actual release (ex. v0.11.53):
- name: get latest Gogs release
local_action:
module: uri
url: https://github.com/gogits/gogs/releases/latest
method: GET
follow_redirects: no
status_code: 301
register: release_url
For b. I have the below which works but needs constant updating. Instead of version i would need a variable set in a.:
- name: download latest
become: yes
become-user: "{{gogs_user}}"
get_url:
url: https://github.com/gogs/gogs/releases/download/v0.11.53/linux_amd64.tar.gz
dest: "/home/{{gogs_user}}/linux_amd64.tar.gz"
Thank you!
I am using the following recipe to download and extract latest
watchexec
binary for Linux from GitHub releases.tar
extra_opts
explained here.This still downloads the binary every time a playbook is called. As an improvement, it might be possible to use
set_fact
for cachingnode_id
attribute that corresponds to the unpacked file.Github has an API to manipulate the release which is documented.
so imagine you want to get the latest release of ansible (which belong to the project ansible) you would
https://api.github.com/repos/ansible/ansible/releases/latest
tarball_url
In ansible code that would do
I let you adapt the proper parameters to answer your question :)