Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Workflow Consistency / Simplification Updates in Windows and RPM (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterzhuamazon committed Aug 11, 2020
1 parent 5db6d20 commit f6d4780
Show file tree
Hide file tree
Showing 7 changed files with 375 additions and 282 deletions.
127 changes: 64 additions & 63 deletions .github/scripts/setup_runners_service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This script allows users to manually assign parameters
if [ "$#" -ne 2 ] || [ "$1" = "--help" ] || [ "$1" = "-h" ]
then
echo "Please assign a2 parameters when running this script"
echo "Please assign 2 parameters when running this script"
echo "Example: $0 \$SETUP_DISTRO \$SETUP_ACTION"
echo "Example: $0 \"tar | deb | rpm\" \"--es | --es-nosec | --kibana | --kibana-nosec\""
exit 1
Expand All @@ -25,6 +25,7 @@ ES_VERSION=`python $REPO_ROOT/bin/version-info --es`

echo "############################################################"
echo "Setup ES/KIBANA to start with YES/NO security configurations"
echo "User enters $SETUP_ACTION"
echo "############################################################"

echo "setup parameters"
Expand All @@ -36,7 +37,7 @@ if [ "$SETUP_DISTRO" = "tar" ]
then
mkdir -p odfe-testing
cd odfe-testing
aws s3 cp s3://artifacts.opendistroforelasticsearch.amazon.com/downloads/tarball/opendistro-elasticsearch/opendistroforelasticsearch-$OD_VERSION.tar.gz .
aws s3 cp s3://artifacts.opendistroforelasticsearch.amazon.com/downloads/tarball/opendistro-elasticsearch/opendistroforelasticsearch-$OD_VERSION.tar.gz . --quiet; echo $?
tar -zxf opendistroforelasticsearch-$OD_VERSION.tar.gz
cd opendistroforelasticsearch-$OD_VERSION
fi
Expand All @@ -59,129 +60,129 @@ then
sudo yum install opendistroforelasticsearch-$OD_VERSION -y
fi



#####################################################################################################

echo "setup es"

# everything needs es
if [ "$SETUP_DISTRO" = "tar" ]
then
sed -i /install_demo_configuration/d opendistro-tar-install.sh
sed -i '/http\.port/s/^# *//' config/elasticsearch.yml
nohup ./opendistro-tar-install.sh &
else
sudo mkdir -p /home/repo
sudo chmod 777 /home/repo
sudo chmod 777 /etc/elasticsearch/elasticsearch.yml
sudo sed -i '/path.logs/a path.repo: ["/home/repo"]' /etc/elasticsearch/elasticsearch.yml
sudo sed -i /^node.max_local_storage_nodes/d /etc/elasticsearch/elasticsearch.yml
sudo systemctl restart elasticsearch.service
fi

if [ "$SETUP_ACTION" = "--es" ]
then
if [ "$SETUP_DISTRO" = "tar" ]
then
nohup ./opendistro-tar-install.sh &
sleep 45
exit 0
else
sudo systemctl restart elasticsearch.service
sleep 30
exit 0
fi
sleep 60
curl -XGET https://localhost:9200 -u admin:admin --insecure
echo "es start"
cd $REPO_ROOT
exit 0
fi

#####################################################################################################

echo "remove es security"
if [ "$SETUP_DISTRO" = "tar" ]
# *nosec remove es-security
if [ "$SETUP_ACTION" = "--es-nosec" ] || [ "$SETUP_ACTION" = "--kibana-nosec" ]
then
./bin/elasticsearch-plugin remove opendistro_security
else
sudo /usr/share/elasticsearch/bin/elasticsearch-plugin remove opendistro_security
sudo sed -i /^opendistro_security/d /etc/elasticsearch/elasticsearch.yml
sudo sed -i /CN=kirk/d /etc/elasticsearch/elasticsearch.yml
sudo sed -i /^cluster.routing.allocation.disk.threshold_enabled/d /etc/elasticsearch/elasticsearch.yml
fi
echo "remove es security"

if [ "$SETUP_ACTION" = "--es-nosec" ]
then
if [ "$SETUP_DISTRO" = "tar" ]
then
./bin/elasticsearch-plugin remove opendistro_security
nohup ./opendistro-tar-install.sh &
sleep 45
exit 0
else
sudo /usr/share/elasticsearch/bin/elasticsearch-plugin remove opendistro_security
sudo sed -i /^opendistro_security/d /etc/elasticsearch/elasticsearch.yml
sudo sed -i /CN=kirk/d /etc/elasticsearch/elasticsearch.yml
sudo sed -i /^cluster.routing.allocation.disk.threshold_enabled/d /etc/elasticsearch/elasticsearch.yml
sudo systemctl restart elasticsearch.service
sleep 30
exit 0
fi
fi

#####################################################################################################

echo "setup kibana"
if [ "$SETUP_DISTRO" = "tar" ]
if [ "$SETUP_ACTION" = "--es-nosec" ]
then
cd ../../
mkdir -p kibana-testing
cd kibana-testing
aws s3 cp s3://artifacts.opendistroforelasticsearch.amazon.com/downloads/tarball/opendistroforelasticsearch-kibana/opendistroforelasticsearch-kibana-$odfe_version.tar.gz .
tar -zxf opendistroforelasticsearch-kibana-$odfe_version.tar.gz
cd opendistroforelasticsearch-kibana
sed -i /install_demo_configuration/d opendistro-tar-install.sh
else
sudo apt install opendistroforelasticsearch-kibana-$OD_VERSION -y || sudo yum install opendistroforelasticsearch-kibana-$OD_VERSION -y
sleep 60
curl -XGET http://localhost:9200
echo "es-nosec start"
cd $REPO_ROOT
exit 0
fi

if [ "$SETUP_ACTION" = "--kibana" ]
#####################################################################################################

# kibana* needs kibana
if [ "$SETUP_ACTION" = "--kibana" ] || [ "$SETUP_ACTION" = "--kibana-nosec" ]
then
echo "setup kibana"

if [ "$SETUP_DISTRO" = "tar" ]
then
cd ../../
mkdir -p kibana-testing
cd kibana-testing
aws s3 cp s3://artifacts.opendistroforelasticsearch.amazon.com/downloads/tarball/opendistroforelasticsearch-kibana/opendistroforelasticsearch-kibana-$odfe_version.tar.gz . --quiet; echo $?
tar -zxf opendistroforelasticsearch-kibana-$odfe_version.tar.gz
cd opendistroforelasticsearch-kibana
sed -i /install_demo_configuration/d opendistro-tar-install.sh
cd ../../odfe-testing
nohup ./opendistro-tar-install.sh &
sleep 45
cd ../../kibana-testing
nohup ./bin/kibana &
sleep 120
exit 0
else
sudo apt install opendistroforelasticsearch-kibana-$OD_VERSION -y || sudo yum install opendistroforelasticsearch-kibana-$OD_VERSION -y
sudo systemctl restart elasticsearch.service
sudo systemctl restart kibana.service
sleep 120
exit 0
fi
fi

#####################################################################################################

echo "remove kibana security"
if [ "$SETUP_DISTRO" = "tar" ]
if [ "$SETUP_ACTION" = "--kibana" ]
then
./bin/kibana-plugin remove opendistro_security
sed -i /^opendistro_security/d ./config/kibana.yml
sed -i 's/https/http/' ./config/kibana.yml
else
sudo /usr/share/kibana/bin/kibana-plugin remove opendistro_security --allow-root
sudo sed -i /^opendistro_security/d /etc/kibana/kibana.yml
sudo sed -i 's/https/http/' /etc/kibana/kibana.yml
sleep 120
curl -XGET https://localhost:9200 -u admin:admin --insecure
curl -v -XGET https://localhost:5601 --insecure
echo "es & kibana start"
cd $REPO_ROOT
exit 0
fi

#####################################################################################################

# kibana-nosec remove kibana-security
if [ "$SETUP_ACTION" = "--kibana-nosec" ]
then
echo "remove kibana security"

if [ "$SETUP_DISTRO" = "tar" ]
then
./bin/kibana-plugin remove opendistro_security
sed -i /^opendistro_security/d ./config/kibana.yml
sed -i 's/https/http/' ./config/kibana.yml
cd ../../odfe-testing
nohup ./opendistro-tar-install.sh &
sleep 45
cd ../../kibana-testing
nohup ./bin/kibana &
sleep 120
exit 0
else
sudo /usr/share/kibana/bin/kibana-plugin remove opendistro_security --allow-root
sudo sed -i /^opendistro_security/d /etc/kibana/kibana.yml
sudo sed -i 's/https/http/' /etc/kibana/kibana.yml
sudo systemctl restart elasticsearch.service
sudo systemctl restart kibana.service
fi

sleep 120
curl -XGET http://localhost:9200
curl -v -XGET http://localhost:5601
echo "es & kibana-nosec start"
cd $REPO_ROOT
exit 0
fi
fi

140 changes: 140 additions & 0 deletions .github/scripts/setup_runners_service_windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
#!/usr/bin/env pwsh

# Keep the pwsh script running even with errors
#$ErrorActionPreference = 'SilentlyContinue'

# setup user parameters
$SETUP_ACTION=$args[0]
if (!$SETUP_ACTION) {
echo "Please enter 1 parameter: --es | --es-nosec | --kibana | --kibana-nosec"
exit 1
}

echo "############################################################"
echo "Setup ES/KIBANA to start with YES/NO security configurations"
echo "User enters $SETUP_ACTION"
echo "############################################################"

echo "setup es"
dir
python -m pip install --upgrade pip
echo pip3 -version
pip3 install awscli
$PACKAGE="opendistroforelasticsearch"
$OD_VERSION=$(python ./bin/version-info --od)
$S3_PACKAGE="odfe-"+$OD_VERSION+".zip"
dir

###############################################################

# everyone needs es
echo "downloading zip from S3"
aws s3 cp s3://artifacts.opendistroforelasticsearch.amazon.com/downloads/odfe-windows/staging/odfe-window-zip/$S3_PACKAGE . --quiet; echo $?\
echo "unzipping $S3_PACKAGE"
unzip -qq .\$S3_PACKAGE

if ($SETUP_ACTION -eq "--es"){
echo "removing useless config" #deprecated since 7.8.0 and will crash --es-nosec now
findstr /V "node.max_local_storage_nodes" .\$PACKAGE-$OD_VERSION\config\elasticsearch.yml > .\$PACKAGE-$OD_VERSION\config\elasticsearch.yml.new
del .\$PACKAGE-$OD_VERSION\config\elasticsearch.yml
move .\$PACKAGE-$OD_VERSION\config\elasticsearch.yml.new .\$PACKAGE-$OD_VERSION\config\elasticsearch.yml
type .\$PACKAGE-$OD_VERSION\config\elasticsearch.yml

echo "running es"
nohup .\$PACKAGE-$OD_VERSION\bin\elasticsearch.bat &

echo "Waiting for 60 seconds"
ping -n 60 127.0.0.1 >.\out.txt
curl -XGET https://localhost:9200 -u admin:admin --insecure

echo "es start"
exit 0
}

###############################################################

# *nosec remove es-security
if ($SETUP_ACTION -eq "--es-nosec" -Or $SETUP_ACTION -eq "--kibana-nosec"){
echo "removing es security"
cd $PACKAGE-$OD_VERSION\bin
.\elasticsearch-plugin.bat remove opendistro_security
cd ..\..

echo "Overriding with elasticsearch.yml having no certificates"
del .\$PACKAGE-$OD_VERSION\config\elasticsearch.yml
aws s3 cp s3://artifacts.opendistroforelasticsearch.amazon.com/downloads/utils/elasticsearch.yml .\$PACKAGE-$OD_VERSION\config --quiet; echo $?
}

if ($SETUP_ACTION -eq "--es-nosec"){
echo "running es"
nohup .\$PACKAGE-$OD_VERSION\bin\elasticsearch.bat &

echo "Waiting for 60 seconds"
ping -n 60 127.0.0.1 >.\out.txt
curl -XGET http://localhost:9200

echo "es-nosec start"
exit 0
}

###############################################################

# kibana* needs kibana
if ($SETUP_ACTION -eq "--kibana" -Or $SETUP_ACTION -eq "--kibana-nosec"){
echo "setup kibana"
mkdir kibana-it-test
cd kibana-it-test
$S3_KIBANA_PACKAGE="odfe-"+$OD_VERSION+"-kibana.zip"
aws s3 cp --quiet s3://artifacts.opendistroforelasticsearch.amazon.com/downloads/odfe-windows/ode-windows-zip/$S3_KIBANA_PACKAGE . --quiet; echo $?\
unzip -qq .\$S3_KIBANA_PACKAGE
}

if ($SETUP_ACTION -eq "--kibana"){
cd ..

echo "running es"
nohup .\$PACKAGE-$OD_VERSION\bin\elasticsearch.bat &

echo "running kibana"
cd kibana-it-test\opendistroforelasticsearch-kibana
nohup .\bin\kibana.bat &
cd ..\..

echo "Waiting for 120 seconds"
ping -n 120 127.0.0.1 >.\out.txt
curl -XGET https://localhost:9200 -u admin:admin --insecure
curl -v -XGET https://localhost:5601 --insecure

echo "kibana start"
exit 0
}

###############################################################

# kibana-nosec remove kibana-security
if ($SETUP_ACTION -eq "--kibana-nosec"){
echo "removing kibana security"
cd opendistroforelasticsearch-kibana
.\bin\kibana-plugin.bat remove opendistro_security
del .\config\kibana.yml
aws s3 cp s3://artifacts.opendistroforelasticsearch.amazon.com/downloads/utils/kibana-config-without-security/kibana.yml .\config --quiet; echo $?

cd ..\..

echo "running es"
nohup .\$PACKAGE-$OD_VERSION\bin\elasticsearch.bat &

echo "running kibana"
cd kibana-it-test\opendistroforelasticsearch-kibana
nohup .\bin\kibana.bat &
cd ..\..

echo "Waiting for 120 seconds"
ping -n 120 127.0.0.1 >.\out.txt
curl -XGET http://localhost:9200
curl -v -XGET http://localhost:5601

echo "kibana-nosec start"
exit 0
}

Loading

0 comments on commit f6d4780

Please sign in to comment.