diff --git a/.github/actions/start-opensearch-with-one-plugin/action.yml b/.github/actions/start-opensearch-with-one-plugins/action.yml similarity index 69% rename from .github/actions/start-opensearch-with-one-plugin/action.yml rename to .github/actions/start-opensearch-with-one-plugins/action.yml index fd7328059c..a00c99e57e 100644 --- a/.github/actions/start-opensearch-with-one-plugin/action.yml +++ b/.github/actions/start-opensearch-with-one-plugins/action.yml @@ -6,18 +6,22 @@ inputs: 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' + plugin-names: + description: 'A comma separated list of plugins to use, such as opensearch-security,opensearch-job-scheduler' required: true setup-script-name: description: 'The name of the setup script you want to run i.e. "setup" (do not include file extension). Leave empty to indicate one should not be run.' required: false - admin-password: - description: 'The admin password uses for the cluster' + security-enabled: + description: 'A boolean indicating whether this workflow is setting up OpenSearch with security' required: true + admin-password: + description: 'The admin password uses for the cluster if security is enabled.' + required: false + runs: using: "composite" steps: @@ -58,17 +62,22 @@ runs: shell: pwsh # Install the plugin - - name: Install Plugin into OpenSearch for Linux + - name: Install Plugin(s) into OpenSearch for Linux if: ${{ runner.os == 'Linux'}} run: | chmod +x ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/bin/opensearch-plugin - /bin/bash -c "yes | ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/bin/opensearch-plugin install file:$(pwd)/${{ inputs.plugin-name }}.zip" + for plugin in ${{ inputs.plugin-names//,/ }}; do + /bin/bash -c "yes | ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/bin/opensearch-plugin install file:$(pwd)/${plugin}.zip" + done shell: bash - - name: Install Plugin into OpenSearch for Windows + - name: Install Plugin(s) 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 + $pluginNames = "${{ inputs.plugin-names }}" -split ',' + foreach ($plugin in $pluginNames) { + 'y' | .\opensearch-${{ inputs.opensearch-version }}-SNAPSHOT\bin\opensearch-plugin.bat install file:$(pwd)\${plugin}.zip + } shell: pwsh # Run any configuration scripts @@ -109,17 +118,28 @@ runs: # Verify that the server is operational - name: Check OpenSearch Running on Linux if: ${{ runner.os != 'Windows'}} - run: curl https://localhost:9200/_cat/plugins -u 'admin:${{ inputs.admin-password }}' -k -v --fail-with-body + run: | + if [ "${{ inputs.security-enabled }}" == "true" ]; then + curl https://localhost:9200/_cat/plugins -u 'admin:${{ inputs.admin-password }}' -k -v --fail-with-body + else + curl http://localhost:9200/_cat/plugins -v + fi shell: bash - name: Check OpenSearch Running on Windows if: ${{ runner.os == 'Windows'}} run: | - $credentialBytes = [Text.Encoding]::ASCII.GetBytes("admin:${{ inputs.admin-password }}") - $encodedCredentials = [Convert]::ToBase64String($credentialBytes) - $baseCredentials = "Basic $encodedCredentials" - $Headers = @{ Authorization = $baseCredentials } - Invoke-WebRequest -SkipCertificateCheck -Uri 'https://localhost:9200/_cat/plugins' -Headers $Headers; + if ("${{ inputs.security-enabled }}" -eq "true") { + $credentialBytes = [Text.Encoding]::ASCII.GetBytes("admin:${{ inputs.admin-password }}") + $encodedCredentials = [Convert]::ToBase64String($credentialBytes) + $baseCredentials = "Basic $encodedCredentials" + $Headers = @{ Authorization = $baseCredentials } + $url = 'https://localhost:9200/_cat/plugins' + } else { + $Headers = @{ } + $url = 'http://localhost:9200/_cat/plugins' + } + Invoke-WebRequest -SkipCertificateCheck -Uri $url -Headers $Headers; shell: pwsh - if: always() diff --git a/.github/workflows/plugin_install.yml b/.github/workflows/plugin_install.yml index b88cfb166f..720ede8c37 100644 --- a/.github/workflows/plugin_install.yml +++ b/.github/workflows/plugin_install.yml @@ -55,12 +55,13 @@ jobs: Get-Content .\setup.bat - name: Run Opensearch with A Single Plugin - uses: ./.github/actions/start-opensearch-with-one-plugin + uses: ./.github/actions/start-opensearch-with-plugins with: opensearch-version: ${{ env.OPENSEARCH_VERSION }} - plugin-name: ${{ env.PLUGIN_NAME }} + plugin-names: ${{ env.PLUGIN_NAME }} setup-script-name: setup admin-password: ${{ steps.random-password.outputs.generated_name }} + security-enabled: true - name: Run sanity tests uses: gradle/gradle-build-action@v3