Fix determining admin user
Change-Id: I17f89bfbbe6a013e621e9c0b4f4b3b589f20dc3f
diff --git a/cicd-lab-pipeline.groovy b/cicd-lab-pipeline.groovy
index 4313e86..88f53d9 100644
--- a/cicd-lab-pipeline.groovy
+++ b/cicd-lab-pipeline.groovy
@@ -221,18 +221,18 @@
//
// Deploy user's ssh key
//
- if (sshPubKey) {
- def out = salt.cmdRun(saltMaster, 'I@salt:master', "[ -d /home/ubuntu ] && echo 'ubuntu user exists'")
- def adminUser
- def authorizedKeysFile
- if (out =~ /ubuntu user exists/) {
- adminUser = "ubuntu"
- authorizedKeysFile = "/home/ubuntu/.ssh/authorized_keys"
- } else {
- adminUser = "root"
- authorizedKeysFile = "/root/.ssh/authorized_keys"
- }
+ def adminUser
+ def authorizedKeysFile
+ def out = salt.cmdRun(saltMaster, 'I@salt:master', "[ -d /home/ubuntu ] && echo 'ubuntu user exists'")
+ if (out =~ /ubuntu user exists/) {
+ adminUser = "ubuntu"
+ authorizedKeysFile = "/home/ubuntu/.ssh/authorized_keys"
+ } else {
+ adminUser = "root"
+ authorizedKeysFile = "/root/.ssh/authorized_keys"
+ }
+ if (sshPubKey) {
println "Deploying provided ssh key at ${authorizedKeysFile}"
salt.cmdRun(saltMaster, '*', "echo '${sshPubKey}' | tee -a ${authorizedKeysFile}")
}