Fix VM extension script for spinnaker and Jenkins setup (#80)
* Update run-cli-command.sh Update run-cli-command.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update install_jenkins.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update init-aptly-repo.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update install_jenkins.sh Update install_jenkins.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update install_jenkins.sh Update install_jenkins.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update install_halyard.sh Update install_halyard.sh Update install_halyard.sh Update install_halyard.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update install_halyard.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update install_halyard.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update install_jenkins.sh Update run-cli-command.sh Update 301-jenkins-aptly-spinnaker-vmss.sh Update basic-docker-build.groovy hushifu Update install_halyard.sh shankongge aaa hh hh b * Fix following scripts * `add-aptly-build-job.sh` * Use work-around github url * `301-jenkins-aptly-spinnaker-vmss.sh` * Fix the bug that dollar sign in password will break the pipe. * Add conditional check before restarting the services * `install_halyard.sh` * Determine the latest version by get the last version number in `hal version list` command output * Refine code
This commit is contained in:
Родитель
aaedcd739f
Коммит
56a874388e
|
@ -42,7 +42,7 @@ job_display_name="Sample Aptly Job"
|
|||
job_description="A basic pipeline that builds a debian package and pushes it to an Aptly repository hosted on the Jenkins VM."
|
||||
repository_name="hello-karyon-rxnetty"
|
||||
artifacts_location="https://raw.githubusercontent.com/Azure/azure-devops-utils/master/"
|
||||
git_url="https://github.com/azure-devops/hello-karyon-rxnetty.git"
|
||||
git_url="https://github.com/mybayern1974/hello-karyon-rxnetty.git"
|
||||
|
||||
while [[ $# > 0 ]]
|
||||
do
|
||||
|
|
|
@ -50,7 +50,7 @@ throw_if_empty repository_name $repository_name
|
|||
echo "deb http://repo.aptly.info/ squeeze main" | sudo tee -a "/etc/apt/sources.list" > /dev/null
|
||||
sudo apt-key adv --keyserver keys.gnupg.net --recv-keys 9E3E53F19C7DE460
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get update --yes
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get install aptly --yes
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get install aptly --force-yes --yes
|
||||
|
||||
# Create default aptly repository
|
||||
sudo su -c "aptly repo create $repository_name" jenkins
|
||||
|
|
|
@ -16,7 +16,6 @@ Arguments
|
|||
--vault_name|-vn [Required]: Vault used to store default Username/Password for deployed VMSS
|
||||
--storage_account_name|-san [Required]: Storage account name used for front50
|
||||
--storage_account_key|-sak [Required]: Storage account key used for front50
|
||||
--packer_storage_account|-psa [Required]: Storage account name used for baked images
|
||||
--vm_fqdn|-vf [Required]: FQDN for the Jenkins instance hosting the Aptly repository
|
||||
--region|-r : Region for VMSS created by Spinnaker, defaulted to westus
|
||||
--artifacts_location|-al : Url used to reference other scripts/artifacts.
|
||||
|
@ -50,7 +49,6 @@ region="westus"
|
|||
repository_name="hello-karyon-rxnetty"
|
||||
artifacts_location="https://raw.githubusercontent.com/Azure/azure-devops-utils/master/"
|
||||
artifacts_location_sas_token=""
|
||||
front50_port="8081"
|
||||
|
||||
while [[ $# > 0 ]]
|
||||
do
|
||||
|
@ -77,8 +75,6 @@ do
|
|||
storage_account_name="$1";;
|
||||
--storage_account_key|-sak)
|
||||
storage_account_key="$1";;
|
||||
--packer_storage_account|-psa)
|
||||
packer_storage_account="$1";;
|
||||
--region|-r)
|
||||
region="$1";;
|
||||
--vm_fqdn|-vf)
|
||||
|
@ -107,14 +103,12 @@ throw_if_empty resource_group $resource_group
|
|||
throw_if_empty vault_name $vault_name
|
||||
throw_if_empty storage_account_name $storage_account_name
|
||||
throw_if_empty storage_account_key $storage_account_key
|
||||
throw_if_empty packer_storage_account $packer_storage_account
|
||||
throw_if_empty vm_fqdn $vm_fqdn
|
||||
throw_if_empty region $region
|
||||
|
||||
default_hal_config="/home/$jenkins_username/.hal/default"
|
||||
|
||||
run_util_script "spinnaker/install_halyard/install_halyard.sh" -san "$storage_account_name" -sak "$storage_account_key" -u "$jenkins_username"
|
||||
|
||||
# Change front50 port so it doesn't conflict with Jenkins
|
||||
front50_settings="$default_hal_config/service-settings/front50.yml"
|
||||
sudo -u $jenkins_username mkdir -p $(dirname "$front50_settings")
|
||||
|
@ -129,8 +123,13 @@ echo "$app_key" | hal config provider azure account add my-azure-account \
|
|||
--default-key-vault "$vault_name" \
|
||||
--default-resource-group "$resource_group" \
|
||||
--packer-resource-group "$resource_group" \
|
||||
--packer-storage-account "$packer_storage_account" \
|
||||
--app-key
|
||||
|
||||
#change region if region not in eastus or westus
|
||||
if [ "$region" != eastus ] && [ "$region" != westus ]; then
|
||||
hal config provider azure account edit my-azure-account \
|
||||
--regions "eastus","westus","$region"
|
||||
fi
|
||||
hal config provider azure enable
|
||||
|
||||
# Configure Rosco (these params are not supported by Halyard yet)
|
||||
|
@ -144,7 +143,7 @@ EOF
|
|||
|
||||
# Configure Jenkins for Spinnaker
|
||||
echo "$jenkins_password" | hal config ci jenkins master add Jenkins \
|
||||
--address "http://localhost:8080" \
|
||||
--address "http://localhost:8082" \
|
||||
--username "$jenkins_username" \
|
||||
--password
|
||||
hal config ci jenkins enable
|
||||
|
@ -159,10 +158,53 @@ run_util_script "jenkins/init-aptly-repo.sh" -vf "${vm_fqdn}" -rn "${repository_
|
|||
run_util_script "jenkins/add-aptly-build-job.sh" -al "${artifacts_location}" -st "${artifacts_location_sas_token}"
|
||||
|
||||
echo "Setting up initial user..."
|
||||
echo "jenkins.model.Jenkins.instance.securityRealm.createAccount(\"$jenkins_username\", \"$jenkins_password\")" > addUser.groovy
|
||||
|
||||
# Using single quote for username and password here to avoid dollar sign being recognized as start of variable
|
||||
echo "jenkins.model.Jenkins.instance.securityRealm.createAccount('$jenkins_username', '$jenkins_password')" > addUser.groovy
|
||||
run_util_script "jenkins/run-cli-command.sh" -cif "addUser.groovy" -c "groovy ="
|
||||
rm "addUser.groovy"
|
||||
|
||||
# Change the Jenkins port in order not to conflict with the Spinnaker front50 port
|
||||
port=8082
|
||||
sed -i -e "s/\(HTTP_PORT=\).*/\1$port/" /etc/default/jenkins
|
||||
service jenkins restart
|
||||
|
||||
# If redis is not started, start the redis-server
|
||||
netstat -tln | grep ":6379 "
|
||||
|
||||
if [ $? -eq 1 ]
|
||||
then
|
||||
echo "Redis is not started. Start the redis-server."
|
||||
sudo redis-server /etc/redis/redis.conf
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
# Double check and log if redis is still not running
|
||||
netstat -tln | grep ":6379 "
|
||||
|
||||
if [ $? -eq 1 ]
|
||||
then
|
||||
echo "Redis failed to start for second time. Related spinnaker micro-services might fail to start."
|
||||
fi
|
||||
|
||||
netstat -tln | grep ":8083 "
|
||||
if [ $? -eq 1 ]
|
||||
then
|
||||
sudo systemctl restart orca.service
|
||||
fi
|
||||
|
||||
netstat -tln | grep ":8080 "
|
||||
if [ $? -eq 1 ]
|
||||
then
|
||||
sudo systemctl restart front50.service
|
||||
fi
|
||||
|
||||
netstat -tln | grep ":8084 "
|
||||
if [ $? -eq 1 ]
|
||||
then
|
||||
sudo systemctl restart gate.service
|
||||
fi
|
||||
|
||||
# Wait for Spinnaker services to be up before returning
|
||||
timeout=180
|
||||
echo "while !(nc -z localhost 8084) || !(nc -z localhost 9000); do sleep 1; done" | timeout $timeout bash
|
||||
|
|
|
@ -47,10 +47,13 @@ throw_if_empty storage_account_key $storage_account_key
|
|||
throw_if_empty username $username
|
||||
|
||||
# Install Halyard
|
||||
curl --silent "https://raw.githubusercontent.com/spinnaker/halyard/master/install/stable/InstallHalyard.sh" | sudo bash -s -- --user "$username" -y
|
||||
curl --silent "https://raw.githubusercontent.com/spinnaker/halyard/master/install/debian/InstallHalyard.sh" | sudo bash -s -- --user "$username" -y
|
||||
|
||||
# Get the latest version of spinnaker
|
||||
version=`hal version list | grep -P '\d+\.\d+\.\d+' -o | tail -1`
|
||||
|
||||
# Set Halyard to use the latest released/validated version of Spinnaker
|
||||
hal config version edit --version $(hal version latest -q)
|
||||
hal config version edit --version $version
|
||||
|
||||
# Configure Spinnaker persistent store
|
||||
hal config storage azs edit --storage-account-name "$storage_account_name" --storage-account-key "$storage_account_key"
|
||||
|
|
Загрузка…
Ссылка в новой задаче