Skip to content

Commit

Permalink
Helpers for testing in a local rundeck
Browse files Browse the repository at this point in the history
  • Loading branch information
farmdawgnation committed Feb 8, 2021
1 parent b8d4b3c commit 93ad5ff
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
9 changes: 9 additions & 0 deletions test-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM rundeck/rundeck:3.3.9

COPY rundeck-config-storage.properties /etc/remco/templates/rundeck-config-storage.properties

USER root

RUN chown rundeck:root /etc/remco/templates/rundeck-config-storage.properties

USER rundeck
58 changes: 58 additions & 0 deletions test-image/rundeck-config-storage.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{% set providerBase = "/rundeck/storage/provider" %}
{% set converterBase = "/rundeck/storage/converter" %}
{% set configConverterBase = "/rundeck/config/storage/converter" %}


{%- macro storage_provider(provider) %}
{%- set index = provider | base %}
{%- set type = getv(printf("%s/type", provider), "db") %}
{% if type == 'db' || type == 'file' %}
rundeck.storage.provider.{{index}}.type={% set type = printf("%s/type", provider) %}{{ getv(type, "db")}}
rundeck.storage.provider.{{index}}.path={% set path = printf("%s/path", provider) %}{{ getv(path, "keys")}}
{% endif %}
{% endmacro %}

{%- macro storage_converter(converter) %}
{%- set index = converter | base %}
rundeck.storage.converter.{{index}}.type={% set type = printf("%s/type", converter) %}{{ getv(type, "jasypt-encryption") }}
rundeck.storage.converter.{{index}}.path={% set path = printf("%s/path", converter) %}{{ getv(path, "keys") }}
rundeck.storage.converter.{{index}}.config.encryptorType={% set encryptortype = printf("%s/config/encryptortype", converter) %}{{ getv(encryptortype, "custom") }}
rundeck.storage.converter.{{index}}.config.password={% set password = printf("%s/config/password", converter) %}{{ getv(password, "") }}
rundeck.storage.converter.{{index}}.config.algorithm={% set algorithm = printf("%s/config/algorithm", converter) %}{{ getv(algorithm, "PBEWITHSHA256AND128BITAES-CBC-BC") }}
rundeck.storage.converter.{{index}}.config.provider={% set provider = printf("%s/config/provider", converter) %}{{ getv(provider, "BC") }}
rundeck.storage.converter.{{index}}.config.keyArn={% set keyArn = printf("%s/config/keyarn", converter) %}{{ getv(keyArn, "") }}
{% endmacro %}

{%- macro config_storage_converter(converter) %}
{%- set index = converter | base %}
rundeck.config.storage.converter.{{index}}.type={% set type = printf("%s/type", converter) %}{{ getv(type, "jasypt-encryption") }}
rundeck.config.storage.converter.{{index}}.path={% set path = printf("%s/path", converter) %}{{ getv(path, "projects") }}
rundeck.config.storage.converter.{{index}}.config.encryptorType={% set encryptortype = printf("%s/config/encryptortype", converter) %}{{ getv(encryptortype, "custom") }}
rundeck.config.storage.converter.{{index}}.config.password={% set password = printf("%s/config/password", converter) %}{{ getv(password, "") }}
rundeck.config.storage.converter.{{index}}.config.algorithm={% set algorithm = printf("%s/config/algorithm", converter) %}{{ getv(algorithm, "PBEWITHSHA256AND128BITAES-CBC-BC") }}
rundeck.config.storage.converter.{{index}}.config.provider={% set provider = printf("%s/config/provider", converter) %}{{ getv(provider, "BC") }}
rundeck.config.storage.converter.{{index}}.config.keyArn={% set keyArn = printf("%s/config/keyarn", converter) %}{{ getv(keyArn, "") }}
{% endmacro %}

{%- if ls(printf("%s/1", providerBase)) | length == 0 %}
rundeck.storage.provider.1.type=db
rundeck.storage.provider.1.path=keys
{% endif %}


{%- for p in lsdir(providerBase) -%}
{% set provider = printf("%s/%s", providerBase, p) -%}
{{ storage_provider(provider) }}
{%- endfor %}

{%- for c in lsdir(converterBase) %}
{% set converter = printf("%s/%s", converterBase, c) -%}
{{ storage_converter(converter) }}
{%- endfor %}

rundeck.projectsStorageType={{ getv("/rundeck/projectsstoragetype", "db") }}

{% for c in lsdir(configConverterBase) %}
{% set converter = printf("%s/%s", configConverterBase, c) -%}
{{ config_storage_converter(converter) }}
{%- endfor %}
9 changes: 8 additions & 1 deletion test-in-rundeck.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
#!/bin/bash

set -e

docker build -t rundeck-kms-test-image test-image

docker run -it \
-e AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY \
-e AWS_REGION \
-e RUNDECK_STORAGE_CONVERTER_1_TYPE=rundeck-kms-plugin \
-e RUNDECK_STORAGE_CONVERTER_1_PATH=keys \
-e RUNDECK_STORAGE_CONVERTER_1_CONFIG_KEYARN=$KMS_KEY_ARN \
-p 4440:4440 \
-v $(pwd)/lib/build/libs/rundeck-kms-plugin.jar:/home/rundeck/libext/rundeck-kms-plugin.jar \
rundeck/rundeck:3.3.9
rundeck-kms-test-image

0 comments on commit 93ad5ff

Please sign in to comment.