klaatu51.github_downloader
Ansible Role: github_downloader
This Ansible role lets you download binary files from a GitHub repository release to a chosen location.
Requirements
This role works with Ansible version 2.10.0 and higher and is designed for Linux/UNIX systems.
Disclaimer
If you run into any issues, please create a GitHub issue. I manage this role in my free time, so I can't guarantee quick responses.
Role Variables
Here’s a list of variables used in this role. For more details, see defaults/main.yml
Variable | Short Description | Default Value |
---|---|---|
github_download_packages |
List of binaries to download. See example below. | [] |
github_download_location |
Destination for the downloads. | $HOME/bin |
github_download_pat_token |
Personal Access Token for API access | None |
github_download_hostname |
GitHub hostname. | github.com |
github_download_api_hostname |
GitHub API hostname. | api.github.com |
Filename Templates
You can use these variables in filenames. They will be replaced with values found by Ansible facts.
Variable | Description | Example |
---|---|---|
%ARCH% |
OS Architecture | amd64 |
%ARCHRAW% |
OS Architecture (keeps x86_64 as x86_64 ) |
x86_64 |
%OS% |
OS Family (in lowercase) | linux / darwin |
%OSCAPITALIZED% |
OS Family (capitalized) | Linux / Darwin |
%VERSION% |
Package Version | v1.20.0 |
%NVERSION% |
Package Version (without the v prefix) |
1.20.0 |
Dependencies
This role does not depend on any other roles.
Example Playbook
Here’s an example playbook that creates a list of users from GitHub.
- hosts: all
become: true
vars:
github_download_packages:
- name: package_name
repo: owner/repo
version: 1.0.2 # Can also be 'latest'
filename: package_name-%VERSION%-%OS%-%ARCH%.tar.gz # See filename templates above
extracted_filename: package_name-%VERSION%
command: package_name install
command_become: false # Do not become root for this command
roles:
- role: xanmanning.github_downloader