Skip to content

Commit

Permalink
Prototype action for start-opensearch
Browse files Browse the repository at this point in the history
opensearch-project#2207

Signed-off-by: Peter Nied <petern@amazon.com>
  • Loading branch information
peternied committed Oct 31, 2022
1 parent a57fd0a commit 1b880f4
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/actions/start-opensearch/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: 'Start OpenSearch'
description: 'Downloads latest build of OpenSearch, installs a plugin, executes and script and then starts OpenSearch on localhost:9200'

inputs:
platform:
description: 'What platform is this action running on, e.g. "windows-latest" ? ' # Note we might be able to pull this from environment variables
required: true

opensearch-version:
description: 'The version of OpenSearch that should be used, e.g "3.0.0"'
required: true

plugin-zip-path:
description: 'The the name of the plugin to use, such as security-dashboards-plugin.zip'
required: true

plugin-start-script:
description: 'A script that should be run before starting OpenSearch'
required: true
# plugins/opensearch-security/tools/install_demo_configuration.sh

runs:
using: "composite"
steps:

# Downloads the min version of OpenSearch Core from the latest build
- name: Download OpenSearch Core
if: ${{ inputs.platform != "windows-latest"}}
run: |
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
tar -xzf opensearch-*.tar.gz
rm -f opensearch-*.tar.gz
shell: bash

# Install the plugin, runs its start-script, and start the OpenSearch server
- name: Run OpenSearch with plugin
if: ${{ inputs.platform != "windows-latest"}}
run: |
cat > os-ep.sh <<EOF
yes | opensearch-plugin install file:///docker-host/plugin.zip
chmod +x ${{ inputs.plugin-start-script }}
yes | ${{ inputs.plugin-start-script }}
chown 1001:1001 -R /opensearch
su -c "/opensearch/bin/opensearch" -s /bin/bash opensearch
EOF
docker build -t opensearch-test:latest -f- . <<EOF
FROM ubuntu:latest
COPY --chown=1001:1001 os-ep.sh /docker-host/
COPY --chown=1001:1001 plugin.zip /docker-host/${{ inputs.plugin-zip-path }}
COPY --chown=1001:1001 opensearch* /opensearch/
RUN chmod +x /docker-host/os-ep.sh
RUN useradd -u 1001 -s /sbin/nologin opensearch
ENV PATH="/opensearch/bin:${PATH}"
WORKDIR /opensearch/
ENTRYPOINT /docker-host/os-ep.sh
EOF
docker run --name ops -d -p 9200:9200 -p 9600:9600 -i opensearch-test:latest
shell: bash

# Give the OpenSearch process some time to boot up before sending any requires, might need to increase the default time!
- name: Sleep while OpenSearch finishes starting up
uses: whatnick/wait-action@v0.1.2
with:
time: '30s'

# Capture any output from the OpenSearch process, needed for any troubleshooting if it doesn't boot
- name: Get Docker Logs
if: ${{ inputs.platform != "windows-latest"}}
run: docker logs ops
shell: bash

# Verify that the server is operational
- name: Check OpenSearch Running
if: ${{ inputs.platform != "windows-latest"}}
run: curl -XGET https://localhost:9200 -u 'admin:admin' -k -v
shell: bash

0 comments on commit 1b880f4

Please sign in to comment.