consul_cloud_setup 318 B

1234567891011121314151617
  1. #!/usr/bin/python
  2. import json
  3. import urllib2
  4. import sys
  5. URL = 'http://169.254.169.254/latest/user-data'
  6. try:
  7. data = json.load(urllib2.urlopen(URL))
  8. except:
  9. print >> sys.stderr, 'Was not able to connect to the Amazon API'
  10. sys.exit(2)
  11. if data['consul_master'] == '127.0.0.1'
  12. print 'i am the master'