[CORD-1474]
Use value of config_cord_profile_dir from config node, rather than head
node
Change-Id: I33c6029c52824921553316d25a4cb13227f68e61
diff --git a/copy-profile-playbook.yml b/copy-profile-playbook.yml
index 761ed0c..154ba50 100644
--- a/copy-profile-playbook.yml
+++ b/copy-profile-playbook.yml
@@ -1,5 +1,5 @@
---
-# copy-profile-book.yml
+# copy-profile-playbook.yml
# Copies the profile to the head node
- name: Include vars
@@ -11,6 +11,11 @@
- "profile_manifests/{{ cord_profile }}.yml"
- profile_manifests/local_vars.yml
+- name: Set hostvars with defaults for each node
+ hosts: head, config
+ roles:
+ - hostvars-defaults
+
- name: Copy cord_profile to head node from config node
hosts: head
roles:
diff --git a/roles/api-tests/defaults/main.yml b/roles/api-tests/defaults/main.yml
index 065a432..8602670 100644
--- a/roles/api-tests/defaults/main.yml
+++ b/roles/api-tests/defaults/main.yml
@@ -1,5 +1,5 @@
---
# api-tests/defaults/main.yml
-config_cord_dir: "{{ ansible_user_dir + '/cord' }}"
+config_cord_dir: "{{ ansible_user_dir ~ '/cord' }}"
diff --git a/roles/copy-cord/defaults/main.yml b/roles/copy-cord/defaults/main.yml
index 962c8db..2b0f313 100644
--- a/roles/copy-cord/defaults/main.yml
+++ b/roles/copy-cord/defaults/main.yml
@@ -1,5 +1,5 @@
---
# copy-cord/defaults/main.yml
-config_cord_dir: "{{ ansible_user_dir + '/cord' }}"
+config_cord_dir: "{{ ansible_user_dir ~ '/cord' }}"
head_cord_dir: "/opt/cord"
diff --git a/roles/copy-profile/defaults/main.yml b/roles/copy-profile/defaults/main.yml
index c4f7979..6f7b645 100644
--- a/roles/copy-profile/defaults/main.yml
+++ b/roles/copy-profile/defaults/main.yml
@@ -1,5 +1,5 @@
---
# copy-profile/defaults/main.yml
-config_cord_profile_dir: "{{ ansible_user_dir + '/cord_profile' }}"
+config_cord_profile_dir: "{{ ansible_user_dir ~ '/cord_profile' }}"
head_cord_profile_dir: "/opt/cord_profile"
diff --git a/roles/copy-profile/tasks/main.yml b/roles/copy-profile/tasks/main.yml
index c206a3f..3434c27 100644
--- a/roles/copy-profile/tasks/main.yml
+++ b/roles/copy-profile/tasks/main.yml
@@ -3,7 +3,7 @@
- name: Copy (sync) the cord_profile directory structure to head node
synchronize:
- src: "{{ config_cord_profile_dir }}/"
+ src: "{{ hostvars[groups['config'][0]]['config_cord_profile_dir'] }}/"
dest: "{{ head_cord_profile_dir }}/"
delete: yes
diff --git a/roles/cord-profile/defaults/main.yml b/roles/cord-profile/defaults/main.yml
index d867ef6..c7bf7aa 100644
--- a/roles/cord-profile/defaults/main.yml
+++ b/roles/cord-profile/defaults/main.yml
@@ -2,7 +2,7 @@
# cord-profile/defaults/main.yml
# where the cord_profile directory is on the config node
-config_cord_profile_dir: "{{ ansible_user_dir + '/cord_profile' }}"
+config_cord_profile_dir: "{{ ansible_user_dir ~ '/cord_profile' }}"
pki_dir: "{{ playbook_dir }}/pki"
ssh_pki_dir: "{{ playbook_dir }}/ssh_pki"
diff --git a/roles/hostvars-defaults/defaults/main.yml b/roles/hostvars-defaults/defaults/main.yml
new file mode 100644
index 0000000..479c662
--- /dev/null
+++ b/roles/hostvars-defaults/defaults/main.yml
@@ -0,0 +1,31 @@
+---
+# hostvars-defaults/defaults/main.yml
+
+# default values
+config_cord_dir: "{{ ansible_user_dir ~ '/cord' }}"
+build_cord_dir: "{{ playbook_dir ~ '/../..' }}"
+head_cord_dir: "/opt/cord"
+
+config_cord_profile_dir: "{{ ansible_user_dir ~ '/cord_profile' }}"
+head_cord_profile_dir: "/opt/cord_profile"
+
+head_onos_cord_dir: "/opt/onos-cord/"
+head_onos_fabric_dir: "/opt/onos_fabric/"
+
+# list of all defaults to set as hostvars
+hostvars_defaults_dict:
+ - key: config_cord_dir
+ val: "{{ config_cord_dir }}"
+ - key: build_cord_dir
+ val: "{{ build_cord_dir }}"
+ - key: head_cord_dir
+ val: "{{ head_cord_dir }}"
+ - key: config_cord_profile_dir
+ val: "{{ config_cord_profile_dir }}"
+ - key: head_cord_profile_dir
+ val: "{{ head_cord_profile_dir }}"
+ - key: head_onos_cord_dir
+ val: "{{ head_onos_cord_dir }}"
+ - key: head_onos_fabric_dir
+ val: "{{ head_onos_fabric_dir }}"
+
diff --git a/roles/hostvars-defaults/tasks/main.yml b/roles/hostvars-defaults/tasks/main.yml
new file mode 100644
index 0000000..e16b593
--- /dev/null
+++ b/roles/hostvars-defaults/tasks/main.yml
@@ -0,0 +1,14 @@
+---
+# hostvars-defaults/tasks/main.yml
+# Sets default variables in multiple hosts to allow them to accessed on other
+# hosts via the hostvars['otherhost']['defaultvar']
+
+- name: List host group specific values of default variables
+ debug:
+ msg: "{{ item.key }}:{{ item.val }}"
+ with_items: "{{ hostvars_defaults_dict }}"
+
+- name: Set hostvars as facts to persist them
+ set_fact: {"{{ item.key }}":"{{ item.val }}"}
+ with_items: "{{ hostvars_defaults_dict }}"
+
diff --git a/roles/monitoringservice-config/defaults/main.yml b/roles/monitoringservice-config/defaults/main.yml
index 2514331..2e9d196 100644
--- a/roles/monitoringservice-config/defaults/main.yml
+++ b/roles/monitoringservice-config/defaults/main.yml
@@ -2,7 +2,7 @@
# monitoringservice-config/defaults/main.yml
#paths
-config_cord_dir: "{{ ansible_user_dir + '/cord' }}"
+config_cord_dir: "{{ ansible_user_dir ~ '/cord' }}"
head_cord_dir: "/opt/cord"
head_cord_profile_dir: "/opt/cord_profile"
diff --git a/roles/onos-fabric-install/defaults/main.yml b/roles/onos-fabric-install/defaults/main.yml
index aaa91e9..367727e 100644
--- a/roles/onos-fabric-install/defaults/main.yml
+++ b/roles/onos-fabric-install/defaults/main.yml
@@ -2,7 +2,7 @@
# onos-fabric-install/defaults/main.yml
# paths
-head_onos_fabric_dir: "/opt/onos_fabric"
+head_onos_fabric_dir: "/opt/onos_fabric/"
# ONOS docker image to use
deploy_docker_registry: ""
diff --git a/roles/platform-check/defaults/main.yml b/roles/platform-check/defaults/main.yml
index 4e19128..f7c291c 100644
--- a/roles/platform-check/defaults/main.yml
+++ b/roles/platform-check/defaults/main.yml
@@ -1,7 +1,7 @@
---
# platform-check/defaults/main.yml
-config_cord_profile_dir: "{{ ansible_user_dir + '/cord_profile' }}"
+config_cord_profile_dir: "{{ ansible_user_dir ~ '/cord_profile' }}"
head_onos_cord_dir: "/opt/onos-cord/"
xos_ui_port: 9000
diff --git a/roles/repo/defaults/main.yml b/roles/repo/defaults/main.yml
index 6ef6c5a..521d097 100644
--- a/roles/repo/defaults/main.yml
+++ b/roles/repo/defaults/main.yml
@@ -1,7 +1,7 @@
---
# repo/defaults/main.yml
-config_cord_dir: "{{ ansible_user_dir + '/cord' }}"
+config_cord_dir: "{{ ansible_user_dir ~ '/cord' }}"
repo_dl_url: "https://storage.googleapis.com/git-repo-downloads/repo"
# This is for repo v1.23, and will change, as repo_dl_url unfortunately lacks a version...