def get_ec2_instancewrappers(self, tags={}): alltags = {} alltags.update(tags) alltags[self.ec2_environment_tag] = self.environment instancewrappers = Ec2InstanceWrapper.get_by_tagvalue( tags=alltags, region=self.region) return instancewrappers
def expand_roledefs(): from fabric.api import env from awsfabrictasks.ec2.api import Ec2InstanceWrapper for k, v in env.roledefs.items(): if isinstance(v, dict): if 'ec2:tagged' in v: region = v['ec2:tagged'].pop('region') if 'region' in v['ec2:tagged'] else None instancewrappers = Ec2InstanceWrapper.get_by_tagvalue(v['ec2:tagged'], region) env.roledefs[k] = [instancewrapper['public_dns_name'] for instancewrapper in instancewrappers]
def expand_roledefs(): from fabric.api import env from awsfabrictasks.ec2.api import Ec2InstanceWrapper for k, v in env.roledefs.items(): if isinstance(v, dict): if 'ec2:tagged' in v: region = v['ec2:tagged'].pop( 'region') if 'region' in v['ec2:tagged'] else None instancewrappers = Ec2InstanceWrapper.get_by_tagvalue( v['ec2:tagged'], region) env.roledefs[k] = [ instancewrapper['public_dns_name'] for instancewrapper in instancewrappers ]
def chef_deploy(nodeconf): """ Deploy the specified ``nodeconf``. :param nodeconf: The name of a file in ``../chef/nodes/``. """ from os.path import exists localpath = join(LOCAL_CHEFDIR, 'nodes', nodeconf) if not exists(localpath): abort('The specified node-config ({0}) does not exist.'.format(localpath)) # Confirm deploy print '{sep} About to deploy {nodeconf} {sep}'.format(sep='='*20, nodeconf=nodeconf) print open(localpath, 'rb').read() print '<'*20 instancewrapper = Ec2InstanceWrapper.get_from_host_string() nametag = instancewrapper.instance.tags.get('Name') confirmmsg = 'Really deploy "{nodeconf}" on EC2 instance "{nametag}"?'.format(nodeconf=nodeconf, nametag=nametag) if not confirm(confirmmsg, default=True): abort('Aborted') # The actual deploy code rsync_deploydir() _create_chefsolo_cachedir() with cd(REMOTE_CHEFDIR): sudo('chef-solo -c {chefdir}/chefsolo.rb -j {chefdir}/nodes/{nodeconf}'.format(chefdir=REMOTE_CHEFDIR, nodeconf=nodeconf)) print 'Deploy of {nametag} complete. Visit the instance at:'.format(**vars()) print print ' http://{0}'.format(instancewrapper.instance.public_dns_name) print print 'Login with:' print ' username: grandma' print ' password: test'
def get_ec2_instancewrappers(self, tags={}): alltags = {} alltags.update(tags) alltags[self.ec2_environment_tag] = self.environment instancewrappers = Ec2InstanceWrapper.get_by_tagvalue(tags=alltags, region=self.region) return instancewrappers