run playbook from within /opt/cord
remove more
don't try to modify now-nonexistent file
Change-Id: If7d1d8453e8c1deb553dd69e52023d8d0900778e
diff --git a/roles/automation-integration/tasks/main.yml b/roles/automation-integration/tasks/main.yml
index cbd37d6..4f3a465 100644
--- a/roles/automation-integration/tasks/main.yml
+++ b/roles/automation-integration/tasks/main.yml
@@ -1,83 +1,18 @@
---
-- 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
+# automation-integration/tasks/main.yml
-- name: Ensure XOS Cluster Enlist Script
+- name: Template do-enlist-compute-node script to /etc/maas/ansible/do-enlist-compute-node
become: yes
template:
- src=do-enlist-compute-node
+ src=do-enlist-compute-node.j2
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: Store cord_in_a_box value for compute node provisioning
- become: yes
- lineinfile: "dest=/etc/maas/ansible/vars/cord.yml state=present regexp='^cord_in_a_box' line='cord_in_a_box: True'"
- when: cord_in_a_box
-
-- name: Ensure JuJu and XOS Compute Node Provisioning
+- name: Have MAAS do-ansible script run do-enlist-compute-node script
become: yes
lineinfile:
dest=/etc/maas/ansible/do-ansible
line='/etc/maas/ansible/do-enlist-compute-node $ID $HOSTNAME || exit $?'
+
diff --git a/roles/automation-integration/templates/do-enlist-compute-node b/roles/automation-integration/templates/do-enlist-compute-node
deleted file mode 100644
index 66cafbc..0000000
--- a/roles/automation-integration/templates/do-enlist-compute-node
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/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/templates/do-enlist-compute-node.j2 b/roles/automation-integration/templates/do-enlist-compute-node.j2
new file mode 100644
index 0000000..9f617f1
--- /dev/null
+++ b/roles/automation-integration/templates/do-enlist-compute-node.j2
@@ -0,0 +1,28 @@
+#!/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 "cd /opt/cord/build/platform-install; ansible-playbook --private-key=/etc/maas/ansible/id_rsa --extra-vars 'cord_in_a_box={{ cord_in_a_box }}' -i $INV cord-compute-playbook.yml" >> $LOG
+
+cd /opt/cord/build/platform-install
+ansible-playbook --private-key=/etc/maas/ansible/id_rsa --extra-vars 'cord_in_a_box={{ cord_in_a_box }}' -i $INV cord-compute-playbook.yml >> $LOG
+
+RESULT=$?
+rm $INV
+
+exit $RESULT