Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/reusable-test-ta-install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Test Splunk TA Installs

on:
push:
workflow_dispatch:
Comment on lines +4 to +5
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
push:
workflow_dispatch:
workflow_call:
inputs:
addon_name:
required: true
type: string

To enable trigger from another workflow and pass the TA name


env:
SPLUNK_PASSWORD: password
SPLUNK_USER: admin
# Set this to your actual TA folder/app name (must match the folder name under etc/apps)
TA_NAME: TA-your_addon_name
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TA_NAME: TA-your_addon_name
TA_NAME: ${{ inputs.addon_name }}
permissions:
contents: read # to successfully checkout repo


jobs:
test-ta-install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- uses: actions/checkout@v4
- uses: actions/checkout@v6


- name: Start Splunk (Docker)
run: |
docker run -d --name splunk \
-e SPLUNK_START_ARGS="--accept-license" \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-e SPLUNK_START_ARGS="--accept-license" \
-e SPLUNK_START_ARGS="--answer-yes --no-prompt --accept-license" \
-e SPLUNK_GENERAL_TERMS: "--accept-sgt-current-at-splunk-com" \

This should also fix the error in the automation execution.

-e SPLUNK_PASSWORD="${SPLUNK_PASSWORD}" \
-p 8089:8089 -p 8000:8000 \
splunk/splunk:latest

- name: Wait for Splunk API
run: |
for i in {1..60}; do
if curl -sk https://localhost:8089/services/server/info >/dev/null; then
echo "Splunk is up"
exit 0
fi
sleep 5
done
docker logs splunk
exit 1

- name: Install TA into Splunk and restart
run: |
docker exec splunk mkdir -p /opt/splunk/etc/apps/"$TA_NAME"
docker cp . splunk:/opt/splunk/etc/apps/"$TA_NAME"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this is going to work. Need to build the TA from package first to be able to copy it in the container. 🤔

docker exec splunk bash -lc "chown -R splunk:splunk /opt/splunk/etc/apps/$TA_NAME"
docker exec splunk bash -lc "/opt/splunk/bin/splunk restart --accept-license --answer-yes --no-prompt"

- name: Verify app is registered
run: |
docker exec splunk bash -lc \
"curl -sk -u ${SPLUNK_USER}:${SPLUNK_PASSWORD} \
https://localhost:8089/services/apps/local?count=0 \
| tr '\n' ' ' \
| grep -q \"<title>${TA_NAME}</title>\""

- name: Dump logs on failure
if: failure()
run: docker logs splunk
Comment thread
edro15 marked this conversation as resolved.
Loading