Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible - Download latest release binary from Github repo

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!

like image 633
Tudor Avatar asked Jun 21 '18 10:06

Tudor


People also ask

How do I pull latest release from GitHub?

On GitHub.com, navigate to the main page of the repository. To the right of the list of files, click Releases. To copy a unique URL to your clipboard, find the release you want to link to, right click the title, and copy the URL. Alternatively, right click Latest Release and copy the URL to share it.

How do I clone a Git repository in Ansible?

Cloning a Git Repository with Ansible playbook In the playbook above, you started by defining a new task and gave it the name “Clone a GitHub repository". Next, you are using the git module to specify the link to the SQLite GitHub repository. You then proceed to define the destination for the cloned repository.

How do I download latex from GitHub?

The repository is located at https://github.com/latex3/latex2e and from that browser page you may explore the files, clone the repository or download the files in a . zip archive (roughly 25Mb) by using the appropriate buttons.


1 Answers

Another approach is to use ansible github_release module to get the latest tag

example

- name: Get gogs latest tag 
  github_release:
    user: gogs
    repo: gogs
    action: latest_release
  register: gogs_latest 

- name: Grab gogs latest binaries 
  unarchive: 
    src: "https://github.com/gogs/gogs/releases/download/{{ gogs_latest['tag'] }}/gogs_{{ gogs_latest['tag'] | regex_replace('^v','') }}_linux_amd64.zip"
    dest: /usr/local/bin
    remote_src: true 

  • The regex part at the end is for replacing the v at the beginning of the tag since the format now on GitHub for gogs is gogs_0.12.3_linux_armv7.zip and latest tag includes a v
like image 56
theJaxon Avatar answered Nov 16 '22 01:11

theJaxon