covalence 0.0.1 → 0.7.9.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +164 -0
- data/README.md +489 -19
- data/TODO.md +14 -0
- data/lib/covalence.rb +41 -0
- data/lib/covalence/core/bootstrap.rb +8 -0
- data/lib/covalence/core/cli_wrappers/packer.yml +9 -0
- data/lib/covalence/core/cli_wrappers/packer_cli.rb +27 -0
- data/lib/covalence/core/cli_wrappers/popen_wrapper.rb +123 -0
- data/lib/covalence/core/cli_wrappers/terraform.yml +39 -0
- data/lib/covalence/core/cli_wrappers/terraform_cli.rb +119 -0
- data/lib/covalence/core/data_stores/hiera.rb +50 -0
- data/lib/covalence/core/entities/context.rb +38 -0
- data/lib/covalence/core/entities/environment.rb +24 -0
- data/lib/covalence/core/entities/input.rb +112 -0
- data/lib/covalence/core/entities/stack.rb +74 -0
- data/lib/covalence/core/entities/state_store.rb +65 -0
- data/lib/covalence/core/repositories/context_repository.rb +30 -0
- data/lib/covalence/core/repositories/environment_repository.rb +92 -0
- data/lib/covalence/core/repositories/input_repository.rb +56 -0
- data/lib/covalence/core/repositories/stack_repository.rb +89 -0
- data/lib/covalence/core/repositories/state_store_repository.rb +31 -0
- data/lib/covalence/core/services/hiera_syntax_service.rb +19 -0
- data/lib/covalence/core/services/packer_stack_tasks.rb +104 -0
- data/lib/covalence/core/services/terraform_stack_tasks.rb +212 -0
- data/lib/covalence/core/state_stores/atlas.rb +157 -0
- data/lib/covalence/core/state_stores/consul.rb +153 -0
- data/lib/covalence/core/state_stores/s3.rb +147 -0
- data/lib/covalence/environment_tasks.rb +328 -0
- data/lib/covalence/helpers/shell_interpolation.rb +28 -0
- data/lib/covalence/helpers/spec_dependencies.rb +21 -0
- data/lib/covalence/rake/rspec/envs_spec.rb +75 -0
- data/lib/covalence/rake/rspec/yaml_spec.rb +14 -0
- data/lib/covalence/spec_tasks.rb +59 -0
- data/lib/covalence/version.rb +3 -0
- metadata +344 -26
- data/.gitignore +0 -9
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -21
- data/Rakefile +0 -2
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/lib/prometheus_unifio.rb +0 -5
- data/lib/prometheus_unifio/version.rb +0 -3
- data/prometheus_unifio.gemspec +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6996b380a260e1574dddef9841685368579573823dd9df81ee8b2e2049b17ad6
|
4
|
+
data.tar.gz: 22b8030ef7c9ae4acd112fe3446958e04de60dc871e8c0582a7478ff972c3837
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 432db3aa484713ec86a56970402789b3e3b3b0c71877a16e7d5840b3546a40a56d5246b57b50514b1e85da5504a3f992c06b18f02bc975a33671f2d9654f633a
|
7
|
+
data.tar.gz: 9bd16e47bbab6d00b73c5ef87d61f5720b7e767380a21afdd82a9b31e49c2d02ce28d97d134c157371a0bf2cc2a089c339409e04ce9728d7706bf364b460e276
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
## Unreleased
|
2
|
+
* Add ability to toggle primary state store
|
3
|
+
* Add environment variable interpolation for input variables
|
4
|
+
* Add support for sops encryption / decryption of hierarchy data
|
5
|
+
|
6
|
+
## 0.7.8 (May 9, 2018)
|
7
|
+
IMPROVEMENTS:
|
8
|
+
- Added support for Terraform workspaces
|
9
|
+
|
10
|
+
## 0.7.7 (May 6, 2018)
|
11
|
+
BACKWARDS INCOMPATIBILITIES:
|
12
|
+
- Versions of Terraform prior to v0.11.4 are no longer supported.
|
13
|
+
|
14
|
+
IMPROVEMENTS:
|
15
|
+
- Extended shell interpolation for input values to support nesting and escaping
|
16
|
+
- Improved support for Terraform plugin caching
|
17
|
+
- Replaced deprecated `-force` option for Terraform `destroy` task with `-auto-approve=true`.
|
18
|
+
|
19
|
+
FIXES:
|
20
|
+
- Updated input processing to support nested complex types properly.
|
21
|
+
- Updated input processing to properly handle non-string values for non-complex input types.
|
22
|
+
|
23
|
+
## 0.7.6 (December 6, 2017)
|
24
|
+
IMPROVEMENTS:
|
25
|
+
- Terraform init failures were not being reported. Update spec tests to catch errors with 'terraform init'.
|
26
|
+
|
27
|
+
## 0.7.5 (October 12, 2017)
|
28
|
+
IMPROVEMENTS:
|
29
|
+
- Fix the sync command to call Terraform get prior to init command. This is required with new version of Terraform.
|
30
|
+
|
31
|
+
## 0.7.4 (September 26, 2017)
|
32
|
+
IMPROVEMENTS:
|
33
|
+
- Updated Covalence to work with Terraform 0.10.x. Updates were made in 0.10.x that requires all variables set for validate to run.
|
34
|
+
- Also added setting for the apply to auto approve. This will be required in upcoming releases and will prompt for input from user.
|
35
|
+
|
36
|
+
## 0.7.3 (June 20, 2017)
|
37
|
+
IMPROVEMENTS:
|
38
|
+
- Tasks within the 'ci' and 'spec' namespaces will no longer load all individual stack tasks like the 'all' namespace.
|
39
|
+
|
40
|
+
FIXES:
|
41
|
+
- Tasks in the reserved 'ci' and 'spec' namespaces were failing in the environments filter logic. These namespaces are not properly ignored.
|
42
|
+
|
43
|
+
## 0.7.2 (June 17, 2017)
|
44
|
+
IMPROVEMENTS:
|
45
|
+
- Added input logging for Packer stacks.
|
46
|
+
- Removed logic for driving Docker containers with Covalence. Default mode of operation is now within a container.
|
47
|
+
- Further merged Terraform and Packer internal structures.
|
48
|
+
- Various performance improvements in the way in which stacks are loaded and processed.
|
49
|
+
|
50
|
+
FIXES:
|
51
|
+
- Fixed Terraform `refresh` task.
|
52
|
+
|
53
|
+
## 0.7.1 (May 15, 2017)
|
54
|
+
IMPROVEMENTS:
|
55
|
+
- Updated Hiera to 3.3.1 to enable `list` and `map` lookups from within the data using the alias lookup function.
|
56
|
+
|
57
|
+
FIXES:
|
58
|
+
- Updated Packer `inspect` task to operate in a temporary directory, so that any generated assets are cleaned up after execution.
|
59
|
+
|
60
|
+
## 0.7.0 (May 15. 2017)
|
61
|
+
BACKWARDS INCOMPATIBILITIES:
|
62
|
+
- Terraform `apply` and `destroy` tasks will no longer include `plan` and `plan_destroy` respectively.
|
63
|
+
- The Packer stack `packer-module` parameter has been replaced by `module` for standardization with Terraform stacks.
|
64
|
+
- The Packer namespace `packer-template` parameter has been moved to the stack scope and is now a relative path to the module (e.g. `packer::build::packer-template: 'fully/qualified/path/template.json'` would become `mystack::packer-template: 'template.json'` for `mystack::module: 'fully/qualified/path'`)
|
65
|
+
- The Packer namespace `packer-targets` parameter has been removed.
|
66
|
+
- The Packer namespace `packer-vars` parameter has been replaced by `vars` for standardization with Terraform stacks.
|
67
|
+
- The `COVALENCE_TERRAFORM_DIR` and `COVALENCE_PACKER_DIR` environment variables now default to the same value as `COVALENCE_WORKSPACE` and are now deprecated.
|
68
|
+
|
69
|
+
FEATURES:
|
70
|
+
- Terraform input variables are now fed in via `-var-file` instead of individual `-var` arguments.
|
71
|
+
- Dependencies can now be specified at the stack scope using `<stack>::deps`, which is an Array of directory paths that are to be made available in the working directory. Paths are relative to the Covalence root directory.
|
72
|
+
- Added support for `list` and `map` input types.
|
73
|
+
|
74
|
+
IMPROVEMENTS:
|
75
|
+
- Exposed Terraform `refresh` command.
|
76
|
+
- Added `refresh` command at the environment and global scope.
|
77
|
+
- Added `format` command at the environment and global scope (#33).
|
78
|
+
- Added `plan` command at the global scope (#40).
|
79
|
+
|
80
|
+
FIXES:
|
81
|
+
- The `targets` namespace parameter is now properly ignored for Packer stacks.
|
82
|
+
- Environment spec tasks now properly account for execution errors (#43)
|
83
|
+
|
84
|
+
## 0.6.1 (April 8, 2017)
|
85
|
+
IMPROVEMENTS:
|
86
|
+
- Stack sync no longer sources modules when retrieving state.
|
87
|
+
|
88
|
+
FIXES:
|
89
|
+
- Fixed regression in sourcing modules from relative paths.
|
90
|
+
|
91
|
+
## 0.6.0 (April 8, 2017)
|
92
|
+
BACKWARDS INCOMPATIBILITIES:
|
93
|
+
- Versions of Terraform prior to v0.9.0 are no longer supported.
|
94
|
+
|
95
|
+
FEATURES:
|
96
|
+
- Added support for remote backends.
|
97
|
+
|
98
|
+
IMPROVEMENTS:
|
99
|
+
- Log level now configurable via the COVALENCE_LOG environment variable.
|
100
|
+
|
101
|
+
## 0.5.3 (October 19, 2016)
|
102
|
+
FIXES:
|
103
|
+
- terraform destroy tasks receive the `-force` param instead of `-input=false`.
|
104
|
+
- `env:spec` only does format checking on the specific path module, not the dependent modules referenced underneath.
|
105
|
+
|
106
|
+
## 0.5.2 (October 12, 2016)
|
107
|
+
FEATURES:
|
108
|
+
- Packer can now be ran from docker containers. Follows the same conventions as terraform by specifying `PACKER_IMG`, `PACKER_CMD`
|
109
|
+
|
110
|
+
FIXES:
|
111
|
+
- More minor PopenWrapper return code fixes
|
112
|
+
- Allow packer to deal with shell interpolation values via the same terraform shell interpolation prefix: `$(...`
|
113
|
+
|
114
|
+
|
115
|
+
## 0.5.1 (October 10, 2016)
|
116
|
+
|
117
|
+
FEATURES:
|
118
|
+
- Packer build and validate now accept runtime arguments, ie `rake example:packer-module:build -- -var "foo=baz"`
|
119
|
+
|
120
|
+
FIXES:
|
121
|
+
- PopenWrapper issues with mismatching exit-codes for happy path runs.
|
122
|
+
- Terraform remote config needed to ignore exitcodes in a few places where it was being called as a precaution or for 0.6.x compatibility reasons.
|
123
|
+
|
124
|
+
## 0.5.0 (October 5, 2016)
|
125
|
+
|
126
|
+
FEATURES:
|
127
|
+
- Better control of running terraform/packer subprocesses:
|
128
|
+
- Ctrl-C breaks out of Terraform/Packer commands (also suppresses the normal debugging output from packer/terraform when they're natively sent a SIGINT)
|
129
|
+
- Debug capability built into the rake task runs to manually confirm each step
|
130
|
+
|
131
|
+
IMPROVEMENTS:
|
132
|
+
- Allow packer stacks to standalone
|
133
|
+
- Finer grain control around terraform exit-codes and when to abort the rake task
|
134
|
+
|
135
|
+
FIXES:
|
136
|
+
- Non-zero error codes now return properly from rake tasks (if the
|
137
|
+
underlying CLI command did not choose to ignore error codes)
|
138
|
+
- Packer runs generate temp JSON files in the packer module directory,
|
139
|
+
allows the use of `{{ template_dir }}` for script locations.
|
140
|
+
|
141
|
+
## 0.4.3 (September 27, 2016)
|
142
|
+
FIXES:
|
143
|
+
- Handle new terraform API output formats for remote inputs
|
144
|
+
|
145
|
+
## 0.4.2 (September 26, 2016)
|
146
|
+
FIXES:
|
147
|
+
- Terraform remote config now works from the module path instead of a temporary directory, which should ensure that the state gets read correctly when ran from a docker context
|
148
|
+
|
149
|
+
## 0.4.1 (September 25, 2016)
|
150
|
+
|
151
|
+
FEATURES:
|
152
|
+
- Terraform rake tasks now accept runtime arguments, ie: `rake example:module_test:plan[1,2] -- --no-drift --help`
|
153
|
+
|
154
|
+
IMPROVEMENTS:
|
155
|
+
- Change COVALENCE_CONFIG to default to covalence.yaml
|
156
|
+
- Gem spec enforce Ruby version >= 2.0.0
|
157
|
+
|
158
|
+
FIXES:
|
159
|
+
- Terraform path handling when terraform is ran in a docker container context. Volume is mounted at the TERRAFORM_DIR base, workdir is a relative subpath to the TERRAFORM_DIR base.
|
160
|
+
- Fixed shell interpolation bug for terraform 0.7.x inputs, which currently forces string types.
|
161
|
+
|
162
|
+
## 0.4.0 (September 14, 2016)
|
163
|
+
|
164
|
+
* Initial release
|
data/README.md
CHANGED
@@ -1,41 +1,511 @@
|
|
1
|
-
#
|
1
|
+
# Covalence
|
2
|
+
[![CircleCI](https://circleci.com/gh/unifio/covalence.svg?style=svg)](https://circleci.com/gh/unifio/covalence)
|
3
|
+
[![Dependency Status](https://gemnasium.com/badges/github.com/unifio/covalence.svg)](https://gemnasium.com/github.com/unifio/covalence)
|
2
4
|
|
3
|
-
|
5
|
+
A tool for the management and orchestration of data used by HashiCorp infrastructure tooling.
|
4
6
|
|
5
|
-
|
7
|
+
<img src="./images/bond.jpg">
|
6
8
|
|
7
|
-
|
9
|
+
# Why Covalence?
|
8
10
|
|
9
|
-
|
11
|
+
## Separation of data and code
|
12
|
+
Covalence allows for Terraform [Backends](https://www.terraform.io/docs/backends/) and variable inputs to be source agnostic, so your modules aren't hard coded to specific data sources.
|
13
|
+
|
14
|
+
## Code / data reuse
|
15
|
+
No more copying around of tfvars files or creating glue code to tie together modules. Covalence will assemble the proper data inputs and modules for the contexts you want.
|
16
|
+
|
17
|
+
## Infrastructure as layers
|
18
|
+
We have found that there is tremendous value in decoupling our infrastructure into layers and coordinating those layers with data. The overhead of managing layers adds up quickly though and introduces risk for human error in coordinating data and state. Coavalence models each context as an executable stack, so that data and state are always managed properly.
|
19
|
+
|
20
|
+
# FAQ
|
21
|
+
|
22
|
+
### Does using Covalence impact my ability to use my code with the HashiCorp tools natively?
|
23
|
+
No. Covalence is a superset of functionality on top of the native HashiCorp tools. While it is opinionated, it does not require any fundamental departure from HashiCorp best practices that would render it unusable with the stand alone products.
|
24
|
+
|
25
|
+
### Why Hiera?
|
26
|
+
Covalence was a tool born of necessity. For those who were early adopters of Terraform, you know what I'm talking about.
|
27
|
+
|
28
|
+
The first Covalence data backend was a single YAML file. That quickly failed to scale as we began using the tool to decouple more and more layers. We needed to move to something more flexible. As you might have guessed, the first projects we used Covalence with also included Puppet. Puppet suffered from similar data management issues that impacted code complexity and reusability. Given that our target users were already comfortable with Hiera and we were using Ruby, it was an obvious fit.
|
29
|
+
|
30
|
+
If you're not familiar with Hiera, you'll want to read up on it [here](https://puppet.com/docs/puppet/5.4/hiera_intro.html). Covalence uses Hiera v3, as v4 and up are no longer separate from Puppet.
|
31
|
+
|
32
|
+
# Requirements
|
33
|
+
|
34
|
+
* [Bash](https://www.gnu.org/software/bash/) shell environment. Windows users, you will need the [Linux subsystem](https://docs.microsoft.com/en-us/windows/wsl/install-win10) installed.
|
35
|
+
* [Docker](https://docs.docker.com/engine/installation/)
|
36
|
+
|
37
|
+
# Quick Start
|
38
|
+
|
39
|
+
* Securely download [covalence](https://s3.amazonaws.com/unifio-covalence/get_covalence/covalence) and add to the `bin` directory of your infrastructure repository or directory.
|
40
|
+
* Change the mode of the file to allow execution: `chmod +x bin/covalence`
|
41
|
+
* Execute `bin/covalence`. This will download the most current version of the launcher script and return a usage statement to the command line. The launcher should be committed to source control.
|
42
|
+
|
43
|
+
For example:
|
44
|
+
|
45
|
+
```
|
46
|
+
|-- bin
|
47
|
+
| |-- covalence
|
48
|
+
| |-- .covalence
|
49
|
+
| |-- launcher
|
50
|
+
...
|
51
|
+
```
|
52
|
+
|
53
|
+
To begin using Covalence, some configuration is required. The following files are required:
|
54
|
+
|
55
|
+
```
|
56
|
+
|-- bin
|
57
|
+
| |-- covalence
|
58
|
+
|-- covalence.yaml
|
59
|
+
|-- Rakefile
|
60
|
+
...
|
61
|
+
```
|
62
|
+
|
63
|
+
See [example](./example) for a minimal configuration.
|
64
|
+
|
65
|
+
While the `.env.covalence` and `.env.docker` files are not a hard requirement, they are the preferred method of overriding values in the Covalence launcher as well as configuring tools within the container. Sample files have been provided as a reference, but many additional options are available.
|
66
|
+
|
67
|
+
# Configure Your Rakefile
|
68
|
+
|
69
|
+
The minimal configuration for your Rakefile is as follows:
|
10
70
|
|
11
71
|
```ruby
|
12
|
-
|
72
|
+
require 'rake'
|
73
|
+
require 'rspec/core/rake_task'
|
74
|
+
require 'covalence/environment_tasks'
|
75
|
+
require 'covalence/spec_tasks'
|
76
|
+
```
|
77
|
+
|
78
|
+
This file is exposed so that you can add other rake tasks as desired. See [example/Rakefile](./example/Rakefile) for an example of extending the Rakefile. Note, if you add dependencies on gems that are not present in the default container, you will need to add them.
|
79
|
+
|
80
|
+
## Reserved Namespaces
|
81
|
+
|
82
|
+
In addition to avoiding any task names that will overlap your environment names, there are several additional tasks built into Covalence.
|
83
|
+
|
84
|
+
### All
|
85
|
+
|
86
|
+
The `all` environment allows for the execution of actions against all configured stacks in all configured environments.
|
87
|
+
|
88
|
+
For example:
|
89
|
+
|
90
|
+
```bash
|
91
|
+
$ bin/covalence all:format
|
92
|
+
```
|
93
|
+
|
94
|
+
would execute `terraform fmt` on all configured stacks in all configured environments.
|
95
|
+
|
96
|
+
Note: Passing a task of the form `<environment>:<action>` will have the same effect on all stacks for the specified environment.
|
97
|
+
|
98
|
+
### RSpec
|
99
|
+
|
100
|
+
Unit tests for all tasks and tools.
|
101
|
+
|
102
|
+
The suite can be executed with the following command:
|
103
|
+
|
104
|
+
```bash
|
105
|
+
$ bin/covalence spec
|
106
|
+
```
|
107
|
+
|
108
|
+
### UAT
|
109
|
+
|
110
|
+
User acceptance tests targeting execution in a continuous integration (CI) environment.
|
111
|
+
|
112
|
+
The suite can be executed with the following command:
|
113
|
+
|
114
|
+
```bash
|
115
|
+
$ bin/covalence ci
|
116
|
+
```
|
117
|
+
|
118
|
+
# Configure Your Data Hierarchy
|
119
|
+
|
120
|
+
If you're not familiar with Hiera, you'll want to start your reading [here](https://puppet.com/docs/hiera/3.3/index.html).
|
121
|
+
|
122
|
+
The hierarchy is driven by the **covalence.yaml** configuration. It is important to note that it is not a requirement that all directories and files in the hierarchy exist, the hierarchy simply dictates an order of priority for looking up values.
|
123
|
+
|
124
|
+
An exmaple configuration is as follows:
|
125
|
+
|
126
|
+
**data/covalence.yaml**
|
127
|
+
```yaml
|
128
|
+
---
|
129
|
+
:backends:
|
130
|
+
- yaml # Data store type. Also supports JSON out-of-the-box.
|
131
|
+
# Can support multiple concurrently.
|
132
|
+
|
133
|
+
:logger: noop # Suppress Hiera logging. Can be re-enabled by
|
134
|
+
# commenting this line out.
|
135
|
+
|
136
|
+
:merge_behavior: 'deeper' # Merge strategy for Hash lookups.
|
137
|
+
|
138
|
+
:hierarchy: # Data store hierarchy. Lookups will traverse the
|
139
|
+
# hierarchy in order from top to bottom.
|
140
|
+
- "environments/%{environment}"
|
141
|
+
- "stacks/%{stack}"
|
142
|
+
- "global"
|
143
|
+
- "environments"
|
144
|
+
|
145
|
+
:yaml: # Configuration specific to the YAML backend.
|
146
|
+
:datadir: data # Root directory of the YAML data store.
|
147
|
+
|
148
|
+
```
|
149
|
+
|
150
|
+
The hierarchy can be changed, but the only two context variables currently supported are the `environment` and `stack` names.
|
151
|
+
|
152
|
+
# Create a Stack
|
153
|
+
|
154
|
+
## Terraform
|
155
|
+
|
156
|
+
A Covalence stack is a pairing of data for a single context with a module. A Terraform stack must minimally include a module mapping as well as a state storage configuration.
|
157
|
+
|
158
|
+
For example, let's create a stack called vpc. Given our hierarchy above, let's add a `data/stacks/vpc.yaml` file and configure it as follows:
|
159
|
+
|
160
|
+
**data/stacks/vpc.yaml**
|
161
|
+
```yaml
|
162
|
+
---
|
163
|
+
# VPC stack
|
164
|
+
|
165
|
+
# Terraform module
|
166
|
+
vpc::module: 'terraform/vpc' # Terraform module directory if different than
|
167
|
+
# the stack name. The key is prepended with the
|
168
|
+
# stack name, as module assignment is stack specific.
|
169
|
+
|
170
|
+
# State storage
|
171
|
+
vpc::state: # Terraform backend configuration. The key is
|
172
|
+
# prepended with the stack name, as the backend
|
173
|
+
# configuration is stack specific. The `state` map
|
174
|
+
# accepts a list of Terraform backend configuration
|
175
|
+
# maps. The first in the list is considered the
|
176
|
+
# primary backend while subsequent entries are
|
177
|
+
# targets for replication. Backend names and
|
178
|
+
# parameters map directly to what is supported by
|
179
|
+
# Terraform. Covalence will generate the code
|
180
|
+
# associated with backend initialization at runtime.
|
181
|
+
|
182
|
+
- s3: # Backend type.
|
183
|
+
bucket: "%{alias('tf_state_bucket')}" # Example for looking up a value from another
|
184
|
+
# context within the hierarchy (e.g. data/environments/test.yaml)
|
185
|
+
encrypt: true
|
186
|
+
name: "%{environment}/%{stack}" # Example of interpolating context specific
|
187
|
+
# variables.
|
188
|
+
region: "%{alias('tf_state_region')}"
|
189
|
+
role_arn: "%{alias('cross_acct_role_arn')}"
|
190
|
+
- consul: # Secondary backend configuration
|
191
|
+
address: 'consul.example.com:8500'
|
192
|
+
name: "%{environment}/%{stack}"
|
193
|
+
|
194
|
+
# Workspace
|
195
|
+
vpc::workspace: 'blue' # Terraform workspace configuration. The key is
|
196
|
+
# prepended with the stack name, as the backend
|
197
|
+
# configuration is stack specific.
|
198
|
+
|
199
|
+
## Dependencies
|
200
|
+
vpc::deps: # List of paths to files or directories outside
|
201
|
+
# of the module directory that are to be copied
|
202
|
+
# into the working directory of the module during
|
203
|
+
# Covalence execution. An example of this would be
|
204
|
+
# an SSH key for cloning a private Terraform
|
205
|
+
# module.
|
206
|
+
- '.ssh'
|
207
|
+
|
208
|
+
# Execution targets
|
209
|
+
terraform::vpc::targets: # Resource targeting. The key is prepended with
|
210
|
+
# the module name, as target assignment can be
|
211
|
+
# shared across contexts.
|
212
|
+
|
213
|
+
az0: # Context name
|
214
|
+
- 'module.az0' # Resource target (e.g. terraform plan -target=module.az0)
|
215
|
+
az1:
|
216
|
+
- 'module.az1'
|
217
|
+
|
218
|
+
# Additional arguments
|
219
|
+
terraform::vpc::args: '-no-color' # Additional arguments to be passed to Terraform.
|
220
|
+
# The key is prepended with the module name, as
|
221
|
+
# arguments can be shared across contexts.
|
222
|
+
|
223
|
+
# Input variables
|
224
|
+
terraform::vpc::vars: # Input variables. The key is prepended with the
|
225
|
+
# module name, as variable assignment can be shared
|
226
|
+
# across contexts.
|
227
|
+
|
228
|
+
region: 'us-east-1' # Short form input string
|
229
|
+
stack_item_label: 'testing'
|
230
|
+
```
|
231
|
+
|
232
|
+
As indicated in the comments above, keys that are stack specific are prepended with the stack name as opposed to the module name. Currently, this include the `module` and `state` parameters only. All other keys will be prepended with the module name, allowing for data sharing between stacks that are based on the same module.
|
233
|
+
|
234
|
+
To demonstrate this, let's add a `data/environments/test.yaml` file and configure it as follows:
|
235
|
+
|
236
|
+
**data/environments/test.yaml**
|
237
|
+
```yaml
|
238
|
+
---
|
239
|
+
# Test environment
|
240
|
+
|
241
|
+
# VPC input variables
|
242
|
+
terraform::vpc::vars:
|
243
|
+
region: 'us-west-2'
|
244
|
+
```
|
245
|
+
|
246
|
+
Let's also go ahead and define some environments by adding the following to `data/environments.yaml`:
|
247
|
+
|
248
|
+
**data/environments.yaml**
|
249
|
+
```yaml
|
250
|
+
---
|
251
|
+
environments:
|
252
|
+
test:
|
253
|
+
- vpc
|
254
|
+
staging:
|
255
|
+
- vpc
|
256
|
+
```
|
257
|
+
|
258
|
+
Our configuration now has two actionable contexts of the VPC stack; `test` and `staging`.
|
259
|
+
|
260
|
+
A call to `bin/covalence -l` will now produce output similar to the following:
|
261
|
+
|
262
|
+
```bash
|
263
|
+
$ bin/covalence -l
|
264
|
+
staging:vpc:apply # Apply changes to the vpc stack of the staging environment
|
265
|
+
staging:vpc:destroy # Destroy the vpc stack of the staging environment
|
266
|
+
staging:vpc:format # Format the vpc stack of the staging environment
|
267
|
+
staging:vpc:plan # Create execution plan for the vpc stack of the staging environment
|
268
|
+
staging:vpc:plan_destroy # Create destruction plan for the vpc stack of the staging environment
|
269
|
+
staging:vpc:refresh # Refresh the vpc stack of the staging environment
|
270
|
+
staging:vpc:sync # Synchronize state stores for the vpc stack of the staging environment
|
271
|
+
staging:vpc:verify # Verify the vpc stack of the staging environment
|
272
|
+
test:vpc:apply # Apply changes to the vpc stack of the test environment
|
273
|
+
test:vpc:destroy # Destroy the vpc stack of the test environment
|
274
|
+
test:vpc:format # Format the vpc stack of the test environment
|
275
|
+
test:vpc:plan # Create execution plan for the vpc stack of the test environment
|
276
|
+
test:vpc:plan_destroy # Create destruction plan for the vpc stack of the test environment
|
277
|
+
test:vpc:refresh # Refresh the vpc stack of the test environment
|
278
|
+
test:vpc:sync # Synchronize state stores for the vpc stack of the test environment
|
279
|
+
test:vpc:verify # Verify the vpc stack of the test environment
|
280
|
+
```
|
281
|
+
|
282
|
+
If we were to execute the `staging:vpc:plan` task, we will see that the VPC is targeted for the `us-east-1` region. However, if we execute the `test:vpc:plan` task, we will see that the VPC is targeted for the `us-west-2` region.
|
283
|
+
|
284
|
+
If we review our hierarchy, we see that values in the `environments` directory take precedence over those in the `stacks` directory. With the addition of `data/environments/test.yaml`, we have introduced variable overrides for the stack defaults in the context of the test environment. As there is no `data/environments/staging.yaml`, the stack default of `us-east-1` is the first value discovered when traversing the hierarchy in the context of the staging environment.
|
285
|
+
|
286
|
+
## Packer
|
287
|
+
|
288
|
+
Packer stacks are managed in the same manner as Terraform stacks within Covalence, but have different configuration requirements. A Packer stack must minimally include a module and build template mapping.
|
289
|
+
|
290
|
+
```yaml
|
291
|
+
---
|
292
|
+
# ECS artifact defaults
|
293
|
+
|
294
|
+
## Module
|
295
|
+
ecs-artifact::module: 'packer/ecs' # Packer module directory if different than
|
296
|
+
# the stack name. The key is prepended with the
|
297
|
+
# stack name, as module assignment is stack specific.
|
298
|
+
# Assets associated with the build (e.g. scripts)
|
299
|
+
# should be co-located with the build template within
|
300
|
+
# the module path.
|
301
|
+
|
302
|
+
## Build template
|
303
|
+
ecs-artifact::packer-template: 'aws-linux-ecs.json' # Relative path to the Packer build template
|
304
|
+
# from within the module directory.
|
305
|
+
|
306
|
+
## Dependencies
|
307
|
+
ecs-artifact::deps: # List of paths to files or directories outside
|
308
|
+
# of the module directory that are to be copied
|
309
|
+
# into the working directory of the module during
|
310
|
+
# Covalence execution. An example of this would be
|
311
|
+
# a common suite of unit tests that exist above
|
312
|
+
# the context of each individual Packer build.
|
313
|
+
- 'serverspec'
|
314
|
+
|
315
|
+
## Input variables
|
316
|
+
packer::ecs::vars:
|
317
|
+
region: "%{alias('region')}" # Example for looking up a value from another
|
318
|
+
# context within the hierarchy (e.g. data/environments/test.yaml)
|
319
|
+
version: '1.0.0'
|
320
|
+
```
|
321
|
+
|
322
|
+
Note: Covalence provides support for YAML based Packer build templates. This capability is not compatible with native Packer, which only supports JSON.
|
323
|
+
|
324
|
+
# Complex Inputs
|
325
|
+
|
326
|
+
Covalence adds additional data processing capabilities on top of Hiera.
|
327
|
+
|
328
|
+
The most basic input is a string. The following is an example of the short form notation for a string input.
|
329
|
+
|
330
|
+
```yaml
|
331
|
+
terraform::example::vars:
|
332
|
+
label: 'test'
|
333
|
+
```
|
334
|
+
|
335
|
+
Standard YAML notation for lists and maps will work as expected as well:
|
336
|
+
|
337
|
+
```yaml
|
338
|
+
terraform::example::vars:
|
339
|
+
labels:
|
340
|
+
- 'test0'
|
341
|
+
- 'test1'
|
342
|
+
- 'test2'
|
343
|
+
samples:
|
344
|
+
terraform: 'testing'
|
345
|
+
packer: 'testing'
|
346
|
+
```
|
347
|
+
|
348
|
+
The long form for the same inputs are as follows:
|
349
|
+
|
350
|
+
```yaml
|
351
|
+
terraform::example::vars:
|
352
|
+
label:
|
353
|
+
type: 'string'
|
354
|
+
value: 'test'
|
355
|
+
labels:
|
356
|
+
type: 'list'
|
357
|
+
value:
|
358
|
+
- 'test0'
|
359
|
+
- 'test1'
|
360
|
+
- 'test2'
|
361
|
+
samples:
|
362
|
+
type: 'map'
|
363
|
+
value:
|
364
|
+
terraform: 'testing'
|
365
|
+
packer: 'testing'
|
13
366
|
```
|
14
367
|
|
15
|
-
|
368
|
+
Maps are processed by Covalence as complex inputs. The `type` parameter is reserved for identifying the type of input. For simple types, like those shown above, the long format is unnecessary in most instances. However, it is the basis for invoking more complex lookups via integrations to other tools.
|
16
369
|
|
17
|
-
|
370
|
+
For example, the following is an example of a lookup from a Terraform state file stored on S3:
|
18
371
|
|
19
|
-
|
372
|
+
```yaml
|
373
|
+
terraform::ecs::cluster::vars:
|
374
|
+
vpc_id:
|
375
|
+
type: 's3.state'
|
376
|
+
bucket: "%{alias('tf_state_bucket')}"
|
377
|
+
document: "%{environment}/vpc/terraform.tfstate"
|
378
|
+
key: 'vpc_id'
|
379
|
+
```
|
380
|
+
|
381
|
+
See the Integrations section below for a list of supported lookups.
|
382
|
+
|
383
|
+
Covalence will also perform UNIX shell interpolation on inputs of the following form:
|
384
|
+
|
385
|
+
```yaml
|
386
|
+
terraform::ecs::cluster::vars:
|
387
|
+
app_label: "$(echo 'this is a test')"
|
388
|
+
```
|
389
|
+
|
390
|
+
# Integrations
|
391
|
+
|
392
|
+
## Terraform Enterprise (formerly Atlas)
|
393
|
+
Module for interacting with the Terraform Enterprise backend.
|
394
|
+
|
395
|
+
### Supported operations
|
396
|
+
|
397
|
+
| K/V Read | K/V Write | Remote State Read | State Storage Backend |
|
398
|
+
|:--------:|:---------:|:-----------------:|:---------------------:|
|
399
|
+
| <img src="./images/checkmark.png"> | | <img src="./images/checkmark.png"> | <img src="./images/checkmark.png"> |
|
400
|
+
|
401
|
+
### Configuration parameters
|
402
|
+
|
403
|
+
| ENV Variable | Default | Description |
|
404
|
+
| ------------------------ | --------------------------------- | ------------------------------------ |
|
405
|
+
| ATLAS_TOKEN | | HTTP authentication token. |
|
406
|
+
|
407
|
+
### Usage
|
408
|
+
|
409
|
+
Artifacts:
|
410
|
+
|
411
|
+
```yaml
|
412
|
+
ami:
|
413
|
+
type: 'atlas.artifact'
|
414
|
+
slug: 'unifio/app/amazon.ami'
|
415
|
+
version: 'latest'
|
416
|
+
key: 'region.us-east-1'
|
417
|
+
```
|
418
|
+
|
419
|
+
State Outputs:
|
420
|
+
|
421
|
+
```yaml
|
422
|
+
vpc_id:
|
423
|
+
type: 'atlas.state'
|
424
|
+
stack: 'unifio/vpc'
|
425
|
+
key: 'vpc_id'
|
426
|
+
```
|
20
427
|
|
21
|
-
|
428
|
+
## Consul
|
429
|
+
Module for interacting with the Consul backend.
|
22
430
|
|
23
|
-
|
431
|
+
### Supported operations
|
24
432
|
|
25
|
-
|
433
|
+
| K/V Read | K/V Write | Remote State Read | State Storage Backend |
|
434
|
+
|:--------:|:---------:|:-----------------:|:---------------------:|
|
435
|
+
| <img src="./images/checkmark.png"> | | <img src="./images/checkmark.png"> | <img src="./images/checkmark.png"> |
|
26
436
|
|
27
|
-
|
437
|
+
### Configuration parameters
|
28
438
|
|
29
|
-
|
439
|
+
| ENV Variable | Default | Description |
|
440
|
+
| ------------------------ | --------------------------------- | ------------------------------------ |
|
441
|
+
| CONSUL_HTTP_ADDR | | DNS name and port of your Consul endpoint specified in the format dnsname:port. Defaults to the local agent HTTP listener. |
|
442
|
+
| CONSUL_HTTP_TOKEN | | HTTP authentication token |
|
30
443
|
|
31
|
-
|
444
|
+
### Usage
|
32
445
|
|
33
|
-
|
446
|
+
Keys:
|
447
|
+
|
448
|
+
```yaml
|
449
|
+
ami:
|
450
|
+
type: 'consul.key'
|
451
|
+
key: 'unifio/app/amazon.ami'
|
452
|
+
```
|
453
|
+
|
454
|
+
State Outputs:
|
455
|
+
|
456
|
+
```yaml
|
457
|
+
vpc_id:
|
458
|
+
type: 'consul.state'
|
459
|
+
stack: 'unifio/vpc'
|
460
|
+
key: 'vpc_id'
|
461
|
+
```
|
462
|
+
|
463
|
+
## S3
|
464
|
+
Module for interacting with the AWS Simple Storage Service (S3) backend.
|
465
|
+
|
466
|
+
### Supported operations
|
467
|
+
|
468
|
+
| K/V Read | K/V Write | Remote State Read | State Storage Backend |
|
469
|
+
|:--------:|:---------:|:-----------------:|:---------------------:|
|
470
|
+
| <img src="./images/checkmark.png"> | | <img src="./images/checkmark.png"> | <img src="./images/checkmark.png"> |
|
471
|
+
|
472
|
+
### Configuration parameters
|
473
|
+
|
474
|
+
| ENV Variable | Default | Description |
|
475
|
+
| ------------------------ | --------------------------------- | ------------------------------------ |
|
476
|
+
| AWS_ACCESS_KEY_ID | | AWS access key. |
|
477
|
+
| AWS_SECRET_ACCESS_KEY | | AWS secret key. Access and secret key variables override credentials stored in credential and config files. |
|
478
|
+
| AWS_REGION | | AWS region. This variable overrides the default region of the in-use profile, if set. |
|
479
|
+
| AWS_PROFILE | | AWS profile. For use with with a credential file. |
|
480
|
+
|
481
|
+
### Usage
|
482
|
+
|
483
|
+
Keys:
|
484
|
+
|
485
|
+
```yaml
|
486
|
+
docker_image:
|
487
|
+
type: 's3.key'
|
488
|
+
bucket: 'artifact-registry'
|
489
|
+
document: 'app-prod.json'
|
490
|
+
key: 'id'
|
491
|
+
```
|
492
|
+
|
493
|
+
State Outputs:
|
494
|
+
|
495
|
+
```yaml
|
496
|
+
vpc_id:
|
497
|
+
type: 's3.state'
|
498
|
+
bucket: 'terraform-state'
|
499
|
+
document: 'production/vpc/terraform.tfstate'
|
500
|
+
key: 'vpc_id'
|
501
|
+
```
|
34
502
|
|
35
|
-
|
503
|
+
# Build From Source
|
36
504
|
|
505
|
+
Covalence is packaged as a Ruby Gem.
|
37
506
|
|
38
|
-
|
507
|
+
Execute the following to build the gem:
|
39
508
|
|
40
|
-
|
509
|
+
`$ gem build covalence.gemspec`
|
41
510
|
|
511
|
+
Gem artifacts are hosted at https://repo.fury.io/unifio/.
|