Merge "Add ensure-bazelisk role"
This commit is contained in:
commit
f4703021a4
@ -14,6 +14,7 @@ General Purpose Roles
|
||||
.. zuul:autorole:: dstat-graph
|
||||
.. zuul:autorole:: emit-job-header
|
||||
.. zuul:autorole:: enable-netconsole
|
||||
.. zuul:autorole:: ensure-bazelisk
|
||||
.. zuul:autorole:: ensure-dstat-graph
|
||||
.. zuul:autorole:: ensure-markdownlint
|
||||
.. zuul:autorole:: fetch-markdownlint
|
||||
|
34
roles/ensure-bazelisk/README.rst
Normal file
34
roles/ensure-bazelisk/README.rst
Normal file
@ -0,0 +1,34 @@
|
||||
Ensure that bazelisk is present.
|
||||
|
||||
If bazelisk is already installed, this role does nothing. Otherwise,
|
||||
it downloads bazelisk from GitHub and installs it in the user's
|
||||
home directory by default.
|
||||
|
||||
**Role Variables**
|
||||
|
||||
.. zuul:rolevar:: bazelisk_version
|
||||
:default: v1.3.0
|
||||
|
||||
Version of bazelisk to install.
|
||||
|
||||
.. zuul:rolevar:: bazelisk_arch
|
||||
:default: linux-amd64
|
||||
|
||||
Architecture to install.
|
||||
|
||||
.. zuul:rolevar:: bazelisk_url
|
||||
:default: https://github.com/bazelbuild/bazelisk/releases/download/{{ bazelisk_version }}/bazelisk-{{ bazelisk_arch }}
|
||||
|
||||
The URL from which to download bazelisk.
|
||||
|
||||
.. zuul:rolevar:: bazelisk_executable
|
||||
:default: bazelisk
|
||||
|
||||
The bazelisk executable. If this already exists, the
|
||||
role will not perform any further actions.
|
||||
|
||||
.. zuul:rolevar:: bazelisk_target
|
||||
:default: "{{ ansible_user_dir }}/.local/bin/bazelisk"
|
||||
|
||||
Where to install bazelisk. If the role downloads bazelisk, it will
|
||||
set :zuul:rolevar:`ensure-bazelisk.bazelisk_executable` to this value as well.
|
6
roles/ensure-bazelisk/defaults/main.yaml
Normal file
6
roles/ensure-bazelisk/defaults/main.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
bazelisk_version: v1.3.0
|
||||
bazelisk_arch: linux-amd64
|
||||
bazelisk_url: "https://github.com/bazelbuild/bazelisk/releases/download/{{ bazelisk_version }}/bazelisk-{{ bazelisk_arch }}"
|
||||
bazelisk_executable: bazelisk
|
||||
# If we have to download it, store it here:
|
||||
bazelisk_target: "{{ ansible_user_dir }}/.local/bin/bazelisk"
|
25
roles/ensure-bazelisk/tasks/main.yaml
Normal file
25
roles/ensure-bazelisk/tasks/main.yaml
Normal file
@ -0,0 +1,25 @@
|
||||
- name: Check if bazelisk is installed
|
||||
command: bash -c "type -p {{ bazelisk_executable }}"
|
||||
failed_when: false
|
||||
register: bazelisk_installed
|
||||
|
||||
- name: Ensure target directory exists
|
||||
file:
|
||||
state: directory
|
||||
path: "{{ bazelisk_target | dirname }}"
|
||||
when: bazelisk_installed.rc != 0
|
||||
|
||||
- name: Download bazelisk
|
||||
get_url:
|
||||
url: "{{ bazelisk_url }}"
|
||||
dest: "{{ bazelisk_target }}"
|
||||
mode: '0755'
|
||||
when: bazelisk_installed.rc != 0
|
||||
register: bazelisk_downloaded
|
||||
|
||||
# This will apply to further plays and playbooks
|
||||
- name: Set bazelisk_executable fact
|
||||
set_fact:
|
||||
bazelisk_executable: "{{ bazelisk_target }}"
|
||||
cacheable: true
|
||||
when: bazelisk_downloaded is changed
|
@ -233,6 +233,15 @@
|
||||
vars:
|
||||
role_name: clear-firewall
|
||||
|
||||
- job:
|
||||
name: zuul-jobs-test-ensure-bazelisk
|
||||
description: Test the ensure-bazelisk role
|
||||
files:
|
||||
- roles/ensure-bazelisk/.*
|
||||
run: test-playbooks/simple-role-test.yaml
|
||||
vars:
|
||||
role_name: ensure-bazelisk
|
||||
|
||||
- job:
|
||||
name: zuul-jobs-test-netconsole
|
||||
description: Test the netconsole setup role
|
||||
@ -482,6 +491,7 @@
|
||||
- zuul-jobs-test-base-roles-ubuntu-xenial
|
||||
- zuul-jobs-test-bindep
|
||||
- zuul-jobs-test-clear-firewall
|
||||
- zuul-jobs-test-ensure-bazelisk
|
||||
- zuul-jobs-test-netconsole
|
||||
- zuul-jobs-test-dstat-graph
|
||||
- zuul-jobs-test-multinode-roles-centos-7
|
||||
@ -510,6 +520,7 @@
|
||||
- zuul-jobs-test-base-roles-ubuntu-xenial
|
||||
- zuul-jobs-test-bindep
|
||||
- zuul-jobs-test-clear-firewall
|
||||
- zuul-jobs-test-ensure-bazelisk
|
||||
- zuul-jobs-test-netconsole
|
||||
- zuul-jobs-test-dstat-graph
|
||||
- zuul-jobs-test-multinode-roles-centos-7
|
||||
|
Loading…
Reference in New Issue
Block a user