[CORD-795]
Docker image building/tagging/labeling, Makefile based build
Change-Id: I0d70ab01353999c0e0585547582af9c62d247987
diff --git a/ansible/genconfig.yml b/ansible/genconfig.yml
new file mode 100644
index 0000000..33038b4
--- /dev/null
+++ b/ansible/genconfig.yml
@@ -0,0 +1,47 @@
+---
+# ansible/genconfig.yml
+# Generate 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: Load pod config
+ include_vars: "{{ pod_config_path }}"
+
+ - name: Set scenario_config_path fact
+ set_fact:
+ scenario_config_path: "{{ (scenarios_dir ~ '/' ~ cord_scenario ~ '/config.yml') | realpath }}"
+
+ - name: Load scenario config
+ include_vars: "{{ scenario_config_path }}"
+
+ - name: Reload pod config to take precedence
+ include_vars: "{{ pod_config_path }}"
+
+ - name: Load pod and scenario configs into facts
+ set_fact:
+ pod_config: "{{ lookup('file', pod_config_path) | from_yaml }}"
+ scenario_config: "{{ lookup('file', scenario_config_path) | from_yaml }}"
+
+ - name: Combine pod and scenario config into master config
+ set_fact:
+ master_config: "{{ scenario_config | combine(pod_config) }}"
+
+ - name: Print vars
+ debug:
+ var: master_config
+
+- name: Generate config files
+ hosts: localhost
+ connection: local
+ gather_facts: False
+ roles:
+ - genconfig
+
diff --git a/ansible/roles/genconfig/tasks/main.yml b/ansible/roles/genconfig/tasks/main.yml
new file mode 100644
index 0000000..5b34654
--- /dev/null
+++ b/ansible/roles/genconfig/tasks/main.yml
@@ -0,0 +1,22 @@
+---
+# genconfig/tasks/main.yml
+
+- name: Create cord_profile file
+ copy:
+ dest: "{{ ( genconfig_dir ~ '/cord_profile' ) | realpath }}"
+ content: "{{ cord_profile }}"
+
+- name: Create cord_scenario file
+ copy:
+ dest: "{{ ( genconfig_dir ~ '/cord_scenario' ) | realpath }}"
+ content: "{{ cord_scenario }}"
+
+- name: Generate config files
+ template:
+ src: "{{ item }}.j2"
+ dest: "{{ ( genconfig_dir ~ '/' ~ item ) | realpath }}"
+ with_items:
+ - inventory.ini
+ - config.mk
+ - config.yml
+
diff --git a/ansible/roles/genconfig/templates/config.mk.j2 b/ansible/roles/genconfig/templates/config.mk.j2
new file mode 100644
index 0000000..dd0fc06
--- /dev/null
+++ b/ansible/roles/genconfig/templates/config.mk.j2
@@ -0,0 +1,41 @@
+# config.mk - generated from ansible/roles/genconfig/templates/config.mk.j2
+# ** DO NOT EDIT THIS FILE MANUALLY! **
+# Edit the Pod Config (or Scenario) and rerun `make config` to regenerate it
+
+# Scenario specific config
+{% if vagrant_vms is defined %}
+VAGRANT_VMS = {{ vagrant_vms | join(' ') }}
+{% endif %}
+{% if headnode is defined %}
+HEADNODE = {{ headnode }}
+{% endif %}
+{% if buildnode is defined %}
+BUILDNODE = {{ buildnode }}
+{% endif %}
+{% if deploy_docker_tag is defined %}
+DEPLOY_DOCKER_TAG = {{ deploy_docker_tag }}
+{% endif %}
+{% if config_cord_profile_dir is defined %}
+CONFIG_CORD_PROFILE_DIR = {{ config_cord_profile_dir }}
+{% endif %}
+
+# Targets and prerequisties
+{% if build_targets is defined %}
+BUILD_TARGETS = $(M)/{{ build_targets | join(" $(M)/") }}
+{% endif %}
+{% if vagrant_up_prereqs is defined %}
+VAGRANT_UP_PREREQS = $(M)/{{ vagrant_up_prereqs | join(" $(M)/") }}
+{% endif %}
+{% if cord_config_prereqs is defined %}
+CORD_CONFIG_PREREQS = $(M)/{{ cord_config_prereqs | join(" $(M)/") }}
+{% endif %}
+{% if copy_config_prereqs is defined %}
+COPY_CONFIG_PREREQS = $(M)/{{ copy_config_prereqs | join(" $(M)/") }}
+{% endif %}
+{% if prep_buildnode_prereqs is defined %}
+PREP_BUILDNODE_PREREQS = $(M)/{{ prep_buildnode_prereqs | join(" $(M)/") }}
+{% endif %}
+{% if prep_headnode_prereqs is defined %}
+PREP_HEADNODE_PREREQS = $(M)/{{ prep_headnode_prereqs | join(" $(M)/") }}
+{% endif %}
+
diff --git a/ansible/roles/genconfig/templates/config.yml.j2 b/ansible/roles/genconfig/templates/config.yml.j2
new file mode 100644
index 0000000..09dffe4
--- /dev/null
+++ b/ansible/roles/genconfig/templates/config.yml.j2
@@ -0,0 +1,7 @@
+---
+# config.yml - generated from ansible/roles/genconfig/templates/config.yml.j2
+# ** DO NOT EDIT THIS FILE MANUALLY! **
+# Edit the Pod Config (or Scenario) and rerun `make config` to regenerate it
+
+{{ master_config | to_nice_yaml }}
+
diff --git a/ansible/roles/genconfig/templates/inventory.ini.j2 b/ansible/roles/genconfig/templates/inventory.ini.j2
new file mode 100644
index 0000000..f23f475
--- /dev/null
+++ b/ansible/roles/genconfig/templates/inventory.ini.j2
@@ -0,0 +1,24 @@
+; inventory.ini, generated from ansible/roles/genconfig/templates/inventory.ini.j2
+; ** DO NOT EDIT THIS FILE MANUALLY! **
+; Edit the Pod Config (or Scenario) and rerun `make config` to regenerate it
+
+{% macro group_template(groupname) %}
+{% if inventory_groups[groupname] %}
+{% for g_key, g_val in inventory_groups[groupname].iteritems() %}
+{{ g_key }}{% if g_val %} {% for key, val in g_val.iteritems() %}{{ key ~ "=" ~ val }}{% endfor %}{% endif %}
+{% endfor %}
+{% endif %}
+{% endmacro %}
+
+[config]
+{{ group_template('config') }}
+
+[build]
+{{ group_template('build') }}
+
+[head]
+{{ group_template('head') }}
+
+[compute]
+{{ group_template('compute') }}
+