Skip to content

Commit

Permalink
[#682] add ansible debug run check
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-semenets committed Dec 26, 2018
1 parent abbb6cd commit 969a2a6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
4 changes: 4 additions & 0 deletions deploy/create-cluster.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ pipeline {

//Job parameters
sharedLibPath = "deploy/legionPipeline.groovy"
ansibleHome = "/opt/legion/deploy/ansible"
ansibleVerbose = ''
helmLocalSource = ''
}

stages {
Expand All @@ -30,6 +33,7 @@ pipeline {
stage('Create Kubernetes Cluster') {
steps {
script {
legion.ansibleDebugRunCheck(env.param_debug_run)
legion.createCluster()
}
}
Expand Down
23 changes: 13 additions & 10 deletions deploy/legionPipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,32 @@ def buildDescription(){
currentBuild.description = "${env.param_profile} ${env.param_git_branch}"
}

def ansibleDebugRunCheck(debugRun) {
if (debugRun == "true" ) {
env.ansibleHome = "${WORKSPACE}/deploy/ansible"
env.ansibleVerbose = '-vvv'
env.helmLocalSource = 'helm_local_source=true'
}
}

def createCluster() {
def verbose = ("${param_debug_run}" == 'true') ? '-vvv' : ''
withCredentials([
file(credentialsId: "vault-${env.param_profile}", variable: 'vault')]) {
withAWS(credentials: 'kops') {
wrap([$class: 'AnsiColorBuildWrapper', colorMapName: "xterm"]) {
docker.image("${env.param_docker_repo}/k8s-ansible:${env.param_legion_version}").inside("-e HOME=/opt/deploy/legion -v ${WORKSPACE}/deploy/profiles:/opt/legion/deploy/profiles -v /etc/ssl:/etc/ssl -u root") {
docker.image("${env.param_docker_repo}/k8s-ansible:${env.param_legion_version}").inside("-e HOME=${env.ansibleHome} -v ${WORKSPACE}/deploy/profiles:/opt/legion/deploy/profiles -v /etc/ssl:/etc/ssl -u root") {
stage('Create cluster') {
sh """
set -e
# Run ansible from workspace for debug or from baked code inside container
if [ ${param_debug_run} = 'true' ]; then
cd ${WORKSPACE}/deploy/ansible
else
cd /opt/legion/deploy/ansible
fi
cd ${env.ansibleHome} && \
ansible-playbook create-cluster.yml \
${verbose} \
${env.ansibleVerbose} \
--vault-password-file=${vault} \
--extra-vars "profile=${env.param_profile} \
legion_version=${env.param_legion_version} \
skip_kops=${env.param_skip_kops} \
helm_repo=${env.param_helm_repo}"
helm_repo=${env.param_helm_repo}" \
${env.helmLocalSource}
"""
}
}
Expand Down

0 comments on commit 969a2a6

Please sign in to comment.