Add copying to remote
This commit is contained in:
@@ -1,12 +1,16 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
|
environment {
|
||||||
|
ANSIBLE_SERVER = "157.230.120.252"
|
||||||
|
}
|
||||||
stages {
|
stages {
|
||||||
stage("copy playbook to ansible-server") {
|
stage("copy playbook to ansible-server") {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
echo "copying ansible folder to ansible server"
|
echo "copying ansible folder to ansible server"
|
||||||
|
withCredentials([sshUserPrivateKey(credentialsId: 'ansible-server-key', keyFileVariable: 'identity', usernameVariable: 'user')]) {
|
||||||
|
sh "scp -i ${identity} ansible/ansible.cfg ${ANSIBLE_SERVER}:/root"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,18 +29,17 @@ pipeline {
|
|||||||
|
|
||||||
def remote = [:]
|
def remote = [:]
|
||||||
remote.name = "ansible-server"
|
remote.name = "ansible-server"
|
||||||
remote.host = "157.230.120.252"
|
remote.host = ANSIBLE_SERVER
|
||||||
remote.allowAnyHosts = true
|
remote.allowAnyHosts = true
|
||||||
|
|
||||||
withCredentials([sshUserPrivateKey(credentialsId: 'ansible-server-key', keyFileVariable: 'identity', usernameVariable: 'user')]) {
|
withCredentials([sshUserPrivateKey(credentialsId: 'ansible-server-key', keyFileVariable: 'identity', usernameVariable: 'user')]) {
|
||||||
remote.identityFile = identity
|
remote.identityFile = identity
|
||||||
remote.user = user
|
remote.user = user
|
||||||
stage('Remote SSH') {
|
|
||||||
sshCommand remote: remote, command: "ls -l"
|
sshCommand remote: remote, command: "ls -l"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user