updated to support the enlisting of compute nodes into juju and XOS when they come on line

Change-Id: I2b1d51414a7e22b9709ea5f534ddef622e008a32
diff --git a/roles/automation-integration/files/do-enlist-compute-node b/roles/automation-integration/files/do-enlist-compute-node
new file mode 100644
index 0000000..66cafbc
--- /dev/null
+++ b/roles/automation-integration/files/do-enlist-compute-node
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+ID=$1
+HOSTNAME=$2
+LOG=/etc/maas/ansible/logs/$ID.log
+
+INV=$(tempfile)
+cat >$INV <<EO_INV
+[head]
+juju-head-node ansible_user={{ ansible_user_id }}
+
+[compute]
+$HOSTNAME ansible_user=ubuntu
+EO_INV
+
+echo "BEGIN INVENTORY FILE" >> $LOG
+cat $INV >> $LOG
+echo "END INVENTORY_FILE" >> $LOG
+
+echo "ANSIBLE_ROLES_PATH=/etc/maas/ansible/roles ansible-playbook --private-key=/etc/maas/ansible/id_rsa -i $INV /etc/maas/ansible/cord-compute-playbook.yml" >> $LOG
+
+ANSIBLE_ROLES_PATH=/etc/maas/ansible/roles ansible-playbook --private-key=/etc/maas/ansible/id_rsa -i $INV /etc/maas/ansible/cord-compute-playbook.yml >> $LOG
+RESULT=$?
+rm $INV
+
+exit $RESULT
diff --git a/roles/automation-integration/tasks/main.yml b/roles/automation-integration/tasks/main.yml
new file mode 100644
index 0000000..9f81631
--- /dev/null
+++ b/roles/automation-integration/tasks/main.yml
@@ -0,0 +1,78 @@
+---
+- name: Ensure Ansible Directories
+  become: yes
+  file:
+    path=/etc/maas/ansible/{{ item }}
+    state=directory
+    owner=maas
+    group=maas
+    mode=0755
+  with_items:
+    - roles
+    - vars
+    - library
+
+- name: Ensure XOS Cluster Enlist Script
+  become: yes
+  template:
+    src=files/do-enlist-compute-node
+    dest=/etc/maas/ansible/do-enlist-compute-node
+    owner=maas
+    group=maas
+    mode=0755
+
+- name: Copy Compute Node Playbook
+  become: yes
+  copy:
+    src=../../../cord-compute-playbook.yml
+    dest=/etc/maas/ansible
+    owner=maas
+    group=maas
+    mode=0644
+
+- name: Copy Required Ansible Libraries
+  become: yes
+  copy:
+    src=../../../library/{{ item }}
+    dest=/etc/maas/ansible/library
+    owner=maas
+    group=maas
+    mode=0644
+  with_items:
+    - juju_facts.py
+
+- name: Copy Required Ansible Roles
+  become: yes
+  copy:
+    src=../../../roles/{{ item }}
+    dest=/etc/maas/ansible/roles
+    owner=maas
+    group=maas
+    mode=0755
+  with_items:
+    - common-prep
+    - cloudlab-prep
+    - compute-prep
+    - dns-configure
+    - head-prep
+    - juju-compute-setup
+    - xos-compute-setup
+
+- name: Copy Required Ansible Variables
+  become: yes
+  copy:
+    src=../../../vars/{{ item }}
+    dest=/etc/maas/ansible/vars
+    owner=maas
+    group=maas
+    mode=0644
+  with_items:
+    - cord_defaults.yml
+    - cord.yml
+    - example_keystone.yml
+
+- name: Ensure JuJu and XOS Compute Node Provisioning
+  become: yes
+  lineinfile:
+    dest=/etc/maas/ansible/do-ansible
+    line='/etc/maas/ansible/do-enlist-compute-node $ID $HOSTNAME || exit $?'