def action_blueprint(config_file, config, args): if args: sys.stderr.write( 'Action "blueprint" accepts no arguments, but got: %s\n' % ' '.join(args)) sys.exit(1) print(util.jsonstr(config))
def amazon_get_ami_by_name(region_name, aws_access_key_id, aws_secret_access_key, name): ec2 = boto3.client('ec2', region_name=region_name, aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key) result = ec2.describe_images(Owners=['self'], Filters=[{'Name': 'name', 'Values': [name]}]) images = result['Images'] assert len(images) == 1, util.jsonstr(images) image = images[0] return image['ImageId']
def _config(self): provs = [ { 'type': 'shell', 'execute_command': "{{ .Vars }} sudo -E /bin/bash '{{ .Path }}'", 'inline': cmds.compile_command_to_bash(cmd), } for cmd in self.cmds ] return util.jsonstr({'builders': [self.builder()], 'provisioners': provs})
def generate(dirpath, config, do_build): files = [] config = preprocess(config) config, barts = get_build_artefacts(config) for bart_name, bart in barts.iteritems(): bart.outputFiles(dirpath) files += bart.getOutputFiles(dirpath) if not do_build: barts = {} barts_to_build = {} # Output build artefact files for bart_name, bart in barts.iteritems(): if bart.needsBuild(): barts_to_build[bart_name] = bart for bart_name, bart in barts_to_build.iteritems(): bart.doBuild(dirpath) for bart_name, bart in barts_to_build.iteritems(): bart.wait(dirpath) for bart_name, bart in barts.iteritems(): bart.postBuild() tfs = compile(config, barts) # Output Terraform configs for filename, tf in tfs.iteritems(): dirfilename = '%s/%s' % (dirpath, filename) files += [dirfilename] with open(dirfilename, 'w') as f: f.write(util.jsonstr(tf)) # Copy terraform plugins into the output dir. config_dir = '%s/.terraform' % os.getcwd() if os.path.exists(config_dir): shutil.copytree(config_dir, dirpath + '/.terraform') return files
def generate(dirpath, config, do_build): files = [] config = preprocess(config) config, barts = get_build_artefacts(config) for bart_name, bart in barts.iteritems(): bart.outputFiles(dirpath) files += bart.getOutputFiles(dirpath) if not do_build: barts = {} barts_to_build = {} # Output build artefact files for bart_name, bart in barts.iteritems(): if bart.needsBuild(): barts_to_build[bart_name] = bart for bart_name, bart in barts_to_build.iteritems(): bart.doBuild(dirpath) for bart_name, bart in barts_to_build.iteritems(): bart.wait(dirpath) for bart_name, bart in barts.iteritems(): bart.postBuild() tfs = compile(config, barts) # Output Terraform configs for filename, tf in tfs.iteritems(): dirfilename = '%s/%s' % (dirpath, filename) files += [dirfilename] with open(dirfilename, 'w') as f: f.write(util.jsonstr(tf)) return files
def action_blueprint(config_file, config, args): if args: sys.stderr.write('Action "blueprint" accepts no arguments, but got: %s\n' % ' '.join(args)) sys.exit(1) print(util.jsonstr(config))