Skip to content

Commit

Permalink
Install from Github for now (#8)
Browse files Browse the repository at this point in the history
The package repository doesn't have packages for ARM.  Let's get
packages from our own Github release assets for now.

Towards GAME-12059.
  • Loading branch information
legoscia authored Nov 15, 2021
1 parent 32bf25e commit 5f42ad0
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 17 deletions.
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ carbon_relay_ng_work_dir: /run/carbon-relay-ng
wait_for_startup: True
wait_for_startup_timeout: 30
wait_for_healthcheck: True

install_from_github_release: True
40 changes: 40 additions & 0 deletions tasks/install_from_github_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
- name: Get latest version from Github
uri:
url: "https://api.github.com/repos/GameAnalytics/carbon-relay-ng/releases/tags/v1.1"
return_content: yes
register: github_response

- name: Get architecture string
set_fact:
arch_string: "{% if ansible_architecture == 'aarch64' %}arm64{% else %}amd64{% endif %}"

- name: Get package name
set_fact:
github_binary_filename: "carbon-relay-ng-1.1-1_{{ arch_string }}.deb"

- name: Set fact about asset URL
set_fact:
binary_asset_url: "{{ github_response.json.assets|json_query(query) }}"
vars:
query: "[?name=='{{ github_binary_filename }}'].url | [0]"
failed_when: not binary_asset_url

- name: Get Binary asset's location
uri:
url: "{{ binary_asset_url }}"
return_content: no
follow_redirects: none
status_code: 302
headers:
Accept: "application/octet-stream"
register: assets

- name: Download binary release
get_url:
url: "{{ assets.location }}"
dest: "/tmp/{{ github_binary_filename }}"
mode: 0644

- name: Install carbon-relay-ng from .deb file
apt:
deb: "/tmp/{{ github_binary_filename }}"
17 changes: 17 additions & 0 deletions tasks/install_with_apt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Raintank is the repository provided by the team who develops carbon-relay-ng (GrafanaLabs)
- name: Add https support for apt
apt:
name: apt-transport-https

- name: Add raintank apt-key
apt_key:
url: https://packagecloud.io/raintank/raintank/gpgkey

- name: Add raintank apt repository
apt_repository:
repo: "deb https://packagecloud.io/raintank/raintank/ubuntu/ xenial main"

- name: Install carbon-relay-ng
apt:
name: carbon-relay-ng
update_cache: yes
27 changes: 10 additions & 17 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
# Raintank is the repository provided by the team who develops carbon-relay-ng (GrafanaLabs)
- name: Add https support for apt
apt:
name: apt-transport-https

- name: Add raintank apt-key
apt_key:
url: https://packagecloud.io/raintank/raintank/gpgkey

- name: Add raintank apt repository
apt_repository:
repo: "deb https://packagecloud.io/raintank/raintank/ubuntu/ xenial main"

- name: Install carbon-relay-ng
apt:
name: carbon-relay-ng
update_cache: yes
# The package repository currently doesn't contain ARM64 packages,
# so we install packages stored in a github release instead.
#
# Revisit once https://github.com/grafana/carbon-relay-ng/pull/479
# is merged.
- include: install_from_github_release.yml
when: install_from_github_release

- include: install_with_apt.yml
when: not install_from_github_release

- name: Copy conf file
template:
Expand Down

0 comments on commit 5f42ad0

Please sign in to comment.