From c70bfe4bbd255ca2e6dce1c6f2851f9fcf208f26 Mon Sep 17 00:00:00 2001 From: Nana Janashia Date: Wed, 7 Apr 2021 11:57:06 +0200 Subject: [PATCH] Add remote execution --- Jenkinsfile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 16779d6..7a06bdd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,5 +15,23 @@ pipeline { } } } + stage("execute ansible playbook") { + steps { + script { + echo "calling ansible playbook to configure ec2 instances" + def remote = [:] + remote.name = "ansible-server" + remote.host = "167.99.136.157" + remote.allowAnyHosts = true + + withCredentials([sshUserPrivateKey(credentialsId: 'ansible-server-key', keyFileVariable: 'keyfile', usernameVariable: 'user')]){ + remote.user = user + remote.identityFile = keyfile + sshCommand remote: remote, command: "ls -l" + + } + } + } + } } } \ No newline at end of file