CORD-616 some cleanup and clarification about registry tags

Change-Id: Ia8562b8b17c949fe135b8092fa370733629e039c
diff --git a/build.gradle b/build.gradle
index aa33b39..da1440f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -39,16 +39,29 @@
     // Upstream registry to simplify filling out the comps table below
     upstreamReg = project.hasProperty('upstreamReg') ? project.getProperty('upstreamReg') : 'docker.io'
 
-    // Target registry to be used to publish docker images needed for deployment
-    targetReg = project.hasProperty('targetReg') ? project.getProperty('targetReg') : 'localhost:5000'
-
-    // The tag used to tag the docker images push to the target registry
-    targetTag = project.hasProperty('targetTag') ? project.getProperty('targetTag') : 'candidate'
-
     // Deployment target config file (yaml format); this can be overwritten from the command line
     // using the -PdeployConfig=<file-path> syntax.
     deployConfig = project.hasProperty('deployConfig') ? project.getProperty('deployConfig') : './config/default.yml'
 
+    println "Using deployment config: $deployConfig"
+    File configFile = new File(deployConfig)
+    def yaml = new Yaml()
+    config = yaml.load(configFile.newReader())
+
+    // Target registry to be used to publish docker images needed for deployment
+    targetReg = project.hasProperty('targetReg')
+        ? project.getProperty('targetReg')
+        : config.docker && config.docker.registry
+            ? config.docker.registry
+            : 'localhost:5000'
+
+    // The tag used to tag the docker images push to the target registry
+    targetTag = project.hasProperty('targetTag')
+        ? project.getProperty('targetTag')
+        : config.docker && config.docker.imageVersion
+            ? config.docker.imageVersion
+            : 'candidate'
+
     comps = [
             'consul': [
                     'type':     'image',
@@ -282,11 +295,6 @@
 }
 
 task prime (type: Exec)  {
-    println "Using deployment config: $deployConfig"
-    File configFile = new File(deployConfig)
-    def yaml = new Yaml()
-    def config = yaml.load(configFile.newReader())
-
     executable = "ansible-playbook"
     args = ["-i", config.seedServer.ip + ',']
 
@@ -328,10 +336,8 @@
         .p(config.otherServers.role, "prov_role")
     }
 
-    if (config.docker) {
-        extraVars = extraVars.p(config.docker.registry, "docker_registry")
-            .p(config.docker.imageVersion, "docker_image_version")
-    }
+    extraVars = extraVars.p("$targetReg", "deploy_docker_registry")
+        .p("$targetTag", "deploy_docker_tag")
 
     def skipTags = [].p(config.seedServer.skipTags)
 
@@ -339,11 +345,6 @@
 }
 
 task deployBase(type: Exec)  {
-    println "Using deployment config: $deployConfig"
-    File configFile = new File(deployConfig)
-    def yaml = new Yaml()
-    def config = yaml.load(configFile.newReader())
-
     executable = "ansible-playbook"
     args = ["-i", config.seedServer.ip + ',']
 
@@ -384,10 +385,8 @@
         .p(config.otherServers.role, "prov_role")
     }
 
-    if (config.docker) {
-        extraVars = extraVars.p(config.docker.registry, "docker_registry")
-            .p(config.docker.imageVersion, "docker_image_version")
-    }
+    extraVars = extraVars.p("$targetReg", "deploy_docker_registry")
+        .p("$targetTag", "deploy_docker_tag")
 
     def skipTags = [].p(config.seedServer.skipTags)