blob: 0d91c31da28447633b6b5c968b34207873d76113 [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
David K. Bainbridge70a06742016-06-15 19:15:53 -070018 FAB_IP="$(curl -s http://allocator:4242/allocations/$MAC | sed -e 's/[{}"]//g' | cut -d, -f2 | cut -d: -f2)/24"
David K. Bainbridge86dad1f2016-06-03 00:01:31 -070019 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
David K. Bainbridgea677d4e2016-09-11 20:01:32 -070025ANSIBLE_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 || exit $?