blob: ae2efb9aafcc6a8f3552e1b769f859dacc2710f7 [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
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