blob: dfe70ad54c1383560a238d900fa6cb1d1ae85333 [file] [log] [blame]
David K. Bainbridge0820cab2016-06-02 17:43:32 -07001#!/bin/bash
2
3ID=$1
4HOSTNAME=$2
5IP=$3
6MAC=$4
7ROLE=$5
8
David K. Bainbridge86dad1f2016-06-03 00:01:31 -07009LOG=/etc/maas/ansible/logs/$ID.log
David K. Bainbridge0820cab2016-06-02 17:43:32 -070010
David K. Bainbridge86dad1f2016-06-03 00:01:31 -070011echo "" >> $LOG
12echo "***** BEGIN *****" >> $LOG
13echo "PROVISION $ID $HOSTNAME $IP $MAC $ROLE" >> $LOG
14
15SKIP_TAGS=
16EXTRA_VARS=
17if [ "$INTERFACE_CONFIG" -eq 1 ]; then
18 FAB_IP=$(curl -s http://allocator:4242/allocations/$MAC | sed -e 's/[{}"]//g' | cut -d, -f2 | cut -d: -f2)
19 EXTRA_VARS="--extra-vars=fabric_ip=$FAB_IP"
20else
21 SKIP_TAGS="--skip-tags=interface_config"
22fi
23
24echo "ANSIBLE_ROLES_PATH=/etc/maas/ansible/roles ansible-playbook --private-key=/etc/maas/ansible/id_rsa -i $IP, /etc/maas/ansible/compute-node.yml $SKIP_TAGS $EXTRA_VARS" >> $LOG
25ANSIBLE_ROLES_PATH=/etc/maas/ansible/roles ansible-playbook --private-key=/etc/maas/ansible/id_rsa -i $IP, /etc/maas/ansible/compute-node.yml $SKIP_TAGS $EXTRA_VARS >> $LOG