Skip to content

Commit

Permalink
Update admin default password in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ElliottKasoar committed Mar 11, 2024
1 parent 1c4014b commit f73b3c2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
5 changes: 3 additions & 2 deletions .ci/opensearch/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ inputs:
description: 'Port where you want to run OpenSearch'
required: false
default: 9200
opensearch_password:
opensearch-initial-admin-password:
description: 'The password for the user admin in your cluster'
required: false
default: 'admin'
default: 'myStrongPassword123!'

runs:
using: 'docker'
Expand All @@ -30,3 +30,4 @@ runs:
NODES: ${{ inputs.nodes }}
PORT: ${{ inputs.port }}
SECURITY_ENABLED: ${{ inputs.security-enabled }}
OPENSEARCH_INITIAL_ADMIN_PASSWORD: ${{ inputs.opensearch-initial-admin-password }}
11 changes: 10 additions & 1 deletion .ci/opensearch/run-opensearch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@ if [[ -z $OPENSEARCH_VERSION ]]; then
exit 1
fi

OPENSEARCH_REQUIRED_VERSION="latest"
# Starting in 2.12.0, security demo configuration script requires an initial admin password
COMPARE_VERSION=`echo $OPENSEARCH_REQUIRED_VERSION $OPENSEARCH_VERSION | tr ' ' '\n' | sort -V | uniq | head -n 1`
if [ "$COMPARE_VERSION" != "$OPENSEARCH_REQUIRED_VERSION" ]; then
OPENSEARCH_INITIAL_ADMIN_PASSWORD="admin"
fi


for (( node=1; node<=${NODES-1}; node++ ))
do
port=$((PORT + $node - 1))

if [[ "$SECURITY_ENABLED" == "true" ]]; then
healthcmd="curl -vvv -s --insecure -u admin:admin --fail https://localhost:$port/_cluster/health || exit 1"
healthcmd="curl -vvv -s --insecure -u admin:$OPENSEARCH_INITIAL_ADMIN_PASSWORD --fail https://localhost:$port/_cluster/health || exit 1"
security=($(cat <<-END
END
Expand All @@ -34,6 +42,7 @@ END
--env discovery.type=single-node \
--env bootstrap.memory_lock=true \
--env "OPENSEARCH_JAVA_OPTS=-Xms4g -Xmx4g" \
--env OPENSEARCH_INITIAL_ADMIN_PASSWORD=$OPENSEARCH_INITIAL_ADMIN_PASSWORD \
"${security[@]}" \
--publish "${port}:${port}" \
--ulimit nofile=65536:65536 \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/opensearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ jobs:
poetry run python -m unittest -v tests
env:
port: 9250
opensearch-version: ${{ matrix.opensearch }}
security_enabled: ${{ matrix.security-enabled }}
6 changes: 5 additions & 1 deletion tests/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ def setUpClass(cls):
cls.security_enabled = os.getenv("security_enabled") == "true"
cls.port = int(os.environ["port"])
cls.host = "localhost"
if os.environ["opensearch-version"] == "latest":
cls.credential = "admin:myStrongPassword123!"
else:
cls.credential = "admin:admin"

logging.basicConfig(level=logging.INFO)

url = f"opensearch://admin:admin@{cls.host}:{cls.port}"
url = f"opensearch://{cls.credential}@{cls.host}:{cls.port}"
if not cls.security_enabled:
url += " --disable_ssl"
try:
Expand Down
6 changes: 5 additions & 1 deletion tests/opensearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ def setUpClass(cls):
cls.security_enabled = os.getenv("security_enabled") == "true"
cls.port = int(os.environ["port"])
cls.host = "localhost"
if os.environ["opensearch-version"] == "latest":
cls.credential = "admin:myStrongPassword123!"
else:
cls.credential = "admin:admin"

logging.basicConfig(level=logging.INFO)

url = f"opensearch://admin:admin@{cls.host}:{cls.port}"
url = f"opensearch://{cls.credential}@{cls.host}:{cls.port}"
try:
abcd = ABCD.from_url(
url,
Expand Down

0 comments on commit f73b3c2

Please sign in to comment.