Skip to content

Commit f466efc

Browse files
authored
Add metal-v2-client role to install V2 client library. (#525)
1 parent d6dc19d commit f466efc

File tree

5 files changed

+76
-0
lines changed

5 files changed

+76
-0
lines changed

control-plane/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ The `defaults` folder contains defaults that are used by multiple roles in the c
5151
| [meili-backup-restore](roles/meili-backup-restore) | A role for deploying a meilisearch database with a [backup-restore-sidecar](https://github.com/metal-stack/backup-restore-sidecar) |
5252
| [metal-db](roles/metal-db) | Deploys a database for the metal-api |
5353
| [metal-python](roles/metal-python) | Installs metal-python |
54+
| [metal-v2-client](roles/metal-v2-client) | Installs metal-stack-api |
5455
| [metal](roles/metal) | Deploys all metal-stack components of the metal-control-plane via Helm chart |
5556
| [monitoring](roles/monitoring) | Deploys metal-stack control plane monitoring components |
5657
| [nsq](roles/nsq) | Deploys [nsq](https://nsq.io/) |
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# metal-v2-client
2+
3+
Sets up [metal-stack-api](https://pypi.org/project/metal-stack-api/) client library from [api](https://github.com/metal-stack/api).
4+
5+
By default, this role uses the release vector to derive the fitting version of the client library.
6+
7+
## Requirements
8+
9+
None
10+
11+
## Variables
12+
13+
| Name | Mandatory | Description |
14+
| ----------------------------------------------- | --------- | ----------------------------------------------------------------------------------------- |
15+
| metal_v2_client_install_latest_on_version_error | | Whether to just install latest client library version when given version was not found |
16+
| metal_v2_client_install_from_git_repository | | Alternatively, install directly from the git repository (e.g. for testing a devel branch) |
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
metal_v2_client_install_latest_on_version_error: true
3+
metal_v2_client_install_from_git_repository: false
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
galaxy_info:
3+
role_name: metal-v2-client
4+
author: metal-stack
5+
description: Installs the metal-stack v2 client library.
6+
license: MIT
7+
min_ansible_version: "2.18"
8+
galaxy_tags: []
9+
10+
platforms:
11+
- name: GenericLinux
12+
versions:
13+
- all
14+
15+
dependencies:
16+
- role: metal-roles/common/roles/defaults
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
- name: Gather releases
3+
setup_yaml:
4+
5+
- name: Install metal-stack-api
6+
block:
7+
- name: Install metal-stack-api client library {{ metal_api_version }}
8+
pip:
9+
name:
10+
- metal-stack-api=={{ metal_api_version }}
11+
- bufbuild-protovalidate-protocolbuffers-python
12+
environment:
13+
# to install the bug module we need for now a download from the buf.build index:
14+
# https://github.com/bufbuild/protovalidate-python/pull/367
15+
PIP_EXTRA_INDEX_URL: https://buf.build/gen/python
16+
17+
when: not metal_v2_client_install_from_git_repository | bool
18+
19+
- name: Install metal-stack-api client library {{ metal_api_version }} from git repository
20+
pip:
21+
name: git+https://github.com/metal-stack/api.git@{{ metal_api_version }}#subdirectory=python
22+
when: metal_v2_client_install_from_git_repository | bool
23+
environment:
24+
VERSION: "{{ metal_api_version }}"
25+
26+
rescue:
27+
# attempt with latest available client when fitting client is not available
28+
- name: Install latest metal-stack-api client library (fallback)
29+
pip:
30+
name:
31+
- metal-stack-api
32+
- bufbuild-protovalidate-protocolbuffers-python
33+
environment:
34+
PIP_EXTRA_INDEX_URL: https://buf.build/gen/python
35+
when: metal_v2_client_install_latest_on_version_error | bool
36+
37+
- name: Fail on unavailable version
38+
fail:
39+
msg: "given metal-stack-api version not found"
40+
when: not metal_v2_client_install_latest_on_version_error | bool

0 commit comments

Comments
 (0)