Skip to content

Instantly share code, notes, and snippets.

@jasonthomas
Created December 21, 2012 21:19
Show Gist options
  • Select an option

  • Save jasonthomas/4355909 to your computer and use it in GitHub Desktop.

Select an option

Save jasonthomas/4355909 to your computer and use it in GitHub Desktop.
autosign.conf
#!/bin/env python
## populate /etc/puppet/autosign.conf based on tags
from boto.ec2 import connect_to_region, regions
region = 'us-west-2'
autosign = '/etc/puppet/autosign.conf'
filters = {'tag:Project': 'amo'}
conn = connect_to_region(region)
reservations = conn.get_all_instances(filters=filters)
private_dns = [i.private_dns_name for r in reservations for i in r.instances]
with open(autosign, 'w') as fp:
for i in private_dns:
fp.write(i + '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment