trigger:
- master
pool:
vmImage: ubuntu-latest
jobs:
- job: ksmSecrets
displayName:"Inject KSM Secrets"
steps:
- task: ksmazpipelinetask@1
name: setKsmSecretsStep
inputs:
keepersecretconfig: $(sm-config)
secrets: |
6ya_fdc6XTsZ7i7x9Jcodg/field/password > var:var_password
6ya_fdc6XTsZ7i7x9Jcodg/field/password > out:out_password
6ya_fdc6XTsZ7i7x9Jcodg/field/password > out_password2
6ya_fdc6XTsZ7i7x9Jcodg/file/mykey.pub > file:/tmp/public_key.pem
6ya_fdc6XTsZ7i7x9Jcodg/file/mykey.pem > file:/tmp/private_key.pem
- bash: |
echo "Using an input-macro works : $(var_password)"
echo "Using an output variable (default method) : $(setKsmSecretsStep.out_password2)"
echo "Using an output variable : $(setKsmSecretsStep.out_password)"
echo "Using the mapped env var : $MY_MAPPED_ENV_VAR_PASSWORD"
echo "Check injected secret file : $(file /tmp/public_key.pem)"
env:
MY_MAPPED_ENV_VAR_PASSWORD: $(var_password) # 環境変数にマッピングするための推奨方法
name: display_secret_values
- bash: |
cat << EOF > decrypted.txt
This is a decrypted message
EOF
name: create_text_file
- bash: cat decrypted.txt
name: view_decrpyted_content
- bash: openssl rsautl -encrypt -inkey /tmp/public_key.pem -pubin -in decrypted.txt -out ecrypted.bin
name: encrypte_file
- bash: cat ecrypted.bin
name: view_encrpyted_content
- bash: openssl rsautl -decrypt -inkey /tmp/private_key.pem -in ecrypted.bin -out decrypted2.txt
name: decrpyt_content
- bash: cat decrypted2.txt
name: view_decrpyted2_content
- job: encryptFileTest
dependsOn: ksmSecrets
variables:
# 出力変数をAからこのジョブにマッピング
# 注意:
# ジョブ間でファイルを共有できないため、各エージェントは一度に1つのジョブしか実行できません。
# 1つのジョブは、独立した実行単位であり、異なるジョブ間で通信するには
# 変数や中間生成物などの「ミドルウェア」を使用する必要があります。
pwdFromKsmSecrets: $[ dependencies.ksmSecrets.outputs['setKsmSecretsStep.out_password'] ]
steps:
- bash: |
echo "password retrieved from job 'ksmSecrets', step 'pwdFromKsmSecrets', out variable 'setKsmSecretsStep.out_password':$(pwdFromKsmSecrets)"