[CORD-2600] Moving loadconfig into an ansible role

Change-Id: Ifb6bfb6f8cf89212ec518c443e9c9b1af662a236
diff --git a/ansible/genconfig.yml b/ansible/genconfig.yml
index d07980b..3434fc2 100644
--- a/ansible/genconfig.yml
+++ b/ansible/genconfig.yml
@@ -16,95 +16,7 @@
 # ansible/genconfig.yml
 # Generate CORD configuration files
 
-- name: Load pod and scenario config files
-  hosts: localhost
-  connection: local
-  gather_facts: False
-
-  tasks:
-
-    - name: Set pod_config_path fact
-      set_fact:
-        pod_config_path:  "{{ cord_podconfig | realpath }}"
-
-    - name: Check for PODCONFIG file
-      stat:
-        path: "{{ pod_config_path }}"
-      register: pod_config_stat
-
-    - name: POD config file specified by 'PODCONFIG' must exist
-      assert:
-        that: pod_config_stat.stat.isreg
-
-    - name: Load pod config
-      include_vars: "{{ pod_config_path }}"
-
-    - name: Set profile_manifest_path fact
-      set_fact:
-        profile_manifest_path:  "{{ (cord_profile_src_dir ~ '/' ~ cord_profile ~ '.yml') | realpath }}"
-
-    - name: Check for profile manifest
-      stat:
-        path: "{{ profile_manifest_path }}"
-      register: profile_manifest_stat
-
-    - name: Profile manifest file specified by 'cord_profile' must exist
-      assert:
-        that: profile_manifest_stat.stat.isreg
-
-    - name: Set scenario_config_path fact
-      set_fact:
-        scenario_config_path:  "{{ (scenarios_dir ~ '/' ~ cord_scenario ~ '/config.yml') | realpath }}"
-
-    - name: Check for scenario config file manifest
-      stat:
-        path: "{{ scenario_config_path }}"
-      register: scenario_config_stat
-
-    - name: Scenario config.yml file specified by 'cord_scenario' must exist
-      assert:
-        that: scenario_config_stat.stat.isreg
-
-    - name: Load scenario config
-      include_vars: "{{ scenario_config_path }}"
-
-    - name: Reload pod config to take precedence
-      include_vars: "{{ pod_config_path }}"
-
-    - name: Load pod, scenario, profile_manifest into facts
-      set_fact:
-        pod_config: "{{ lookup('file', pod_config_path) | from_yaml }}"
-        scenario_config: "{{ lookup('file', scenario_config_path) | from_yaml }}"
-        profile_manifest: "{{ lookup('file', profile_manifest_path) | from_yaml }}"
-
-    - name: Combine pod and scenario configs and profile manifest into master config
-      set_fact:
-        master_config: "{{ profile_manifest | combine(scenario_config) | combine(pod_config) }}"
-
-    - name: Prime profile_container_list from with master_config.docker_image_whitelist
-      set_fact:
-        profile_container_list: "{{ master_config.docker_image_whitelist }}"
-
-    - name: Add items to profile_container_list from profile_manifest.xos_services
-      set_fact:
-        profile_container_list: "{{ profile_container_list }} + [ 'xosproject/{{ item.name }}-synchronizer' ]"
-      with_items: "{{ profile_manifest.xos_services }}"
-      when:  item.synchronizer is not defined or item.synchronizer
-
-    - name: Add items to profile_container_list from profile_manifest.enabled_gui_extensions
-      set_fact:
-        profile_container_list: "{{ profile_container_list }} + [ 'xosproject/gui-extension-{{ item.name }}' ]"
-      with_items: "{{ profile_manifest.enabled_gui_extensions }}"
-
-    - name: Update docker_image_whitelist to include containers specified by profile
-      set_fact:
-        master_config: "{{ master_config | combine({'docker_image_whitelist': profile_container_list}, recursive=True) }}"
-
-    - name: Print vars
-      debug:
-        var: master_config
-
-- name: Generate config files
+- name: Load pod and scenario config files, Generate config files
   hosts: localhost
   connection: local
   gather_facts: False
diff --git a/ansible/roles/genconfig/tasks/main.yml b/ansible/roles/genconfig/tasks/main.yml
index 1ad13fb..cb88406 100644
--- a/ansible/roles/genconfig/tasks/main.yml
+++ b/ansible/roles/genconfig/tasks/main.yml
@@ -15,6 +15,87 @@
 
 # genconfig/tasks/main.yml
 
+- name: Set pod_config_path fact
+  set_fact:
+    pod_config_path:  "{{ cord_podconfig | realpath }}"
+
+- name: Check for PODCONFIG file
+  stat:
+    path: "{{ pod_config_path }}"
+  register: pod_config_stat
+
+- name: POD config file specified by 'PODCONFIG' must exist
+  assert:
+    that: pod_config_stat.stat.isreg
+
+- name: Load pod config
+  include_vars: "{{ pod_config_path }}"
+
+- name: Set profile_manifest_path fact
+  set_fact:
+    profile_manifest_path:  "{{ (cord_profile_src_dir ~ '/' ~ cord_profile ~ '.yml') | realpath }}"
+
+- name: Check for profile manifest
+  stat:
+    path: "{{ profile_manifest_path }}"
+  register: profile_manifest_stat
+
+- name: Profile manifest file specified by 'cord_profile' must exist
+  assert:
+    that: profile_manifest_stat.stat.isreg
+
+- name: Set scenario_config_path fact
+  set_fact:
+    scenario_config_path:  "{{ (scenarios_dir ~ '/' ~ cord_scenario ~ '/config.yml') | realpath }}"
+
+- name: Check for scenario config file manifest
+  stat:
+    path: "{{ scenario_config_path }}"
+  register: scenario_config_stat
+
+- name: Scenario config.yml file specified by 'cord_scenario' must exist
+  assert:
+    that: scenario_config_stat.stat.isreg
+
+- name: Load scenario config
+  include_vars: "{{ scenario_config_path }}"
+
+- name: Reload pod config to take precedence
+  include_vars: "{{ pod_config_path }}"
+
+- name: Load pod, scenario, profile_manifest into facts
+  set_fact:
+    pod_config: "{{ lookup('file', pod_config_path) | from_yaml }}"
+    scenario_config: "{{ lookup('file', scenario_config_path) | from_yaml }}"
+    profile_manifest: "{{ lookup('file', profile_manifest_path) | from_yaml }}"
+
+- name: Combine pod and scenario configs and profile manifest into master config
+  set_fact:
+    master_config: "{{ profile_manifest | combine(scenario_config) | combine(pod_config) }}"
+
+- name: Prime profile_container_list from with master_config.docker_image_whitelist
+  set_fact:
+    profile_container_list: "{{ master_config.docker_image_whitelist }}"
+
+- name: Add items to profile_container_list from profile_manifest.xos_services
+  set_fact:
+    profile_container_list: "{{ profile_container_list }} + [ 'xosproject/{{ item.name }}-synchronizer' ]"
+  with_items: "{{ profile_manifest.xos_services }}"
+  when:  item.synchronizer is not defined or item.synchronizer
+
+- name: Add items to profile_container_list from profile_manifest.enabled_gui_extensions
+  set_fact:
+    profile_container_list: "{{ profile_container_list }} + [ 'xosproject/gui-extension-{{ item.name }}' ]"
+  with_items: "{{ profile_manifest.enabled_gui_extensions }}"
+
+- name: Update docker_image_whitelist to include containers specified by profile
+  set_fact:
+    master_config: "{{ master_config | combine({'docker_image_whitelist': profile_container_list}, recursive=True) }}"
+
+- name: Print vars
+  debug:
+    var: master_config
+
 - name: Create cord_profile file
   copy:
     dest: "{{ ( genconfig_dir ~ '/cord_profile' ) | realpath }}"