Install the CORD-in-a-Box head node into the 'prod' VM

Change-Id: I121130e21ae4268a9dbc9d0a6fb8ff8095ffdcc7
diff --git a/ansible/roles/maas-provision/tasks/main.yml b/ansible/roles/maas-provision/tasks/main.yml
new file mode 100644
index 0000000..32e43ea
--- /dev/null
+++ b/ansible/roles/maas-provision/tasks/main.yml
@@ -0,0 +1,37 @@
+# Doesn't seem to be a MAAS module for Ansible yet
+- name: Get MAAS credentials
+  become: yes
+  command: maas-region-admin apikey --username=cord
+  register: maas_key
+  tags:
+    - skip_ansible_lint
+
+- name: Login to MAAS
+  command: maas login cord http://localhost/MAAS/api/1.0 {{ maas_key.stdout }}
+  tags:
+    - skip_ansible_lint
+
+- name: Wait for node to become ready
+  shell: maas cord nodes list|jq -r '.[] | select(.status == 0).system_id'
+  register: nodeid
+  until: nodeid.stdout
+  retries: 40
+  delay: 15
+  tags:
+    - skip_ansible_lint
+
+# We need to be able to reboot the VM on the physical server running CiaB
+- name: Add remote power state
+  command: maas cord node update {{ nodeid.stdout }} power_type="virsh" power_parameters_power_address="qemu+ssh://{{ maas_user }}@10.100.198.1/system" power_parameters_power_id="{{ vagrant_name }}"
+  tags:
+    - skip_ansible_lint
+
+- name: Wait for node to be fully provisioned
+  become: yes
+  shell: /usr/local/bin/get-node-prov-state |jq '.[] | select(.id == "{{ nodeid.stdout }}").status'
+  register: prov_state
+  until: prov_state.stdout == "2"
+  retries: 80
+  delay: 30
+  tags:
+    - skip_ansible_lint