-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GitHub Action for plugin install (#2239)
Converts the security plugin install into a git hub action action.yml process instead of a workflow. Signed-off-by: Stephen Crawford <steecraw@amazon.com> Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com>
- Loading branch information
1 parent
943a7da
commit e36d396
Showing
2 changed files
with
146 additions
and
106 deletions.
There are no files selected for viewing
126 changes: 126 additions & 0 deletions
126
.github/actions/start-opensearch-with-one-plugin/action.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
name: 'Start OpenSearch with One Plugin' | ||
description: 'Downloads latest build of OpenSearch, installs a plugin, executes a script and then starts OpenSearch on localhost:9200' | ||
|
||
inputs: | ||
opensearch-version: | ||
description: 'The version of OpenSearch that should be used, e.g "3.0.0"' | ||
required: true | ||
|
||
plugin-name: | ||
description: 'The name of the plugin to use, such as opensearch-security' | ||
required: true | ||
|
||
plugin-start-script: | ||
description: 'The file name for the configuration script for the plugin such as install_demo_configurations -- may not be needed for every plugin' | ||
required: false | ||
|
||
docker-host-plugin-zip: | ||
description: 'The name of the zip file for the plugin hosted on docker-host i.e. security-plugin.zip ' | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
|
||
# Configure longpath names if on Windows | ||
- name: Enable Longpaths if on Windows | ||
if: ${{ runner.os == 'Windows' }} | ||
run: git config --system core.longpaths true | ||
shell: pwsh | ||
|
||
# Download OpenSearch | ||
- uses: peternied/download-file@v1 | ||
if: ${{ runner.os == 'Windows' }} | ||
with: | ||
url: https://artifacts.opensearch.org/snapshots/core/opensearch/${{ inputs.opensearch-version }}-SNAPSHOT/opensearch-min-${{ inputs.opensearch-version }}-SNAPSHOT-windows-x64-latest.zip | ||
|
||
- uses: peternied/download-file@v1 | ||
if: ${{ runner.os == 'Linux' }} | ||
with: | ||
url: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/${{ inputs.opensearch-version }}/latest/linux/x64/tar/builds/opensearch/dist/opensearch-min-${{ inputs.opensearch-version }}-linux-x64.tar.gz | ||
|
||
# Extract downloaded zip | ||
- name: Extract downloaded zip for Linux | ||
if: ${{ runner.os == 'Linux' }} | ||
run: | | ||
tar -xzf opensearch-*.tar.gz | ||
rm -f opensearch-*.tar.gz | ||
shell: bash | ||
|
||
- name: Extract downloaded zip for Windows | ||
if: ${{ runner.os == 'Windows' }} | ||
run: | | ||
tar -xzf opensearch-min-${{ inputs.opensearch-version }}-SNAPSHOT-windows-x64-latest.zip | ||
del opensearch-min-${{ inputs.opensearch-version }}-SNAPSHOT-windows-x64-latest.zip | ||
shell: pwsh | ||
|
||
# Move and rename the plugin for installation | ||
- name: Move and rename the plugin for installation | ||
run: mv ./build/distributions/${{ inputs.plugin-name }}-*.zip ${{ inputs.plugin-name }}.zip | ||
shell: bash | ||
|
||
# Install the plugin, runs its start-script, and start the OpenSearch server | ||
- name: Install Plugin into OpenSearch for Linux | ||
if: ${{ runner.os == 'Linux'}} | ||
run: | | ||
cat > os-ep.sh <<EOF | ||
yes | opensearch-plugin install file:///docker-host/${{ inputs.docker-host-plugin-zip }}.zip | ||
chmod +x plugins/${{ inputs.plugin-name }}/tools/${{ inputs.plugin-start-script }}.sh | ||
yes | plugins/${{ inputs.plugin-name }}/tools/${{ inputs.plugin-start-script }}.sh | ||
chown 1001:1001 -R /opensearch | ||
su -c "/opensearch/bin/opensearch" -s /bin/bash opensearch | ||
EOF | ||
docker build -t opensearch-test -f- . <<EOF | ||
FROM ubuntu:latest | ||
COPY --chown=1001:1001 os-ep.sh /docker-host/ | ||
COPY --chown=1001:1001 ${{ inputs.plugin-name }}.zip /docker-host/${{ inputs.docker-host-plugin-zip }}.zip | ||
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 | ||
shell: bash | ||
|
||
- name: Install Plugin into OpenSearch for Windows | ||
if: ${{ runner.os == 'Windows'}} | ||
run: | | ||
'y' | .\opensearch-${{ inputs.opensearch-version }}-SNAPSHOT\bin\opensearch-plugin.bat install file:$pwd\${{ inputs.plugin-name }}.zip | ||
'y', 'y', 'N' | .\opensearch-${{ inputs.opensearch-version }}-SNAPSHOT\plugins\${{ inputs.plugin-name }}\tools\${{ inputs.plugin-start-script }}.bat | ||
shell: pwsh | ||
|
||
# Run OpenSearch | ||
- name: Run OpenSearch with plugin on Linux | ||
if: ${{ runner.os == 'Linux'}} | ||
run: docker run --name ops -d -p 9200:9200 -p 9600:9600 -i opensearch-test:latest | ||
shell: bash | ||
|
||
- name: Run OpenSearch with plugin on Windows | ||
if: ${{ runner.os == 'Windows'}} | ||
run: start .\opensearch-${{ inputs.opensearch-version }}-SNAPSHOT\bin\opensearch.bat | ||
shell: pwsh | ||
|
||
# Give the OpenSearch process some time to boot up before sending any requires, might need to increase the default time! | ||
- name: Sleep while OpenSearch starts | ||
uses: peternied/action-sleep@v1 | ||
with: | ||
seconds: 30 | ||
|
||
# Verify that the server is operational | ||
- name: Check OpenSearch Running on Linux | ||
if: ${{ runner.os != 'Windows'}} | ||
run: | | ||
docker logs ops | ||
curl https://localhost:9200/_cat/plugins -u 'admin:admin' -k -v | ||
shell: bash | ||
|
||
- name: Check OpenSearch Running on Windows | ||
if: ${{ runner.os == 'Windows'}} | ||
run: | | ||
$credentialBytes = [Text.Encoding]::ASCII.GetBytes("admin:admin") | ||
$encodedCredentials = [Convert]::ToBase64String($credentialBytes) | ||
$baseCredentials = "Basic $encodedCredentials" | ||
$Headers = @{ Authorization = $baseCredentials } | ||
Invoke-WebRequest -SkipCertificateCheck -Uri 'https://localhost:9200/_cat/plugins' -Headers $Headers; | ||
shell: pwsh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters