Skip to content

Commit 1b880f4

Browse files
committed
Prototype action for start-opensearch
opensearch-project#2207 Signed-off-by: Peter Nied <petern@amazon.com>
1 parent a57fd0a commit 1b880f4

1 file changed

Lines changed: 76 additions & 0 deletions

File tree

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: 'Start OpenSearch'
2+
description: 'Downloads latest build of OpenSearch, installs a plugin, executes and script and then starts OpenSearch on localhost:9200'
3+
4+
inputs:
5+
platform:
6+
description: 'What platform is this action running on, e.g. "windows-latest" ? ' # Note we might be able to pull this from environment variables
7+
required: true
8+
9+
opensearch-version:
10+
description: 'The version of OpenSearch that should be used, e.g "3.0.0"'
11+
required: true
12+
13+
plugin-zip-path:
14+
description: 'The the name of the plugin to use, such as security-dashboards-plugin.zip'
15+
required: true
16+
17+
plugin-start-script:
18+
description: 'A script that should be run before starting OpenSearch'
19+
required: true
20+
# plugins/opensearch-security/tools/install_demo_configuration.sh
21+
22+
runs:
23+
using: "composite"
24+
steps:
25+
26+
# Downloads the min version of OpenSearch Core from the latest build
27+
- name: Download OpenSearch Core
28+
if: ${{ inputs.platform != "windows-latest"}}
29+
run: |
30+
wget https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/$opensearch_version/latest/linux/x64/tar/builds/opensearch/dist/opensearch-min-$opensearch_version-linux-x64.tar.gz
31+
tar -xzf opensearch-*.tar.gz
32+
rm -f opensearch-*.tar.gz
33+
shell: bash
34+
35+
# Install the plugin, runs its start-script, and start the OpenSearch server
36+
- name: Run OpenSearch with plugin
37+
if: ${{ inputs.platform != "windows-latest"}}
38+
run: |
39+
cat > os-ep.sh <<EOF
40+
yes | opensearch-plugin install file:///docker-host/plugin.zip
41+
chmod +x ${{ inputs.plugin-start-script }}
42+
yes | ${{ inputs.plugin-start-script }}
43+
chown 1001:1001 -R /opensearch
44+
su -c "/opensearch/bin/opensearch" -s /bin/bash opensearch
45+
EOF
46+
docker build -t opensearch-test:latest -f- . <<EOF
47+
FROM ubuntu:latest
48+
COPY --chown=1001:1001 os-ep.sh /docker-host/
49+
COPY --chown=1001:1001 plugin.zip /docker-host/${{ inputs.plugin-zip-path }}
50+
COPY --chown=1001:1001 opensearch* /opensearch/
51+
RUN chmod +x /docker-host/os-ep.sh
52+
RUN useradd -u 1001 -s /sbin/nologin opensearch
53+
ENV PATH="/opensearch/bin:${PATH}"
54+
WORKDIR /opensearch/
55+
ENTRYPOINT /docker-host/os-ep.sh
56+
EOF
57+
docker run --name ops -d -p 9200:9200 -p 9600:9600 -i opensearch-test:latest
58+
shell: bash
59+
60+
# Give the OpenSearch process some time to boot up before sending any requires, might need to increase the default time!
61+
- name: Sleep while OpenSearch finishes starting up
62+
uses: whatnick/wait-action@v0.1.2
63+
with:
64+
time: '30s'
65+
66+
# Capture any output from the OpenSearch process, needed for any troubleshooting if it doesn't boot
67+
- name: Get Docker Logs
68+
if: ${{ inputs.platform != "windows-latest"}}
69+
run: docker logs ops
70+
shell: bash
71+
72+
# Verify that the server is operational
73+
- name: Check OpenSearch Running
74+
if: ${{ inputs.platform != "windows-latest"}}
75+
run: curl -XGET https://localhost:9200 -u 'admin:admin' -k -v
76+
shell: bash

0 commit comments

Comments
 (0)