Files
java-maven-app/Jenkinsfile-v1
2021-04-03 17:53:39 +02:00

45 lines
1.6 KiB
Plaintext

pipeline {
agent any
environment {
ANSIBLE_SERVER = "157.230.120.252"
}
stages {
stage("copy playbook to ansible-server") {
steps {
script {
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"
}
}
}
}
stage("copy ssh keys for Ansible") {
steps {
script {
echo "copying ssh keys for ec2 instances"
}
}
}
stage("execute ansible playbook from the ansible-server") {
steps {
script {
echo "executing ansible-playbook"
def remote = [:]
remote.name = "ansible-server"
remote.host = ANSIBLE_SERVER
remote.allowAnyHosts = true
withCredentials([sshUserPrivateKey(credentialsId: 'ansible-server-key', keyFileVariable: 'identity', usernameVariable: 'user')]) {
remote.identityFile = identity
remote.user = user
sshCommand remote: remote, command: "ls -l"
}
}
}
}
}
}