Skip to content

Commit 5808144

Browse files
committed
Add expiring licenses check script and configuration
Introduce a new script to check for expiring licenses and a corresponding YAML configuration file. The script captures output based on specified parameters, reports any licenses that are expiring within a defined timeframe, and exits with exit 1.
1 parent bc945e6 commit 5808144

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

tasks/expiring-licenses.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
# code_snippet expiring-licenses-script start bash
3+
4+
cat /var/version && echo ""
5+
set -eux
6+
7+
# Build the command with optional flags
8+
cmd="om --env env/"${ENV_FILE}" expiring-licenses --format json"
9+
10+
if [ -n "${EXPIRES_WITHIN:-}" ]; then
11+
cmd="${cmd} --expires-within ${EXPIRES_WITHIN}"
12+
fi
13+
14+
if [ "${STAGED:-false}" = "true" ]; then
15+
cmd="${cmd} --staged"
16+
fi
17+
18+
if [ "${DEPLOYED:-false}" = "true" ]; then
19+
cmd="${cmd} --deployed"
20+
fi
21+
22+
# Run the command and capture the output
23+
output=$(${cmd})
24+
25+
# Check if there are any expiring licenses (empty array means no licenses)
26+
if [ "$output" != "[]" ]; then
27+
echo "Found expiring licenses:"
28+
echo "$output"
29+
exit 1
30+
fi
31+
32+
echo "No expiring licenses found within ${EXPIRES_WITHIN:-3m}"
33+
# code_snippet expiring-licenses-script end

tasks/expiring-licenses.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# The inputs, outputs, params, filename, and filepath
2+
# of this task file are part of its semantically versioned API.
3+
# See our documentation for a detailed discussion of our semver API.
4+
# See www.semver.org for an explanation of semantic versioning.
5+
6+
# code_snippet expiring-licenses start yaml
7+
---
8+
platform: linux
9+
10+
inputs:
11+
- name: platform-automation-tasks
12+
- name: env # contains the env file with target OpsMan Information
13+
14+
params:
15+
ENV_FILE: env.yml
16+
# - Required
17+
# - Filepath of the env config YAML
18+
# - The path is relative to root of the `env` input
19+
20+
EXPIRES_WITHIN:
21+
# - Optional
22+
# - Example: "3m" is 3 months
23+
# - Check for licenses expiring within the defined time period
24+
# - Supports a time period defined with a suffix of:
25+
# days(d), weeks(w), months(m) and years(y)
26+
# - Defaults to "3m" if not specified
27+
28+
STAGED:
29+
# - Optional
30+
# - Boolean flag
31+
# - Include staged products in the check
32+
# - Defaults to false if not specified
33+
34+
DEPLOYED:
35+
# - Optional
36+
# - Boolean flag
37+
# - Include deployed products in the check
38+
# - Defaults to false if not specified
39+
40+
run:
41+
path: platform-automation-tasks/tasks/expiring-licenses.sh
42+
# code_snippet expiring-licenses end

0 commit comments

Comments
 (0)