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 cb8135e
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 17 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 = '-vvv'
helmLocalRun = 'true'
}

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

def ansibleDebugRunCheck(String debugRun) {
// For run ansible playbooks and helm charts from sources in workspace and use verbose output for debug purposes
if (debugRun == "true" ) {
ansibleHome = "${WORKSPACE}/deploy/ansible"
ansibleVerbose = env.ansibleVerbose
helmLocalRun = env.helmLocalRun
} else {
ansibleHome = env.ansibleHome
ansibleVerbose = ''
helmLocalRun = 'false'
}
}

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=${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 ${ansibleHome} && \
ansible-playbook create-cluster.yml \
${verbose} \
${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} \
helm_local_run=${helmLocalRun}"
"""
}
}
Expand Down
2 changes: 1 addition & 1 deletion deploy/profiles/legion-ci-app.epm.kharlamov.biz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ airflow_rds_size: "50"
# Kops
cluster_name: legion-ci-app.epm.kharlamov.biz
state_store: s3://legion-cluster
cluster_ssh_public_key_path: /opt/deploy/legion/legion_id_rsa.pub
cluster_ssh_public_key_path: "{{ tmp_dir }}/legion_id_rsa.pub"

private_network: '172.31'
cluster_zones:
Expand Down
2 changes: 1 addition & 1 deletion deploy/profiles/legion-ci-infra.epm.kharlamov.biz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ airflow_rds_size: "50"
# Kops
cluster_name: legion-ci-infra.epm.kharlamov.biz
state_store: s3://legion-cluster
cluster_ssh_public_key_path: /opt/deploy/legion/legion_id_rsa.pub
cluster_ssh_public_key_path: "{{ tmp_dir }}/legion_id_rsa.pub"

private_network: '172.31'
cluster_zones:
Expand Down
2 changes: 1 addition & 1 deletion deploy/profiles/legion-ci.epm.kharlamov.biz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ airflow_rds_size: "50"
# Kops
cluster_name: legion-ci.epm.kharlamov.biz
state_store: s3://legion-cluster
cluster_ssh_public_key_path: /opt/deploy/legion/legion_id_rsa.pub
cluster_ssh_public_key_path: "{{ tmp_dir }}/legion_id_rsa.pub"

private_network: '172.31'
cluster_zones:
Expand Down
2 changes: 1 addition & 1 deletion deploy/profiles/legion-demo.epm.kharlamov.biz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ airflow_rds_size: "50"
# Kops
cluster_name: legion-demo.epm.kharlamov.biz
state_store: s3://legion-cluster
cluster_ssh_public_key_path: /opt/deploy/legion/legion_id_rsa.pub
cluster_ssh_public_key_path: "{{ tmp_dir }}/legion_id_rsa.pub"

private_network: '172.31'
cluster_zones:
Expand Down
2 changes: 1 addition & 1 deletion deploy/profiles/legion-dev.epm.kharlamov.biz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ airflow_rds_size: "50"
# Kops
cluster_name: legion-dev.epm.kharlamov.biz
state_store: s3://legion-cluster
cluster_ssh_public_key_path: /opt/deploy/legion/legion_id_rsa.pub
cluster_ssh_public_key_path: "{{ tmp_dir }}/legion_id_rsa.pub"

private_network: '172.31'
cluster_zones:
Expand Down
2 changes: 1 addition & 1 deletion deploy/profiles/legion-test.epm.kharlamov.biz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ airflow_rds_size: "50"
# Kops
cluster_name: legion-test.epm.kharlamov.biz
state_store: s3://legion-cluster
cluster_ssh_public_key_path: /opt/deploy/legion/legion_id_rsa.pub
cluster_ssh_public_key_path: "{{ tmp_dir }}/legion_id_rsa.pub"

private_network: '172.31'
cluster_zones:
Expand Down

0 comments on commit cb8135e

Please sign in to comment.