-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add install_demo_configuration Batch script for Windows #2161
Add install_demo_configuration Batch script for Windows #2161
Conversation
Thanks @cwperks adding this to backport 2.x. |
Codecov Report
@@ Coverage Diff @@
## main #2161 +/- ##
============================================
+ Coverage 61.02% 61.15% +0.13%
- Complexity 3233 3239 +6
============================================
Files 257 258 +1
Lines 18110 18110
Branches 3229 3224 -5
============================================
+ Hits 11052 11076 +24
+ Misses 5476 5456 -20
+ Partials 1582 1578 -4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets update the plugin_install.yml to deploy OpenSearch windows and test this new script.
Good idea - I will see what it takes to add this to the github workflow. |
Signed-off-by: Stephen Crawford <[email protected]>
Plugin install currently runs on Ubuntu. In that case we will have to add a new workflow for windows. |
0e3319c
to
ca93b26
Compare
Signed-off-by: Stephen Crawford <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
c0b6cf8
to
53839ae
Compare
Windows plugin install
.github/workflows/plugin_install.yml
Outdated
- name: Download OpenSearch Core | ||
run: | | ||
cd .. | ||
Invoke-WebRequest https://artifacts.opensearch.org/snapshots/core/opensearch/2.4.0-SNAPSHOT/opensearch-min-2.4.0-SNAPSHOT-windows-x64-latest.zip -Outfile opensearch-2.4.0.zip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@scrawfor99 - Is it possible to get this value from gradle properties like the linux-install
?
If not, then I think plugin_install.yml
needs to be added to the version increment automation here: https://github.com/opensearch-project/security/blob/main/build.gradle#L602-L605
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently there is not a great option for doing this. It is possible but Powershell is not as friendly about it as Unix. I can work on it if you would like however.
Signed-off-by: Stephen Crawford <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
@opensearch-project/security This PR is now ready for further review. Thank you @scrawfor99 for figuring out how to automate the validation of this change by adding a new job in Note: For the merge into main we are disabling this job because the distribution for 3.0.0 is not stable and the node does not get brought up successfully. This job will be enabled in 2.x when this change is backported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! I would prefer we addressed the comments I've added as they would lower the amount of work/changes we need to do after merging and getting this running in the 2.4 branch much cleaner.
Please take a look at them if you think it would be better to handle out of band and file another issue for follow up
$encodedCredentials = [Convert]::ToBase64String($credentialBytes) | ||
$baseCredentials = "Basic $encodedCredentials" | ||
$Headers = @{ Authorization = $baseCredentials } | ||
Invoke-WebRequest -SkipCertificateCheck -Uri 'https://localhost:9200' -Headers $Headers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Save some code and rewrite as Invoke-WebRequest -SkipCertificateCheck -Uri 'https://admin:admin@localhost:9200'
, worked when I tried it locally. More details on this format [1]
- name: Download OpenSearch Core | ||
run: | | ||
cd .. | ||
Invoke-WebRequest https://artifacts.opensearch.org/snapshots/core/opensearch/3.0.0-SNAPSHOT/opensearch-min-3.0.0-SNAPSHOT-windows-x64-latest.zip -Outfile opensearch-3.0.0.zip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we replace all the references to 3.0.0 with something like ${{ env.OPENSEARCH_VERSION }}
, see how this can be set for the job with the env
[1]
[1] https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#env
.github/workflows/plugin_install.yml
Outdated
run: ./gradlew integTestRemote -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername="opensearch" -Dhttps=true -Duser=admin -Dpassword=admin | ||
|
||
windows-install: | ||
if: ${{ false }} # disable for now - no stable distribution for 3.0.0 yet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a link to the issue associated with this failure
Note; we should create an issue in our repo to re-enable
- name: Run OpenSearch with plugin | ||
run: | | ||
cd .. | ||
start .\Opensearch\bin\opensearch.bat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have a way to get the logs from the process in cases it doesn't come up like in the linux version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note; this is a good candidate for a follow up issue
@peterzhuamazon Tagging in case you know someone who can help answer a problem we are facing. As part of this PR to add the batch script for We are currently facing a problem where the opensearch node does not startup (the command In the linux install we add a user and run with the newly created user. It looks like the corresponding windows commands would be:
but The github action we created works on 2.x, but not on 3.0. It only works on 2.x because this PR (opensearch-project/OpenSearch#4656) has not yet been backported to 2.x. |
At one point in time there may have been something similar to:
in Bootstrap.java, but there is no such option. I'm not sure if it helps, but github's documentation says UAC is disabled on the runners. See https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#administrative-privileges Ideally, the workflow creates a user |
Signed-off-by: Craig Perkins <[email protected]>
@opensearch-project/security The new plugin-install job on windows is working now after the revert from core and new snapshot distribution. This is ready to be reviewed again - there is a link to a snapshot distribution that will need to be updated when an official distro is published. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥳
Removing the old |
Signed-off-by: Craig Perkins <[email protected]> Signed-off-by: Stephen Crawford <[email protected]> Co-authored-by: Stephen Crawford <[email protected]> Co-authored-by: Stephen Crawford <[email protected]> (cherry picked from commit 45c766f)
#2203) * Add install_demo_configuration Batch script for Windows (#2161) Signed-off-by: Craig Perkins <[email protected]> Signed-off-by: Stephen Crawford <[email protected]> Co-authored-by: Stephen Crawford <[email protected]> Co-authored-by: Stephen Crawford <[email protected]> (cherry picked from commit 45c766f) * Change to 2.4.0 for the min url Signed-off-by: Peter Zhu <[email protected]> Signed-off-by: Peter Zhu <[email protected]> Co-authored-by: Craig Perkins <[email protected]> Co-authored-by: Peter Zhu <[email protected]>
Tried a few more things, documented here |
@dbwiddis I have also been trying with psexec here: main...cwperks:security:windows-debugging#diff-3e971aab38c741b1cb89584068ce23192213a18b1ecc885ac7b450bf5a5bb86eR85-R140 and it feels like its close to a breakthrough, but the swallowing of the output is causing difficulty. I plan to return to this issue so that we can re-apply your change of enforcing that the node does not start with escalated privileges. |
Thank you @dbwiddis. I saw your comment this morning and was trying to apply it on this branch https://github.com/cwperks/security/tree/windows-paexec but have still been unsuccessful in bringing up the node. I am able to use both psexec and paexec on a windows computer, but still struggling within the github runner. |
I found that having the Specifically: Also set the working directory using |
https://stackoverflow.com/questions/148968/windows-batch-files-bat-vs-cmd Seems like not that much differences? Thanks. |
I suspect it was the error value difference that I saw... |
opensearch-project#2203) * Add install_demo_configuration Batch script for Windows (opensearch-project#2161) Signed-off-by: Craig Perkins <[email protected]> Signed-off-by: Stephen Crawford <[email protected]> Co-authored-by: Stephen Crawford <[email protected]> Co-authored-by: Stephen Crawford <[email protected]> (cherry picked from commit 45c766f) * Change to 2.4.0 for the min url Signed-off-by: Peter Zhu <[email protected]> Signed-off-by: Peter Zhu <[email protected]> Co-authored-by: Craig Perkins <[email protected]> Co-authored-by: Peter Zhu <[email protected]>
…roject#2161) Signed-off-by: Craig Perkins <[email protected]> Signed-off-by: Stephen Crawford <[email protected]> Co-authored-by: Stephen Crawford <[email protected]> Co-authored-by: Stephen Crawford <[email protected]> Signed-off-by: Stephen Crawford <[email protected]>
opensearch-project#2203) * Add install_demo_configuration Batch script for Windows (opensearch-project#2161) Signed-off-by: Craig Perkins <[email protected]> Signed-off-by: Stephen Crawford <[email protected]> Co-authored-by: Stephen Crawford <[email protected]> Co-authored-by: Stephen Crawford <[email protected]> (cherry picked from commit 45c766f) * Change to 2.4.0 for the min url Signed-off-by: Peter Zhu <[email protected]> Signed-off-by: Peter Zhu <[email protected]> Co-authored-by: Craig Perkins <[email protected]> Co-authored-by: Peter Zhu <[email protected]> Signed-off-by: Stephen Crawford <[email protected]>
opensearch-project#2203) * Add install_demo_configuration Batch script for Windows (opensearch-project#2161) Signed-off-by: Craig Perkins <[email protected]> Signed-off-by: Stephen Crawford <[email protected]> Co-authored-by: Stephen Crawford <[email protected]> Co-authored-by: Stephen Crawford <[email protected]> (cherry picked from commit 45c766f) * Change to 2.4.0 for the min url Signed-off-by: Peter Zhu <[email protected]> Signed-off-by: Peter Zhu <[email protected]> Co-authored-by: Craig Perkins <[email protected]> Co-authored-by: Peter Zhu <[email protected]> Signed-off-by: Stephen Crawford <[email protected]>
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.3 1.3
# Navigate to the new working tree
cd .worktrees/backport-1.3
# Create a new branch
git switch --create backport/backport-2161-to-1.3
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 45c766f5b98bb88b642d0c7fbccb32653213c300
# Push it to GitHub
git push --set-upstream origin backport/backport-2161-to-1.3
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.3 Then, create a pull request where the |
opensearch-project#2203) * Add install_demo_configuration Batch script for Windows (opensearch-project#2161) Signed-off-by: Craig Perkins <[email protected]> Signed-off-by: Stephen Crawford <[email protected]> Co-authored-by: Stephen Crawford <[email protected]> Co-authored-by: Stephen Crawford <[email protected]> (cherry picked from commit 45c766f) * Change to 2.4.0 for the min url Signed-off-by: Peter Zhu <[email protected]> Signed-off-by: Peter Zhu <[email protected]> Co-authored-by: Craig Perkins <[email protected]> Co-authored-by: Peter Zhu <[email protected]>
Description
As part of the effort to support windows distribution in 2.4.0 (opensearch-project/opensearch-build#33) the security plugin needs a script to install the demo configuration on windows.
This PR introduces
install_demo_configuration.bat
with the same functionality as the bash script and installs the demo certificates and adds default config lines toopensearch.yml
Enhancement
Issues Resolved
#2148
Testing
Tested by going through the steps outlined on opensearch-project/opensearch-build#33.
Replace step 6 with
cd plugins/opensearch-security/tools & ./install_demo_configuration.bat
Screenshot below shows using
https
and logging in with admin account credentials:Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.