-
Notifications
You must be signed in to change notification settings - Fork 7
Glossary
A resource is an object in your infrastructure. It's a server, a domain, an IP address, a shell script -- anything that be created, modified or deleted. Each resource has a set of attributes including an action. A resource in Mastermind is not a reflection of existing state, but rather a template that, when executed, creates the desired state.
{
"name":"app.example.com",
"action":"create",
"resource_name":"ec2_server",
"provider_name":"ec2_server",
"default_action":"create",
"aws_access_key_id":"abcd1234",
"aws_secret_access_key":"abcd1234",
"image_id":"ami-1234abcd",
"flavor_id":"m1.large",
"key_name":"default",
"security_groups":["default","app_servers"]
}
Resources can have dynamic attributes; that is, a resource's attribute can contain values from the Task data or another resource's attribute.
Given a Task's data attribute that contains the following JSON:
{
"aws":{
"aws_access_key_id":"1234abcd",
"aws_secret_access_key":"1234abcd"
}
}
You can access the above data with the following syntax: "attribute":"{{data::nested.data.attribute}}"
. For example, if we want to populate the aws_access_key_id
and aws_secret_access_key
with the task data, our Resource object would look like this:
{
"name":"app.example.com",
"action":"create",
"resource_name":"ec2_server",
"provider_name":"ec2_server",
"default_action":"create",
"aws_access_key_id":"{{data::aws.aws_access_key_id}}",
"aws_secret_access_key":"{{data::aws.aws_secret_access_key}}",
"image_id":"ami-1234abcd",
"flavor_id":"m1.large",
"key_name":"default",
"security_groups":["default","app_servers"]
}
You can also access other resources' attributes with "attribute":"{{resource[name]::attribute}}"
. Dynamic attributes may also be interpolated in strings using the handlebar brackets, {{}}
.
{
"name":"app-server",
"action":"create",
"resource_name":"ec2_server",
"provider_name":"ec2_server",
"default_action":"create",
"aws_access_key_id":"{{data::aws.aws_access_key_id}}",
"aws_secret_access_key":"{{data::aws.aws_secret_access_key}}",
"image_id":"ami-1234abcd",
"flavor_id":"m1.large",
"key_name":"default",
"security_groups":["default","app_servers"],
"public_ip_address":"192.168.100.100"
}
{
"name":"bootstrap-app-server",
"action":"execute",
"resource_name":"ssh",
"provider_name":"ssh",
"default_action":"execute",
"user":"ubuntu",
"key":"/home/admin/{{resource[app-sever]::key_file}}.pem"
"command":"/bin/bash /tmp/bootstrap-script.sh"
}
A resource has two states: compilation and execution. During compilation, a resource will fill in any dynamic attributes and validate all attributes. During execution, the resource will send itself to its provider for final processing and action.
A provider is the service that performs actions on your resources. Every resource has a provider. When a resource is executed, its attributes are compiled and sent to the provider to be processed. It's the provider's responsibility to validate that the resource being executed has all necessary attributes for the requested action.
A task is an ordered list of resources. When a task is ran, each resource is compiled and executed in sequence. Tasks can also be composed of other tasks. Tasks have a special "data" attribute that is a JSON (or Hash) object containing additional information that may be used by resources during compilation and execution.