Created
February 29, 2020 14:34
-
-
Save suhasulun/654dde0679f52dd6bb864e4a6e7b2d4f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def label = "projectname-${UUID.randomUUID().toString()}" | |
podTemplate(label: label, containers: [ | |
containerTemplate(name: 'docker', image: 'docker', command: 'cat', ttyEnabled: true), | |
containerTemplate(name: 'git', image: 'alpine/git', ttyEnabled: true, command: 'cat'), | |
containerTemplate(name: 'terragrunt', image: 'alpine/terragrunt:latest', ttyEnabled: true, command: 'cat'), | |
containerTemplate(name: 'ansible', image: 'suhasulun/devops:ansible', command: 'cat', ttyEnabled: true), | |
], | |
volumes: [ | |
hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'), | |
] | |
) { | |
node(label) { | |
stage('Check running containers') { | |
container('docker') { | |
// example to show you can run docker commands when you mount the socket | |
sh 'hostname' | |
sh 'hostname -i' | |
sh 'docker ps' | |
} | |
} | |
stage('Clone repository') { | |
container('git') { | |
sh 'whoami' | |
sh 'hostname -i' | |
sh 'git clone -b master https://github.com/suhasulun/sqlcluster=automation.git' | |
} | |
} | |
stage('Setup Infrastructure') { | |
container('terragrunt') { | |
dir('terraform/') { | |
sh 'terragrunt get && terragrunt init' | |
sh 'terragrunt plan' | |
sh 'terragrunt apply' | |
} | |
} | |
} | |
stage('Join Domain and Configure Windows Servers') { | |
container('ansible') { | |
dir('ansible/') { | |
sh 'ansible-playbook -i hosts -vv domain.role' | |
} | |
} | |
} | |
stage('Configure and Enable SQL Clustering') { | |
container('ansible') { | |
dir('ansible/') { | |
sh 'ansible-playbook -i hosts -v -e env=${params.environment} main.yml' | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment