CORD-616 make sure that platform can install via tunnel and some clean up
Change-Id: I3ce86a41e17135bad00305eb1e419544ae7fc912
diff --git a/build.gradle b/build.gradle
index db86e6d..3b8f645 100644
--- a/build.gradle
+++ b/build.gradle
@@ -40,29 +40,38 @@
// 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'
-
- // Component table
- comps = [
- ]
-
// 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'
+
+ println "targetReg = $targetReg, targetTag = $targetTag"
+
+ // Component table
+ comps = [
+ ]
}
task copyAnsibleInventory(type: Copy) {
- inputs.file deployConfig
-
- File configFile = new File(deployConfig)
- def yaml = new Yaml()
- def config = yaml.load(configFile.newReader())
-
from 'inventory/templates/single-prod'
into 'inventory'
expand([
@@ -79,14 +88,6 @@
task prime {
// TODO this is a place-holder.
// dependsOn updateDocker
- doFirst {
- println "Using deployment config: $deployConfig"
- File configFile = new File(deployConfig)
- def yaml = new Yaml()
- def config = yaml.load(configFile.newReader())
- println "Config: $config"
- println "Access some data in config:\n\tSeed server IP=${config.seedServer.ip}"
- }
}
// ---------------- Useful tasks ----------------
@@ -144,11 +145,6 @@
task deployPlatform (type: Exec) {
dependsOn copyAnsibleInventory
- 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", "inventory/single-prod"]
@@ -184,10 +180,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)
@@ -197,11 +191,6 @@
task deploySingle (type: Exec) {
dependsOn copyAnsibleInventory
- 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", "inventory/single-prod"]
@@ -237,10 +226,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)
@@ -250,11 +237,6 @@
task postDeployTests (type: Exec) {
dependsOn copyAnsibleInventory
- 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", "inventory/single-prod"]
@@ -290,10 +272,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)
diff --git a/roles/xos-build/defaults/main.yml b/roles/xos-build/defaults/main.yml
index 3d67ba2..4467e45 100644
--- a/roles/xos-build/defaults/main.yml
+++ b/roles/xos-build/defaults/main.yml
@@ -1,4 +1,3 @@
---
xos_repo_dir: "{{ playbook_dir }}/../../orchestration/xos/containers/xos"
-docker_registry: "{{ inventory_hostname }}:5000"
diff --git a/roles/xos-build/tasks/main.yml b/roles/xos-build/tasks/main.yml
index 6bf54a0..847a4e7 100644
--- a/roles/xos-build/tasks/main.yml
+++ b/roles/xos-build/tasks/main.yml
@@ -11,14 +11,11 @@
xosdir.stat.exists == True
- name: tag xos base container image
- local_action: command docker tag xosproject/xos-base {{ docker_registry }}/xosproject/xos-base:candidate
+ local_action: command docker tag xosproject/xos-base {{ deploy_docker_registry }}/xosproject/xos-base:{{ deploy_docker_tag }}
when:
xosdir.stat.exists == True
- name: publish XOS base container image to local repo
- local_action: shell cd {{ xos_repo_dir }} && docker push {{ docker_registry }}/xosproject/xos-base:candidate
+ local_action: shell cd {{ xos_repo_dir }} && docker push {{ deploy_docker_registry }}/xosproject/xos-base:{{ deploy_docker_tag }}
when:
xosdir.stat.exists == True
-
-
-
diff --git a/roles/xos-vm-install/defaults/main.yml b/roles/xos-vm-install/defaults/main.yml
index 0be9d5b..14d04ab 100644
--- a/roles/xos-vm-install/defaults/main.yml
+++ b/roles/xos-vm-install/defaults/main.yml
@@ -17,4 +17,6 @@
docker_opts: ""
docker_tag: "latest"
docker_registry: "docker.io"
+
local_docker_registry: "docker-registry:5000"
+local_docker_tag: "{{ deploy_docker_tag | default('candidate') }}"
diff --git a/roles/xos-vm-install/files/xos-setup-cord-pod-playbook.yml b/roles/xos-vm-install/files/xos-setup-cord-pod-playbook.yml
index bf613be..ac4adc6 100644
--- a/roles/xos-vm-install/files/xos-setup-cord-pod-playbook.yml
+++ b/roles/xos-vm-install/files/xos-setup-cord-pod-playbook.yml
@@ -79,7 +79,7 @@
with_items: "{{ xos_images }}"
- name: Check to see if registry is reachable
- command: curl -sf http://docker-registry:5000/
+ command: curl -sf http://{{ local_docker_registry }}
ignore_errors: yes
register: docker_registry_check
tags:
@@ -89,7 +89,7 @@
set_fact:
docker_registry: "{{ local_docker_registry }}"
docker_opts: "--insecure-registry {{ local_docker_registry }}"
- docker_tag: "candidate"
+ docker_tag: "{{ deploy_docker_tag }}"
when: docker_registry_check|succeeded
- name: Set docker options
diff --git a/roles/xos-vm-install/templates/xos-setup-vars.yml.j2 b/roles/xos-vm-install/templates/xos-setup-vars.yml.j2
index ed22592..95b21b4 100644
--- a/roles/xos-vm-install/templates/xos-setup-vars.yml.j2
+++ b/roles/xos-vm-install/templates/xos-setup-vars.yml.j2
@@ -24,3 +24,5 @@
docker_registry: "{{ docker_registry }}"
local_docker_registry: "{{ local_docker_registry }}"
+deploy_docker_registry: "{{ deploy_docker_registry }}"
+deploy_docker_tag: "{{ deploy_docker_tag }}"