foremast package

Subpackages

Submodules

foremast.args module

Common _argparse_ arguments.

foremast.args.add_app(parser)[source]

Add an app flag to the _parser_.

foremast.args.add_artifact_path(parser)[source]

Add an artifact-path flag to _parser_.

foremast.args.add_artifact_version(parser)[source]

Add an artifact-version flag to _parser_.

foremast.args.add_debug(parser)[source]

Add a debug flag to the _parser_.

foremast.args.add_env(parser)[source]

Add an env flag to the _parser_.

foremast.args.add_gitlab_token(parser)[source]

Add a token-file flag to the _parser_.

foremast.args.add_properties(parser)[source]

Add a settings flag to the _parser_.

foremast.args.add_region(parser)[source]

Add a region flag to the _parser_.

foremast.consts module

Load base config and export package constants.

The foremast configuration file is read from the following locations in descending order. First found wins.

  • ./.foremast/foremast.cfg
  • ~/.foremast/foremast.cfg
  • /etc/foremast/foremast.cfg
; foremast.cfg
[base]
domain = example.com
envs = dev,stage,prod
regions = us-east-1,us-west-2
ami_json_url = http://s3.bucketname.com/ami_lookup.json
git_url = https://git.example.com
gate_api_url = http://gate-api.example.com:8084
templates_path = ../../foremast-templates
default_securitygroup_rules = { "bastion" : [ { "start_port": "22", "end_port": "22", "protocol": "tcp" } ],
                                "serviceapp" : [ { "start_port": "8080", "end_port": "8080", "protocol": "tcp" } ] }

[credentials]
gitlab_token = 123token23423343
slack_token = 123slack3203120312

[whitelists]
asg_whitelist = application1,application2

[formats]
app = {project}{repo}
dns_elb = lb-{project}{repo}.{env}.{domain}
s3_bucket = secret-{env}-{project}

[task_timeouts]
default = 120
envs = { "dev" : { "deleteScalingPolicy": 240} }
foremast.consts.EC2_PIPELINE_TYPES = ('ec2', 'rolling')

Comma separated list of Pipeline Types to treat as EC2 deployments.

This is useful when defining custom Pipeline Types. When Pipeline Type matches, EC2 specific data is used in deployment, such as Auto Scaling Groups and Availability Zones.

Default: ec2,rolling
Required: No
Example: ec2,infrastructure,propeller
foremast.consts.extract_formats(config_handle)[source]

Get application formats.

See gogoutils.Formats for available options.

Parameters:config_handle (configparser.ConfigParser) – Instance of configurations.
Returns:Formats in {$format_type: $format_pattern}.
Return type:dict
foremast.consts.find_config()[source]

Look for foremast.cfg in config_locations or ./config.py.

Raises:SystemExit – No configuration file found.
Returns:Found dynamic or static configuration.
Return type:dict
foremast.consts.load_dynamic_config(config_dir='/home/docs/checkouts/readthedocs.org/user_builds/foremast/checkouts/latest/_docs')[source]

Load and parse dynamic config

foremast.consts.validate_key_values(config_handle, section, key, default=None)[source]

Warn when key is missing from configuration section.

Parameters:
  • config_handle (configparser.ConfigParser) – Instance of configurations.
  • section (str) – Name of configuration section to retrieve.
  • key (str) – Configuration key to look up.
  • default (object) – Default object to use when key is not found.
Returns:

str when key exists, otherwise default object.

Return type:

object

foremast.destroyer module

Complete Application destroyer script.

foremast.destroyer.main()[source]

Attempt to fully destroy AWS Resources for a Spinnaker Application.

foremast.exceptions module

Foremast and Spinnaker related custom exceptions.

exception foremast.exceptions.DataPipelineDefinitionError[source]

Bases: foremast.exceptions.ForemastError

Error Creating Data Pipeline.

exception foremast.exceptions.ForemastConfigurationFileError[source]

Bases: foremast.exceptions.ForemastError

Foremast configuration file misconfigured.

exception foremast.exceptions.ForemastError[source]

Bases: Exception

Foremast related error.

exception foremast.exceptions.ForemastTemplateNotFound[source]

Bases: Exception

Foremast Template was not found.

exception foremast.exceptions.GitLabApiError[source]

Bases: foremast.exceptions.ForemastError

GitLab API did not return a good status.

exception foremast.exceptions.InvalidEventConfiguration[source]

Bases: foremast.exceptions.ForemastError

Invalid AWS Lambda event configuration.

exception foremast.exceptions.LambdaAliasDoesNotExist[source]

Bases: foremast.exceptions.ForemastError

Lambda function was not found.

exception foremast.exceptions.LambdaFunctionDoesNotExist[source]

Bases: foremast.exceptions.ForemastError

Lambda function was not found.

exception foremast.exceptions.PrimaryDNSRecordNotFound[source]

Bases: foremast.exceptions.ForemastError

Required Primary DNS record does not exist.

exception foremast.exceptions.RequiredKeyNotFound[source]

Bases: foremast.exceptions.ForemastError

Required key in json config not found.

exception foremast.exceptions.S3ArtifactNotFound[source]

Bases: foremast.exceptions.ForemastError

Could not find Artifact to upload to S3.

exception foremast.exceptions.S3SharedBucketNotFound[source]

Bases: foremast.exceptions.ForemastError

Shared S3 Bucket does not exist.

exception foremast.exceptions.SNSSubscriptionDoesNotExist[source]

Bases: foremast.exceptions.ForemastError

SNS Subscriptions does not exist.

exception foremast.exceptions.SNSTopicNotFound[source]

Bases: foremast.exceptions.ForemastError

SNS Topic was not found.

exception foremast.exceptions.SpinnakerAppNotFound[source]

Bases: foremast.exceptions.SpinnakerError

Spinnaker app not found error.

exception foremast.exceptions.SpinnakerApplicationListError[source]

Bases: foremast.exceptions.SpinnakerError

Spinnaker application list error.

exception foremast.exceptions.SpinnakerDnsCreationFailed[source]

Bases: foremast.exceptions.SpinnakerError

Spinnaker DNS creation error.

exception foremast.exceptions.SpinnakerElbNotFound[source]

Bases: foremast.exceptions.SpinnakerError

Spinnaker Elb not found.

exception foremast.exceptions.SpinnakerError[source]

Bases: foremast.exceptions.ForemastError

Spinnaker related error.

exception foremast.exceptions.SpinnakerPipelineCreationFailed[source]

Bases: foremast.exceptions.SpinnakerError

Could not create Spinnaker Pipeline.

exception foremast.exceptions.SpinnakerPipelineDeletionFailed[source]

Bases: foremast.exceptions.SpinnakerError

Could not delete Spinnaker Pipeline.

exception foremast.exceptions.SpinnakerSecurityGroupCreationFailed[source]

Bases: foremast.exceptions.SpinnakerError

Could not create Security Group.

exception foremast.exceptions.SpinnakerSecurityGroupError[source]

Bases: foremast.exceptions.SpinnakerError

Could not create Security Group.

exception foremast.exceptions.SpinnakerSubnetError(env='', region='')[source]

Bases: foremast.exceptions.SpinnakerError

Unavailable environment or region.

exception foremast.exceptions.SpinnakerTaskError(task_state)[source]

Bases: foremast.exceptions.SpinnakerError

Spinnaker Task did not finish properly.

exception foremast.exceptions.SpinnakerTaskInconclusiveError(message)[source]

Bases: foremast.exceptions.SpinnakerTaskError

Spinnaker Task state failed to reach terminal state in allowed time.

exception foremast.exceptions.SpinnakerTimeout[source]

Bases: foremast.exceptions.SpinnakerError

Spinnaker Timeout error.

exception foremast.exceptions.SpinnakerVPCIDNotFound[source]

Bases: foremast.exceptions.SpinnakerError

Spinnaker did not find the VPC ID.

exception foremast.exceptions.SpinnakerVPCNotFound[source]

Bases: foremast.exceptions.SpinnakerError

Spinnaker did not find a VPC.

foremast.runner module

A runner for all of the spinnaker pipe modules.

Read environment variables from Jenkins:

  • EMAIL
  • ENV
  • GIT_REPO
  • PROJECT
  • REGION

Then run specific prepare jobs.

class foremast.runner.ForemastRunner[source]

Bases: object

Wrap each pipes module in a way that is easy to invoke.

cleanup()[source]

Clean up generated files.

create_app()[source]

Create the spinnaker application.

create_archaius()[source]

Create S3 bucket for Archaius.

create_autoscaling_policy()[source]

Create Scaling Policy for app in environment

create_awslambda()[source]

Create security groups as defined in the configs.

create_datapipeline()[source]

Creates data pipeline and adds definition

create_dns()[source]

Create DNS for the defined app and environment.

create_elb()[source]

Create the ELB for the defined environment.

create_iam()[source]

Create IAM resources.

create_pipeline(onetime=None)[source]

Create the spinnaker pipeline(s).

create_s3app()[source]

Create S3 infra for s3 applications

create_secgroups()[source]

Create security groups as defined in the configs.

deploy_s3app()[source]

Deploys artifacts contents to S3 bucket

promote_s3app()[source]

promotes S3 deployment to LATEST

slack_notify()[source]

Send out a slack notification.

write_configs()[source]

Generate the configurations needed for pipes.

foremast.runner.create_scaling_policy()[source]

Create Auto Scaling Policy for an Auto Scaling Group.

foremast.runner.debug_flag()[source]

Set logging level for entry points.

foremast.runner.deploy_s3app()[source]

Entry point for application setup and s3 deployments

foremast.runner.prepare_app_pipeline()[source]

Entry point for application setup and initial pipeline in Spinnaker.

foremast.runner.prepare_infrastructure()[source]

Entry point for preparing the infrastructure in a specific env.

foremast.runner.prepare_onetime_pipeline()[source]

Entry point for single use pipeline setup in the defined app.

foremast.runner.promote_s3app()[source]

Entry point for application setup and s3 promotions

foremast.runner.rebuild_pipelines(*args)[source]

Entry point for rebuilding pipelines.

Use to rebuild all pipelines or a specific group.

foremast.validate module

Spinnaker validate functions.

foremast.validate.validate_all(args)[source]

Run all validate steps.

foremast.validate.validate_gate()[source]

Check Gate connection.

foremast.version module

Package version functions.

foremast.version.get_version()[source]

Retrieve package version.

foremast.version.print_version()[source]

Show package version.

Module contents

Tools for creating infrastructure and Spinnaker Applications.