prerequisite check role
fixed formatting, added dns check before creating VM's

Change-Id: Ibb6c8898ca635a4cc6446b8b3aef584fe458c224
diff --git a/cord-single-playbook.yml b/cord-single-playbook.yml
index 48867be..92807f2 100644
--- a/cord-single-playbook.yml
+++ b/cord-single-playbook.yml
@@ -11,6 +11,11 @@
   - include_vars: vars/cord.yml
   - include_vars: vars/example_keystone.yml
 
+- name: Check Prerequisites
+  hosts: head
+  roles:
+    - prereqs-common
+
 - name: DNS Server and apt-cacher-ng Setup
   hosts: head
   become: yes
diff --git a/roles/dns-configure/tasks/main.yml b/roles/dns-configure/tasks/main.yml
index 7aff9f4..1481bbe 100644
--- a/roles/dns-configure/tasks/main.yml
+++ b/roles/dns-configure/tasks/main.yml
@@ -7,3 +7,7 @@
     dest="/etc/resolv.conf"
     mode=0644 owner=root group=root
 
+- name: Check that VM's can be found in DNS
+  shell: "dig +short {{ item.name }}.{{ site_suffix }} | grep {{ item.ipv4_last_octet }}"
+  with_items: "{{ head_vm_list }}"
+
diff --git a/roles/prereqs-common/defaults/main.yml b/roles/prereqs-common/defaults/main.yml
new file mode 100644
index 0000000..1425db4
--- /dev/null
+++ b/roles/prereqs-common/defaults/main.yml
@@ -0,0 +1,24 @@
+---
+# prereqs-common/defaults/main.yml
+
+min_memtotal_mb: 48000
+min_processor_vcpus: 12
+
+kvm_check: true
+
+dns_check_domain: wiki.opencord.org
+dns_check_ipv4: 52.9.82.207
+
+# obtained from: https://www.iana.org/domains/root/servers
+dns_roots:
+  - 192.5.5.241
+  - 193.0.14.129
+  - 198.41.0.4
+  - 199.7.91.13
+
+http_dl_url: "http://cord.staging.wpengine.com/wp-content/uploads/2016/07/cord-tm-logo.png"
+http_dl_cksum: "sha256:9a69c741a4bb609ad7e49bd0fd335a95db2e66dc0d72866569e11385df9dcc28"
+
+https_dl_url: "https://jenkins.opencord.org/static/8d0f081d/images/headshot.png"
+https_dl_cksum: "sha256:690e82fb98ffb2b4b232d9b9cf9cc52eb7972e56a84902f6d1150b75456058c6"
+
diff --git a/roles/prereqs-common/tasks/main.yml b/roles/prereqs-common/tasks/main.yml
new file mode 100644
index 0000000..606a029
--- /dev/null
+++ b/roles/prereqs-common/tasks/main.yml
@@ -0,0 +1,38 @@
+---
+# prereqs-common/tasks/main.yml
+
+- name: "Check here on failure: 'https://wiki.opencord.org/display/CORD/Troubleshooting+a+Build'"
+  pause:
+    seconds: 10
+
+- name: Memory size Check
+  assert:
+    that: "ansible_memtotal_mb >= {{ min_memtotal_mb }}"
+
+- name: CPU quantity Check
+  assert:
+    that: "ansible_processor_vcpus >= {{ min_processor_vcpus }}"
+
+- name: CPU KVM Check
+  when: kvm_check
+  shell: "lsmod | grep kvm_"
+
+- name: DNS Lookup Check
+  shell: "dig +short {{ dns_check_domain }} | grep {{ dns_check_ipv4 }}"
+
+- name: DNS Global Root Connectivity Check
+  shell: "dig @{{ item }} +trace +short {{ dns_check_domain }} | grep {{ dns_check_ipv4 }}"
+  with_items: "{{ dns_roots }}"
+
+- name: HTTP Download Check
+  get_url:
+    url: "{{ http_dl_url }}"
+    checksum: "{{ http_dl_cksum }}"
+    dest: /tmp/http_dl_check
+
+- name: HTTPS Download Check
+  get_url:
+    url: "{{ https_dl_url }}"
+    checksum: "{{ https_dl_cksum }}"
+    dest: /tmp/https_dl_check
+