builderator 1.1.9 → 1.1.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,245 +0,0 @@
1
- Configuration DSL
2
- =================
3
-
4
- Builderator's configuration language is a Ruby DSL, composed of `attributes`, which are grouped into `namespaces`. A `namespace` may be singular, or it may be part of a `collection`, in which case more than one named entry may be defined with the same `namespace`.
5
-
6
- Namespaces and collections can accessed with blocks, or with a fluent interface:
7
-
8
- ```ruby
9
- aws do |a|
10
- a.region = 'us-west-1'
11
- end
12
-
13
- ## Is the same as
14
- aws.region = 'us-west-1'
15
- ```
16
-
17
- Collections are sets of named items. Like namespaces, they can be accessed with blocks, or a fluent interface:
18
-
19
- ```ruby
20
- profile :default do |default_profile|
21
- default_profile.chef.run_list 'apt:default', 'redis:server', 'app::server'
22
- end
23
-
24
- profile(:default).chef.environment 'development'
25
- profile(:prod).chef.environment 'production'
26
- ```
27
-
28
- In the example above, the same collection item is accessed twice. A second item is also defined in the same collection. The final result looks like:
29
-
30
- ```json
31
- {
32
- "profile": {
33
- "default": {
34
- "chef": {
35
- "run_list": ["apt:default", "redis:server", "app::server"],
36
- "environment": "development"
37
- }
38
- },
39
- "prod": {
40
- "chef": {
41
- "environment": "production"
42
- }
43
- }
44
- }
45
- }
46
- ```
47
-
48
- Collections and namespaces may be nested indefinitely.
49
-
50
- ## Extending Collection Items
51
-
52
- A collection item can extend another item using a hash-notation:
53
-
54
- ```ruby
55
- profile :prod => Config.profile(:default) do |prod|
56
- prod.chef.environment = 'production'
57
- end
58
- ```
59
-
60
- Following the example, above, the `prod` profile will now be pre-populated with all of the values in the `default` profile, which can be overridden:
61
-
62
- ```json
63
- {
64
- "profile": {
65
- "default": {
66
- "chef": {
67
- "run_list": ["apt:default", "redis:server", "app::server"],
68
- "environment": "development"
69
- }
70
- },
71
- "prod": {
72
- "chef": {
73
- "run_list": ["apt:default", "redis:server", "app::server"],
74
- "environment": "production"
75
- }
76
- }
77
- }
78
- }
79
- ```
80
-
81
- ## List-type Attributes
82
-
83
- Some configuration attributes are actually ordered sets of values. These are referred to as `list-type` attributes, and have some additional options:
84
-
85
- ```ruby
86
- chef.run_list 'apt:default', :mode => :override
87
- ```
88
-
89
- The `:mode` parameter tells the configuration manager how how to compile a list-type attribute that is defined in two or more layers, or is modified in an extended collection item. Currently, two modes are implemented:
90
-
91
- * `:override` - Instructs the compiler to discard any elements that have been loaded from lower layers. This does not have any effect upon the behavior of the same attribute in higher layers, meaning that the current layer's override may be appended to or overridden by future layers, according to their `mode` parameter.
92
- * `:union` - Default behavior. Instructs the compiler to perform a set-union between the current layer's elements and the current set of elements compiled from lower layers.
93
-
94
- List-type attributes may also have an `appender method`, which allows elements to be appended to the current set _in that layer_. **List-type attributes do not have an `=` setter.**
95
-
96
- Because `chef.run_list` is a list-type attribute, we can tell Builderator to override the `default` profile's `run_list`:
97
-
98
- ```ruby
99
- profile :prod => Config.profile(:default) do |prod|
100
- prod.chef.environment = 'production'
101
- prod.chef.run_list 'apt:default', 'redis:server', 'app::server', 'app::tls', :mode => :override
102
- end
103
- ```
104
-
105
- We could also append to `default`'s `run_list` without modifying `default`:
106
-
107
- ```ruby
108
- profile :prod => Config.profile(:default) do |prod|
109
- prod.chef.environment = 'production'
110
- prod.chef.run_list_item 'app::tls'
111
- end
112
- ```
113
-
114
- Both of the above will result in the same compiled configuration:
115
-
116
- ```json
117
- {
118
- "profile": {
119
- "default": {
120
- "chef": {
121
- "run_list": ["apt:default", "redis:server", "app::server"],
122
- "environment": "development"
123
- }
124
- },
125
- "prod": {
126
- "chef": {
127
- "run_list": ["apt:default", "redis:server", "app::server", "app::tls"],
128
- "environment": "production"
129
- }
130
- }
131
- }
132
- }
133
- ```
134
-
135
- ## Helper Methods
136
-
137
- * `lookup(source, query)` - Query an external data-source for a value inline.
138
- * Source `:image`: Return an array of EC2 instances, sorted by `creation_date` (See http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Client.html#describe_images-instance_method)
139
-
140
- * `vendored(name, path)` - Return the absolute path to `path` in the named vendor resource. _ Hint: Use this helper to reference Builderator policy files and Chef data_bag and environment sources in an external repository._
141
-
142
- * `relative(path)` - Return the absolute path to `path` relative to the calling Buildfile _Hint: Use this helper to reference templates included with a vendored policy._
143
-
144
- ## Configuration Parameters
145
-
146
- * [Namespace `cookbook`](configuration/cookbook.md)
147
- * [Collection `profile`](configuration/profile.md)
148
-
149
- * `build_name, required: true` The name of the build
150
- * `build_number` Optional reference to the CI build number for this release
151
- * `build_url` Optional link the CI page for this release
152
- * `description` A short human-readable description of the build
153
- * `version` The version of this release of the build. Auto-populated by `autoversion` by default
154
- * `cleanup` Enable post-build cleanup tasks. Default `true`
155
-
156
- ### Namespace `autoversion`
157
-
158
- * `create_tags` During a release, automatically create and push new SCM tags
159
- * `search_tags` Use SCM tags to determine the current version of the build
160
-
161
- ### Namespace `chef`
162
-
163
- Global configurations for chef provisioners in Vagrant and Packer
164
-
165
- * `log_level` Chef client/solo log level
166
- * `staging_directory` the path in VMs and images that Chef artifacts should be mounted/copied to. Defaults to `/var/chef`
167
- * `version` The version of chef to install with Omnibus
168
-
169
- ### Namespace `local`
170
-
171
- Local paths used for build tasks
172
-
173
- * `cookbook_path` Path at which to vendor cookbooks. Default `.builderator/cookbooks`
174
- * `data_bag_path` and `environment_path` Paths that Chef providers should load data-bag and environment documents from.
175
-
176
- ### Collection `policy`
177
-
178
- Load additional attributes into the parent file from a relative path
179
-
180
- * `path` Load a DSL file, relative => true
181
- * `json` Load a JSON file relative => true
182
-
183
- ### Namespace `aws`
184
-
185
- AWS API configurations. _Hint: Configure these in `$HOME/.builderator/Buildfile`, or use a built-in credential source, e.g. ~/.aws/config!_
186
-
187
- * `region` The default AWS region to use
188
- * `access_key` and `secret_key` A valid IAM key-pair
189
-
190
- ### Collection `vendor`
191
-
192
- Fetch remote artifacts for builds
193
-
194
- * Sources:
195
- * `path` Link to a local file/directory
196
- * `git` Fetch a git repository
197
- * `github` Fetch a git repository from a GitHub URI (e.g. `OWNER/REPO`) using the SSH protocol. You must have a valid SSH key configuration for public GitHub.
198
- * Git-specific parameters:
199
- * `remote` - The name of the remote repository at `git` or `github`. Defaults to `origin`
200
- * `branch` - The SCM branch to check out. Defaults to `master`
201
- * `tag` or `ref` - A SHA-ish or SCM tag to check out. Overrides `branch`.
202
- * `rel` Checkout a sub-directory of a git repository
203
-
204
- ### Namespace `cleaner`
205
-
206
- Configuration parameters for `build-clean` tasks
207
-
208
- #### Namespace `limits`
209
-
210
- Maximum number of resources to remove without manual override
211
-
212
- * `images`
213
- * `launch_configs`
214
- * `snapshots`
215
- * `volumes`
216
-
217
- ### Namespace `generator`
218
-
219
- Configurations for the `generator` task
220
-
221
- #### Collection `project`
222
-
223
- * `builderator.version` The version of Builderator to install with Bundler
224
- * `ruby.version` The version of ruby to require for Bundler and `rbenv`/`rvm`
225
-
226
- ##### Namespace `vagrant`
227
-
228
- * `install` Boolean, include the vagrant gem from GitHub `mitchellh/vagrant`
229
- * `version` The version of Vagrant to use from GitHub, if `install` is true
230
-
231
- ###### Collection `plugin`
232
-
233
- Vagrant plugins to install, either with the `build vagrant plugin` command, for a system-wide installation of Vagrant, or in the generated Gemfile if `install` is true
234
-
235
- ##### Collection `resource`
236
-
237
- Add a managed file to the project definition
238
-
239
- * `action` One of
240
- * `:create` Add a file from a template if it's missing
241
- * `:sync` Create or update a file from a template, stopping to ask for instructions if the file exists and the templated output does not match
242
- * `:ignore` Do nothing
243
- * `:rm` Delete a file if it exists
244
- * `path` One or more path in the working directory the this resource manages. Action `:rm` will delete multiple files, while `:create` and `:sync` will only use the first element of the list as their destination.
245
- * `template` The path to an ERB template. Must be an absolute path: use the [helpers](#helpers) in the Buildfile namespace to extend paths inline.
@@ -1,27 +0,0 @@
1
- cookbook
2
- ========
3
-
4
- * `path` The path to a local cookbook source, including a valid `metadata.rb` file.
5
- * `sources, type: list, singular: add_source, unique: true` Supermarket APIs to resolve cookbook dependencies from
6
- * `metadata` Boolean. Read dependencies from local cookbook metadata.
7
-
8
- ## `depends name`
9
-
10
- Collection of declared cookbook dependencies. Options are passed to [Berkshelf](http://berkshelf.com/). Check out their docs for additional details.
11
-
12
- * `version` A version constraint spec for the cookbook
13
- * `git` A git URI from which to fetch the cookbook
14
- * `GitHub` A GitHub URL from which to fetch the cookbook
15
- * `branch` A branch reference from which to fetch the cookbook
16
- * `tag` A tag reference from which to fetch the cookbook
17
- * `ref` A comittish reference from which to fetch the cookbook
18
- * `rel` The sub-directory of a git repository to check out as a cookbook
19
- * `path` The path to a local cookbook, relative to the build workspace.
20
-
21
- ## Tasks
22
-
23
- * `berks metadata COOKBOOK` Generates a `metadata.json` file from a local cookbook's `metadata.rb` file. The specified `COOKBOOK` must be in the `cookbook.depends` collection with a valid `path` attribute.
24
- * `berks vendor` Resolve and fetch cookbooks for the `cookbook.depends` collection and store in `$VENDOR_PATH/cookbooks`
25
- * `berks upload` Upload the resolved dependency set for `cookbook.depends` to the Chef Server configured in Berkshelf's configuration (default `$HOME/.berkshelf/config.json`)
26
- * `berks clean` Removes the project's cookbook vendor cache.
27
- * `berks uncache` is a helper to clear Berkshelf's host-cache, in `$HOME/.berkshelf/cookbooks` by default.
@@ -1,122 +0,0 @@
1
- Collection `profile`
2
- ====================
3
-
4
- A profile is a combination of Chef parameters, and Vagrant and Packer configurations. Profiles should provide
5
-
6
- * `tags, type: hash` EC2 tags to apply to instances and AMIs
7
- * `log_level` Chef log-level. Default `:info`
8
-
9
- ## Collection `artifact`
10
-
11
- An externally managed resource to push to VMs and image builds, e.g. `bundle.tar.gz` from a Maven build.
12
-
13
- * `path` The workspace-rooted path to the artifact
14
- * `destination` The absolute path on the VM or image at which the artifact should be placed
15
-
16
- ## Namespace `chef`
17
- * `run_list, type: list, singular: run_list_item, unique: true` The Chef runlist for this profile
18
- * `environment` The Chef environment to load for this
19
- * `node_attrs, type: hash` A hash of node attributes for this profile
20
-
21
-
22
- ## Namespace `packer`
23
-
24
- Packer configurations for this profile
25
-
26
- ### Collection `build`
27
-
28
- Add a packer build
29
-
30
- * `type` the build provider (e.g. amazon-ebs, virtualbox)
31
- * `instance_type` the EC2 instance type to use
32
- * `source_ami` The source AMI ID for an `amazon-ebs`
33
- * `ssh_username` Default `ubuntu`
34
- * `ami_virtualization_type` Default `hvm`
35
- * `tagging_role` the name of an IAM role that exists in each remote account that allows the AMI to be retagged
36
-
37
- Example usage:
38
-
39
- <pre>
40
- profile bake: Config.profile(:default) do |bake|
41
- bake.packer do |packer|
42
- packer.build :default do |build|
43
- build.tagging_role 'CreateTagsOnAllImages'
44
- end
45
- end
46
- end
47
- </pre>
48
-
49
- Example IAM policy in remote account:
50
-
51
- <pre>
52
- {
53
- "Version": "2012-10-17",
54
- "Statement": [
55
- {
56
- "Sid": "StmtId",
57
- "Effect": "Allow",
58
- "Action": [
59
- "ec2:CreateTags"
60
- ],
61
- "Resource": [
62
- "*"
63
- ]
64
- }
65
- ]
66
- }
67
- </pre>
68
-
69
-
70
- The above policy needs to be assigned to a role that enables a trust relationship with the account that builds the AMI:
71
-
72
- <pre>
73
- {
74
- "Version": "2012-10-17",
75
- "Statement": [
76
- {
77
- "Effect": "Allow",
78
- "Principal": {
79
- "AWS": "arn:aws:iam::[ami_builder_account]:user/[ami_builder_user]"
80
- },
81
- "Action": "sts:AssumeRole"
82
- }
83
- }
84
- </pre>
85
-
86
- ## TODO: Share accounts
87
-
88
- * `ami_name` Name for new AMI
89
- * `ami_description` Description for the new AMI
90
-
91
-
92
- ## Namespace `vagrant`
93
-
94
- Vagrant VM configurations
95
-
96
- ### Namespace `local`
97
-
98
- Parameters for a local VM build
99
-
100
- * `provider` Default `virtualbox`
101
- * `box` Default `ubuntu-14.04-x86_64`
102
- * `box_url` Default `https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box`
103
-
104
- * `cpus` Default 2
105
- * `memory` Default 1024 (MB)
106
-
107
- ## Namespace `ec2`
108
-
109
- Parameters for the provisioning EC2 nodes with Vagrant
110
-
111
- * `provider` Default `aws`
112
- * `box` Default `dummy`
113
- * `box_url` Default `https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box`
114
- * `instance_type`
115
- * `source_ami`
116
- * `ssh_username`
117
- * `virtualization_type`
118
- * `iam_instance_profile_arn`
119
- * `subnet_id`
120
- * `security_groups, type: list, singular: security_group, unique: true`
121
- * `public_ip`
122
- * `ssh_host_attribute` One of: `[:public_ip_address, :dns_name, :private_ip_address]`, Default `:private_ip_address`
@@ -1,65 +0,0 @@
1
- Versioning
2
- ==========
3
-
4
- This functionality is currently supported for Git.
5
-
6
- ## Version Bump Steps
7
-
8
- * `major` - Increment major version.
9
- * `major-prerelease` - Start a pre-release train from the next major version (increments major version).
10
- * `minor` - Increment minor version.
11
- * `minor-prerelease` - Start a pre-release train from the next minor version (increments minor version).
12
- * `patch` - Increment the patch version.
13
- * `patch-prerelease` - Force a new pre-release train from the next patch version, even if the current version is a pre-release.
14
- * `release` - Release a pre-release train a the current `major`.`minor`.`patch` version.
15
- * `prerelease NAME` Create or increment a pre-release version. If the current version is not a pre-release, the patch version will also be incremented.
16
- * `build` Add or increment a build number.
17
-
18
- Step types are an ordered-set. Incrementing a higher step resets all lower parameters.
19
-
20
- ## Commands
21
-
22
- ### `build version current`
23
-
24
- Searches for the newest SCM tag that is a valid sem-ver string and writes it to VERSION in the project root.
25
-
26
- ### `build version bump [STEP [PRERELEASE_NAME=alpha]]`
27
-
28
- Increment the current version by the desired step and create a new SCM tag at HEAD.
29
-
30
- If STEP is omitted, Builderator will scan messages of commits between HEAD and the current version tag for hash-tag style annotations indicating how to increment the version, finally defaulting to a `patch` step if no annotations are found. If multiple `#STEP` annotations are detected, the largest (e.g. `#major` > `#patch`) step will be applied.
31
-
32
- ## Configuration
33
-
34
- The `autoversion` namespace has two attributes:
35
-
36
- * `create_tags BOOLEAN` enables auto-generation of SCM tags after `bump` tasks. Default `false`.
37
- * `search_tags` enables detection of the current version from SCM tags. Default `true`.
38
-
39
- ```ruby
40
- autoversion do |version|
41
- version.create_tags false
42
- version.search_tags true
43
- end
44
- ```
45
-
46
- ## Adding Providers
47
-
48
- SCM providers must extend the `Builderator::Control::Version::SCM` module, and must implement two methods in their singleton class:
49
-
50
- * `self._history` Return an array of hashes with the following keys:
51
- - `:id` SCM commit identity
52
- - `:message` SCM commit message
53
- - `:tags` `nil` or an array of semver strings
54
- * `self.supported?` Return `true` if the provider supports the build environment (e.g. the `Git` provider checks that `pwd` is a git repository), else return `false`.
55
-
56
- To enable a provider module, pass it to `SCM.register`. See [Builderator::Control::Version::Git](blob/auto-version/lib/builderator/control/version/git.rb) for an example.
57
-
58
- ## This looks like `thor-scmversion`
59
-
60
- _Why aren't you using `thor-scmversion`?!_
61
-
62
- Well yes, it's based upon `thor-scmversion`, which I've been using for a while. `thor-scmversion` provides a nice model to ensure correct versioning of automatically built modules, but the project is largely abandoned, lacks some key features required for Builderator, and has a very inefficient access path for reading Git SCM data.
63
-
64
- This implementation adds `TYPE-prerelease` bump steps, improves semver matching regular-expressions, dramatically improves git-data access time for repositories with many tags (only reads from git-blobs once),
65
- and de-couples core functionality for parsing and incrementing versions from Thor tasks and actual mutation of the repository.