diff --git a/tasks/expiring-licenses.sh b/tasks/expiring-licenses.sh new file mode 100755 index 00000000..de0f6ea4 --- /dev/null +++ b/tasks/expiring-licenses.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# code_snippet expiring-licenses-script start bash + +cat /var/version && echo "" +set -eux + +# Build the command with optional flags +cmd="om --env env/"${ENV_FILE}" expiring-licenses --format json" + +if [ -n "${EXPIRES_WITHIN:-}" ]; then + cmd="${cmd} --expires-within ${EXPIRES_WITHIN}" +fi + +if [ "${STAGED:-false}" = "true" ]; then + cmd="${cmd} --staged" +fi + +if [ "${DEPLOYED:-false}" = "true" ]; then + cmd="${cmd} --deployed" +fi + +# Run the command and capture the output +output=$(${cmd}) + +# Check if there are any expiring licenses (empty array means no licenses) +if [ "$output" != "[]" ]; then + echo "Found expiring licenses:" + echo "$output" + exit 1 +fi + +echo "No expiring licenses found within ${EXPIRES_WITHIN:-3m}" +# code_snippet expiring-licenses-script end diff --git a/tasks/expiring-licenses.yml b/tasks/expiring-licenses.yml new file mode 100644 index 00000000..2d92843d --- /dev/null +++ b/tasks/expiring-licenses.yml @@ -0,0 +1,42 @@ +# The inputs, outputs, params, filename, and filepath +# of this task file are part of its semantically versioned API. +# See our documentation for a detailed discussion of our semver API. +# See www.semver.org for an explanation of semantic versioning. + +# code_snippet expiring-licenses start yaml +--- +platform: linux + +inputs: + - name: platform-automation-tasks + - name: env # contains the env file with target OpsMan Information + +params: + ENV_FILE: env.yml + # - Required + # - Filepath of the env config YAML + # - The path is relative to root of the `env` input + + EXPIRES_WITHIN: + # - Optional + # - Example: "3m" is 3 months + # - Check for licenses expiring within the defined time period + # - Supports a time period defined with a suffix of: + # days(d), weeks(w), months(m) and years(y) + # - Defaults to "3m" if not specified + + STAGED: + # - Optional + # - Boolean flag + # - Include staged products in the check + # - Defaults to false if not specified + + DEPLOYED: + # - Optional + # - Boolean flag + # - Include deployed products in the check + # - Defaults to false if not specified + +run: + path: platform-automation-tasks/tasks/expiring-licenses.sh +# code_snippet expiring-licenses end