Create ansible server env var
This commit is contained in:
9
Jenkinsfile
vendored
9
Jenkinsfile
vendored
@@ -1,15 +1,18 @@
|
||||
pipeline {
|
||||
agent any
|
||||
environment {
|
||||
ANSIBLE_SERVER = "167.99.136.157"
|
||||
}
|
||||
stages {
|
||||
stage("copy files to ansible server") {
|
||||
steps {
|
||||
script {
|
||||
echo "copying all neccessary files to ansible control node"
|
||||
sshagent(['ansible-server-key']) {
|
||||
sh "scp -o StrictHostKeyChecking=no ansible/* root@167.99.136.157:/root"
|
||||
sh "scp -o StrictHostKeyChecking=no ansible/* root@${ANSIBLE_SERVER}:/root"
|
||||
|
||||
withCredentials([sshUserPrivateKey(credentialsId: 'ec2-server-key', keyFileVariable: 'keyfile', usernameVariable: 'user')]) {
|
||||
sh 'scp $keyfile root@167.99.136.157:/root/ssh-key.pem'
|
||||
sh 'scp $keyfile root@$ANSIBLE_SERVER:/root/ssh-key.pem'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +24,7 @@ pipeline {
|
||||
echo "calling ansible playbook to configure ec2 instances"
|
||||
def remote = [:]
|
||||
remote.name = "ansible-server"
|
||||
remote.host = "167.99.136.157"
|
||||
remote.host = ANSIBLE_SERVER
|
||||
remote.allowAnyHosts = true
|
||||
|
||||
withCredentials([sshUserPrivateKey(credentialsId: 'ansible-server-key', keyFileVariable: 'keyfile', usernameVariable: 'user')]){
|
||||
|
||||
Reference in New Issue
Block a user