Skip to content

Commit

Permalink
[#682] mount ansible from workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-semenets committed Dec 22, 2018
1 parent 20b6d1f commit 735f64a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 4 additions & 1 deletion deploy/create-cluster.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ pipeline {
param_legion_version = "${params.LegionVersion}"
param_docker_repo = "${params.DockerRepo}"
param_helm_repo = "${params.HelmRepo}"
param_debug_run = "${params.DebugRun}"

//Job parameters
sharedLibPath = "deploy/legionPipeline.groovy"
}
Expand All @@ -28,7 +30,8 @@ pipeline {
stage('Create Kubernetes Cluster') {
steps {
script {
legion.createCluster()
mounts = legion.ansibleContainerMount()
legion.createCluster(mounts)
}
}
}
Expand Down
11 changes: 8 additions & 3 deletions deploy/legionPipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ def buildDescription(){
currentBuild.description = "${env.param_profile} ${env.param_git_branch}"
}

def createCluster() {
def ansibleContainerMount() {
("${param_debug_run}" == "true" ) ? "${WORKSPACE}/deploy:/opt/legion/deploy:/opt/legion/deploy" : "${WORKSPACE}/deploy/profiles:/opt/legion/deploy/profiles"
}

def createCluster(mounts) {
print(mounts)
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=/opt/deploy/legion -v ${mounts} -v /etc/ssl:/etc/ssl -u root") {
stage('Create cluster') {
sh """
cd /opt/legion/deploy/ansible && ansible-playbook create-cluster.yml \
Expand Down Expand Up @@ -63,7 +68,7 @@ def deployLegion() {
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 -u root") {
docker.image("${env.param_docker_repo}/k8s-ansible:${env.param_legion_version}").inside("-e HOME=/opt/deploy/legion -v ${param_debug_run} ? ${WORKSPACE}/deploy:/opt/legion/deploy : ${WORKSPACE}/deploy/profiles:/opt/legion/deploy/profiles -u root") {
stage('Deploy Legion') {
sh """
cd /opt/legion/deploy/ansible && ansible-playbook deploy-legion.yml \
Expand Down

0 comments on commit 735f64a

Please sign in to comment.