Problem
Today I tried the GitLab CI Vault integration to replace manual commands as shown below. The gitlab-integration
job fails. The manual
jobs succeeds with the correct data shown. I get a permissio denied
error, but the same data is requested with commands which work with the JWT as shown below. Do I need to add some information for the Vault Integration or is my .gitlab-ci.yml
faulty?
Thanks for any help!
Error Message from gitlab-integration
job
Resolving secrets
Resolving secret "cert"...
Using "vault" secret resolver...
ERROR: Job failed (system failure): resolving secrets: reading secret: reading from Vault: api error: status code 403: 1 error occurred:
* permission denied
Output from working manual
job
$ export VAULT_ADDR=https://vault.+++.de:443
$ export VAULT_TOKEN="$(vault write -field=token auth/jwt/login jwt=$CI_JOB_JWT)"
$ vault kv get certificates/+++.de
====== Metadata ======
Key Value
--- -----
created_time 2020-12-06T19:11:21.705026445Z
deletion_time n/a
destroyed false
version 1
======= Data =======
Key Value
--- -----
certificate -----BEGIN CERTIFICATE-----
+++
-----END CERTIFICATE-----
key -----BEGIN RSA PRIVATE KEY-----
+++
-----END RSA PRIVATE KEY-----
Example
gitlab-integration: # Does not work
stage: build
variables:
VAULT_SERVER_URL: https://vault.+++.de:443
# With or without these variables, it does not change the output
# VAULT_AUTH_PATH: jwt
# VAULT_AUTH_ROLE: gitlab-ci
secrets:
cert:
vault: certificates/+++.de
image: registry.+++.de/+++/images/cpi
script:
- cat $cert
manual: # Works without problems
stage: build
image: registry.###.de/+++/images/cpi # Image with Vault installed
script:
- export VAULT_ADDR=https://vault.+++.de:443
- export VAULT_TOKEN="$(vault write -field=token auth/jwt/login jwt=$CI_JOB_JWT)"
- vault kv get certificates/+++.de
For privacy reasons, some values are removed and replaced with +++
.