David K. Bainbridge | 0820cab | 2016-06-02 17:43:32 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | ID=$1 |
| 4 | HOSTNAME=$2 |
| 5 | IP=$3 |
| 6 | MAC=$4 |
| 7 | ROLE=$5 |
| 8 | |
David K. Bainbridge | 86dad1f | 2016-06-03 00:01:31 -0700 | [diff] [blame] | 9 | LOG=/etc/maas/ansible/logs/$ID.log |
David K. Bainbridge | 0820cab | 2016-06-02 17:43:32 -0700 | [diff] [blame] | 10 | |
David K. Bainbridge | 86dad1f | 2016-06-03 00:01:31 -0700 | [diff] [blame] | 11 | echo "" >> $LOG |
| 12 | echo "***** BEGIN *****" >> $LOG |
| 13 | echo "PROVISION $ID $HOSTNAME $IP $MAC $ROLE" >> $LOG |
| 14 | |
| 15 | SKIP_TAGS= |
| 16 | EXTRA_VARS= |
| 17 | if [ "$INTERFACE_CONFIG" -eq 1 ]; then |
David K. Bainbridge | 70a0674 | 2016-06-15 19:15:53 -0700 | [diff] [blame] | 18 | FAB_IP="$(curl -s http://allocator:4242/allocations/$MAC | sed -e 's/[{}"]//g' | cut -d, -f2 | cut -d: -f2)/24" |
David K. Bainbridge | 86dad1f | 2016-06-03 00:01:31 -0700 | [diff] [blame] | 19 | EXTRA_VARS="--extra-vars=fabric_ip=$FAB_IP" |
| 20 | else |
| 21 | SKIP_TAGS="--skip-tags=interface_config" |
| 22 | fi |
| 23 | |
| 24 | echo "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. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame^] | 25 | 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 || exit $? |