idlc-sdk-pfm 1.0.0.pre.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/.yardopts +3 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +37 -0
- data/Rakefile +6 -0
- data/bin/pfm +8 -0
- data/docs/GettingStarted.md +299 -0
- data/idlc-sdk-pfm.gemspec +44 -0
- data/lib/idlc-sdk-pfm/builtin_commands.rb +11 -0
- data/lib/idlc-sdk-pfm/cli.rb +150 -0
- data/lib/idlc-sdk-pfm/command/apply.rb +71 -0
- data/lib/idlc-sdk-pfm/command/base.rb +195 -0
- data/lib/idlc-sdk-pfm/command/build.rb +120 -0
- data/lib/idlc-sdk-pfm/command/configure.rb +41 -0
- data/lib/idlc-sdk-pfm/command/destroy.rb +61 -0
- data/lib/idlc-sdk-pfm/command/exec.rb +24 -0
- data/lib/idlc-sdk-pfm/command/format.rb +64 -0
- data/lib/idlc-sdk-pfm/command/generate.rb +83 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/base.rb +50 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/server_build.rb +58 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/Berksfile +3 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/build_cookbook/.kitchen.yml +21 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/build_cookbook/README.md +146 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/build_cookbook/test-fixture-recipe.rb +8 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/chefignore +107 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/cookbook_readmes/README-policy.md +9 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/cookbook_readmes/README.md +54 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/delivery-config.json +12 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/delivery-project.toml +36 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/gitignore +21 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/README.md +24 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/cookbooks/example/README.md +27 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb +7 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/cookbooks/example/metadata.rb +6 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +8 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/data_bags/README.md +56 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/data_bags/example/example_item.json +4 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/dot-chef-repo.txt +6 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/environments/README.md +9 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/environments/example.json +13 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/policies/README.md +24 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/roles/README.md +9 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/roles/example.json +13 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/spec_helper.rb +2 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/spec_helper_policyfile.rb +2 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/metadata.rb +7 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/app.rb +89 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/attribute.rb +12 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/build_cookbook.rb +182 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/cookbook.rb +144 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/cookbook_file.rb +24 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/lwrp.rb +23 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/policyfile.rb +8 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/recipe.rb +51 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/repo.rb +67 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/template.rb +32 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/LICENSE.all_rights.erb +3 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/LICENSE.apachev2.erb +201 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/LICENSE.gplv2.erb +339 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/LICENSE.gplv3.erb +674 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/LICENSE.mit.erb +21 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/Policyfile.rb.erb +25 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/README.md.erb +4 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/attribute.rb.erb +0 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/build_cookbook/Berksfile.erb +7 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/build_cookbook/metadata.rb.erb +10 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/build_cookbook/recipe.rb.erb +8 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/cookbook_file.erb +0 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/inspec_default_test.rb.erb +18 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/kitchen.yml.erb +26 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/kitchen_policyfile.yml.erb +33 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/metadata.rb.erb +20 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/provider.rb.erb +0 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/recipe.rb.erb +5 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/recipe_spec.rb.erb +22 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/repo/gitignore.erb +128 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/resource.rb.erb +0 -0
- data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/template.erb +0 -0
- data/lib/idlc-sdk-pfm/command/generator_commands.rb +34 -0
- data/lib/idlc-sdk-pfm/command/plan.rb +80 -0
- data/lib/idlc-sdk-pfm/command/templates/app/files/config/client.rb.template +9 -0
- data/lib/idlc-sdk-pfm/command/templates/app/files/config/init.ps1.userdata +16 -0
- data/lib/idlc-sdk-pfm/command/templates/base/files/config/client.rb.template +6 -0
- data/lib/idlc-sdk-pfm/command/templates/base/files/config/init.ps1.userdata +219 -0
- data/lib/idlc-sdk-pfm/command/validate.rb +85 -0
- data/lib/idlc-sdk-pfm/command/validator_commands/base.rb +65 -0
- data/lib/idlc-sdk-pfm/command/validator_commands/infrastructure.rb +46 -0
- data/lib/idlc-sdk-pfm/command/validator_commands/server_build.rb +135 -0
- data/lib/idlc-sdk-pfm/command/validator_commands.rb +32 -0
- data/lib/idlc-sdk-pfm/commands_map.rb +61 -0
- data/lib/idlc-sdk-pfm/generator.rb +52 -0
- data/lib/idlc-sdk-pfm/helpers.rb +49 -0
- data/lib/idlc-sdk-pfm/settings.rb +205 -0
- data/lib/idlc-sdk-pfm/validator.rb +52 -0
- data/lib/idlc-sdk-pfm/version.rb +3 -0
- data/lib/idlc-sdk-pfm.rb +24 -0
- metadata +342 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e06db05b04105a042039112e0424544589134df5
|
4
|
+
data.tar.gz: bb28fc80e37768c1e348e0f2344a2d50809f1739
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3028af844527847d29f0790603ee88c1ca1e99a6102ae0d4144a33744c7c63f8a02ab24c0d4840b4ff0c87ded6a76efd5c282d981ba351fd1fee58f4130f3613
|
7
|
+
data.tar.gz: 8872731f018eb25b4a24061e7df5a00a951f1abf544d2b1552e1363628c5b3b0aa928bfa152666e62266a40e62158874fec4eafdaa4c3480830eec1727f39fb3
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/.yardopts
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Nathan Cazell
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Idlc::Sdk::Pfm
|
2
|
+
|
3
|
+
Provides the pfm executable for idlc-sdk. This gem is part of the IDLC SDK
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'idlc-sdk-pfm'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install idlc-sdk-pfm
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
See the {file:docs/GettingStarted.md Getting Started Guide} for PFM executable usage.
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/idlc-sdk-pfm.
|
34
|
+
|
35
|
+
## License
|
36
|
+
|
37
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/pfm
ADDED
@@ -0,0 +1,299 @@
|
|
1
|
+
# @title Getting Started Guide
|
2
|
+
|
3
|
+
## `pfm` Executable
|
4
|
+
Bundled with this gem is an executable `pfm`. The `pfm` executable is a command-line tool that does the following:
|
5
|
+
|
6
|
+
* Generates server build repositories, templates, and default cookbooks
|
7
|
+
* Builds images with Packer from existing server build repositories
|
8
|
+
* Validates server build repositories, templates, and cookbooks
|
9
|
+
|
10
|
+
The following commands are available in PFM 0.3.x (see pfm -h for a full list):
|
11
|
+
|
12
|
+
```
|
13
|
+
Usage:
|
14
|
+
pfm -h/--help
|
15
|
+
pfm -v/--version
|
16
|
+
pfm command [arguments...] [options...]
|
17
|
+
|
18
|
+
|
19
|
+
Available Commands:
|
20
|
+
generate Generate a new server build, repository, cookbooks, etc.
|
21
|
+
build Build a specified server template
|
22
|
+
validate Test & validate a server build
|
23
|
+
exec Runs the command in context of the embedded ruby
|
24
|
+
configure Run initial setup and configuration
|
25
|
+
plan Show the infrastructure plan
|
26
|
+
apply Apply the infrastructure plan
|
27
|
+
destroy Destroy all managed infrastructure
|
28
|
+
format format infrastructure code
|
29
|
+
```
|
30
|
+
|
31
|
+
### Configuring `pfm`
|
32
|
+
#### `.pfm/` Options Directory
|
33
|
+
The `pfm` executable will automatically generate a default config file located at `.pfm/config`. It will set sensible defaults, that should work for most implementations. You can change these settings by editing the file directly or running `pfm configure`.
|
34
|
+
|
35
|
+
See available settings in {Pfm::Settings}
|
36
|
+
|
37
|
+
### `pfm` Commands
|
38
|
+
#### pfm generate server-build
|
39
|
+
Use the `pfm generate server-build` subcommand to generate server build repositories/templates.
|
40
|
+
|
41
|
+
##### Syntax
|
42
|
+
```
|
43
|
+
$ pfm generate server-build NAME [options]
|
44
|
+
```
|
45
|
+
|
46
|
+
##### Options
|
47
|
+
`-h`, `--help`
|
48
|
+
- Show this message
|
49
|
+
|
50
|
+
`-V`, `--verbose`
|
51
|
+
- Show detailed output from the generator
|
52
|
+
|
53
|
+
`-v`, `--version`
|
54
|
+
- Show pfm version
|
55
|
+
|
56
|
+
##### Examples
|
57
|
+
To generate a server build repositories, run a command similar to:
|
58
|
+
|
59
|
+
```
|
60
|
+
$ pfm generate server-build app-axpwa
|
61
|
+
```
|
62
|
+
|
63
|
+
|
64
|
+
#### pfm build
|
65
|
+
Use the `pfm build` subcommand to build server images (using Packer) from existing build repositories & templates (previously generated from `pfm generate`)
|
66
|
+
|
67
|
+
##### Syntax
|
68
|
+
```
|
69
|
+
$ pfm build BUILD_NAME [options]
|
70
|
+
```
|
71
|
+
|
72
|
+
##### Options
|
73
|
+
This subcommand has the following options:
|
74
|
+
|
75
|
+
`-a VERSION`, `--app-release VERSION`
|
76
|
+
- Application Version Number to build
|
77
|
+
|
78
|
+
`-n`, `--build-number NUMBER`
|
79
|
+
- Override the build number. Default is ENV::BUILD_NUMBER
|
80
|
+
|
81
|
+
`-t`, `--build-template TEMPLATE`
|
82
|
+
- The Packer Build Template to use. The default template file is `build.json`. This file should reside in the root of the server build directory.
|
83
|
+
|
84
|
+
`-m`, `--build-metadata METADATA_FILE`
|
85
|
+
- The build metadata file to use. The default metadata file is `metadata`. This file should reside in the root of the server build directory.
|
86
|
+
|
87
|
+
`-h`, `--help`
|
88
|
+
- Show this message
|
89
|
+
|
90
|
+
`-V`, `--verbose`
|
91
|
+
- Show detailed output from the generator
|
92
|
+
|
93
|
+
`-v`, `--version`
|
94
|
+
- Show pfm version
|
95
|
+
|
96
|
+
##### Examples
|
97
|
+
To build a server repositories/template, run a command similar to:
|
98
|
+
|
99
|
+
```
|
100
|
+
$ pfm build app-axpwa -a 3.1.0.1585
|
101
|
+
```
|
102
|
+
|
103
|
+
#### pfm validate server-build
|
104
|
+
Use the `pfm validate server-build` subcommand to validate a server build repository. This will run various tools such as Foodcritic, Rubocop, and ChefSpec against the build repo. Reports & Artifacts are generated and stored in `.pfm/tests/{reports,artifacts}`
|
105
|
+
|
106
|
+
##### Syntax
|
107
|
+
```
|
108
|
+
$ pfm validate server-build BUILD_NAME [options]
|
109
|
+
```
|
110
|
+
|
111
|
+
##### Options
|
112
|
+
`-t`, `--build-template TEMPLATE`
|
113
|
+
- The Build Template to use. Default is `build.json`
|
114
|
+
|
115
|
+
`-m`, `--build-metadata METADATA_FILE`
|
116
|
+
- The build metadata file to use. The default metadata file is `metadata`. This file should reside in the root of the server build directory.
|
117
|
+
|
118
|
+
`-c`, `--circle-ci`
|
119
|
+
- Use Circle Ci artifact output directories
|
120
|
+
|
121
|
+
`-h`, `--help`
|
122
|
+
- Show this message
|
123
|
+
|
124
|
+
`-V`, `--verbose`
|
125
|
+
- Show detailed output from the generator
|
126
|
+
|
127
|
+
`-v`, `--version`
|
128
|
+
- Show pfm version
|
129
|
+
|
130
|
+
##### Examples
|
131
|
+
To validate a build repository, run a command similar to:
|
132
|
+
|
133
|
+
```
|
134
|
+
$ pfm validate server-build app-axpwa
|
135
|
+
```
|
136
|
+
#### pfm validate infrastructure
|
137
|
+
Use the `pfm validate infrastructure` subcommand to validate a server build repository. This will run various tools such as Foodcritic, Rubocop, and ChefSpec against the build repo. Reports & Artifacts are generated and stored in `.pfm/tests/{reports,artifacts}`
|
138
|
+
|
139
|
+
##### Syntax
|
140
|
+
```
|
141
|
+
$ pfm validate infrastructure [options]
|
142
|
+
```
|
143
|
+
|
144
|
+
##### Options
|
145
|
+
`-h`, `--help`
|
146
|
+
- Show this message
|
147
|
+
|
148
|
+
`-V`, `--verbose`
|
149
|
+
- Show detailed output from the generator
|
150
|
+
|
151
|
+
`-v`, `--version`
|
152
|
+
- Show pfm version
|
153
|
+
|
154
|
+
##### Examples
|
155
|
+
To validate a build repository, run a command similar to:
|
156
|
+
|
157
|
+
```
|
158
|
+
$ pfm validate infrastructure
|
159
|
+
```
|
160
|
+
|
161
|
+
#### pfm exec
|
162
|
+
Use the `pfm exec` subcommand to run arbitrary shell commands with the PATH environment variable and the GEM_HOME and GEM_PATH Ruby environment variables pointed at the Pfm bundle.
|
163
|
+
|
164
|
+
##### Syntax
|
165
|
+
```
|
166
|
+
$ pfm exec SYSTEM_COMMAND [options]
|
167
|
+
```
|
168
|
+
|
169
|
+
##### Options
|
170
|
+
`-h`, `--help`
|
171
|
+
- Show this message
|
172
|
+
|
173
|
+
`-V`, `--verbose`
|
174
|
+
- Show detailed output from the generator
|
175
|
+
|
176
|
+
`-v`, `--version`
|
177
|
+
- Show pfm version
|
178
|
+
|
179
|
+
##### Examples
|
180
|
+
None.
|
181
|
+
|
182
|
+
#### pfm plan
|
183
|
+
Use the `pfm plan` subcommand to plan infrastructure changes before they are executed.
|
184
|
+
|
185
|
+
##### Syntax
|
186
|
+
```
|
187
|
+
$ pfm plan [options]
|
188
|
+
```
|
189
|
+
|
190
|
+
##### Options
|
191
|
+
|
192
|
+
`-a`, `--app-release VERSION`
|
193
|
+
- Application Version Number to Deploy
|
194
|
+
|
195
|
+
`-b`, `--server-build BUILD_NUMBER`
|
196
|
+
- The build number of the AMI to deploy
|
197
|
+
|
198
|
+
`-l`, `--landscape`
|
199
|
+
- Format the Terraform plan output with `terraform_landscape`
|
200
|
+
|
201
|
+
`-h`, `--help`
|
202
|
+
- Show this message
|
203
|
+
|
204
|
+
`-V`, `--verbose`
|
205
|
+
- Show detailed output
|
206
|
+
|
207
|
+
`-v`, `--version`
|
208
|
+
- Show pfm version
|
209
|
+
|
210
|
+
##### Examples
|
211
|
+
To plan an infrastructure release with application version number 3.1.0.1654, run a command similar to:
|
212
|
+
|
213
|
+
```
|
214
|
+
$ pfm plan -a 3.1.0.1654
|
215
|
+
```
|
216
|
+
|
217
|
+
#### pfm apply
|
218
|
+
Use the `pfm apply` subcommand to apply infrastructure changes before they are executed.
|
219
|
+
|
220
|
+
##### Syntax
|
221
|
+
```
|
222
|
+
$ pfm apply [options]
|
223
|
+
```
|
224
|
+
|
225
|
+
##### Options
|
226
|
+
|
227
|
+
`-a`, `--app-release VERSION`
|
228
|
+
- Application Version Number to Deploy
|
229
|
+
|
230
|
+
`-b`, `--server-build BUILD_NUMBER`
|
231
|
+
- The build number of the AMI to deploy
|
232
|
+
|
233
|
+
`-h`, `--help`
|
234
|
+
- Show this message
|
235
|
+
|
236
|
+
`-V`, `--verbose`
|
237
|
+
- Show detailed output
|
238
|
+
|
239
|
+
`-v`, `--version`
|
240
|
+
- Show pfm version
|
241
|
+
|
242
|
+
##### Examples
|
243
|
+
To apply an infrastructure release with application version number 3.1.0.1654, run a command similar to:
|
244
|
+
|
245
|
+
```
|
246
|
+
$ pfm apply -a 3.1.0.1654
|
247
|
+
```
|
248
|
+
|
249
|
+
#### pfm destroy
|
250
|
+
Use the `pfm destroy` subcommand to destroy a managed environment and all associated resources. THIS CANNOT BE UNDONE
|
251
|
+
|
252
|
+
##### Syntax
|
253
|
+
```
|
254
|
+
$ pfm destroy [options]
|
255
|
+
```
|
256
|
+
|
257
|
+
##### Options
|
258
|
+
|
259
|
+
`-h`, `--help`
|
260
|
+
- Show this message
|
261
|
+
|
262
|
+
`-V`, `--verbose`
|
263
|
+
- Show detailed output
|
264
|
+
|
265
|
+
`-v`, `--version`
|
266
|
+
- Show pfm version
|
267
|
+
|
268
|
+
##### Examples
|
269
|
+
To destroy a managed environment
|
270
|
+
|
271
|
+
```
|
272
|
+
$ pfm destroy
|
273
|
+
```
|
274
|
+
|
275
|
+
#### pfm format
|
276
|
+
Use the `pfm format` subcommand to format an infrastructure repository and associated files to a canonical format.
|
277
|
+
|
278
|
+
##### Syntax
|
279
|
+
```
|
280
|
+
$ pfm format [options]
|
281
|
+
```
|
282
|
+
|
283
|
+
##### Options
|
284
|
+
|
285
|
+
`-h`, `--help`
|
286
|
+
- Show this message
|
287
|
+
|
288
|
+
`-V`, `--verbose`
|
289
|
+
- Show detailed output
|
290
|
+
|
291
|
+
`-v`, `--version`
|
292
|
+
- Show pfm version
|
293
|
+
|
294
|
+
##### Examples
|
295
|
+
To format an infrastructure repository's files
|
296
|
+
|
297
|
+
```
|
298
|
+
$ pfm format
|
299
|
+
```
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "idlc-sdk-pfm/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "idlc-sdk-pfm"
|
8
|
+
spec.version = Pfm::VERSION
|
9
|
+
spec.authors = ["Nathan Cazell"]
|
10
|
+
spec.email = ["nathan.cazell@imageapi.com"]
|
11
|
+
|
12
|
+
spec.summary = 'IDLC SDK for AWS resources - PFM'
|
13
|
+
spec.description = 'Provides the pfm executable for idlc-sdk. This gem is part of the IDLC SDK'
|
14
|
+
spec.homepage = 'https://github.com/nathantcz/idlc-sdk'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
spec.has_rdoc = 'yard'
|
17
|
+
spec.executables << 'pfm'
|
18
|
+
|
19
|
+
spec.metadata = {
|
20
|
+
'source_code_uri' => 'https://github.com/nathantcz/idlc-sdk-deploy'
|
21
|
+
}
|
22
|
+
|
23
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
24
|
+
f.match(%r{^(test|spec|features|bin)/})
|
25
|
+
end
|
26
|
+
|
27
|
+
spec.require_paths = ['lib']
|
28
|
+
|
29
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
30
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
31
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
32
|
+
spec.add_development_dependency 'rubocop', '0.48.1'
|
33
|
+
spec.add_development_dependency 'pry'
|
34
|
+
spec.add_development_dependency 'yard'
|
35
|
+
|
36
|
+
spec.add_runtime_dependency 'idlc-sdk-core'
|
37
|
+
spec.add_runtime_dependency 'idlc-sdk-build'
|
38
|
+
spec.add_runtime_dependency 'idlc-sdk-deploy'
|
39
|
+
spec.add_runtime_dependency 'chefspec'
|
40
|
+
spec.add_runtime_dependency 'mixlib-cli'
|
41
|
+
spec.add_runtime_dependency 'mixlib-shellout'
|
42
|
+
spec.add_runtime_dependency 'rubocop-junit-formatter'
|
43
|
+
spec.add_runtime_dependency 'rubocop', '0.48.1'
|
44
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Pfm.commands do |c|
|
2
|
+
c.builtin 'generate', :Generate, desc: 'Generate a new server build, repository, cookbooks, etc.'
|
3
|
+
c.builtin 'build', :Build, desc: 'Build a specified server template'
|
4
|
+
c.builtin 'validate', :Validate, desc: 'Test & validate a server build'
|
5
|
+
c.builtin 'exec', :Exec, desc: 'Runs the command in context of the embedded ruby'
|
6
|
+
c.builtin 'configure', :Configure, desc: 'Run initial setup and configuration'
|
7
|
+
c.builtin 'plan', :Plan, desc: 'Show the infrastructure plan'
|
8
|
+
c.builtin 'apply', :Apply, desc: 'Apply the infrastructure plan'
|
9
|
+
c.builtin 'destroy', :Destroy, desc: 'Destroy all managed infrastructure'
|
10
|
+
c.builtin 'format', :Format, desc: 'format infrastructure code'
|
11
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
module Pfm
|
2
|
+
class CLI
|
3
|
+
include Mixlib::CLI
|
4
|
+
include Pfm::Helpers
|
5
|
+
|
6
|
+
banner(<<-BANNER)
|
7
|
+
Usage:
|
8
|
+
pfm -h/--help
|
9
|
+
pfm -v/--version
|
10
|
+
pfm command [arguments...] [options...]
|
11
|
+
BANNER
|
12
|
+
|
13
|
+
option :version,
|
14
|
+
short: '-v',
|
15
|
+
long: '--version',
|
16
|
+
description: 'Show pfm version',
|
17
|
+
boolean: true
|
18
|
+
|
19
|
+
option :help,
|
20
|
+
short: '-h',
|
21
|
+
long: '--help',
|
22
|
+
description: 'Show this message',
|
23
|
+
boolean: true
|
24
|
+
|
25
|
+
option :verbose,
|
26
|
+
short: '-V',
|
27
|
+
long: '--verbose',
|
28
|
+
description: 'Show detailed output',
|
29
|
+
boolean: true,
|
30
|
+
default: false
|
31
|
+
|
32
|
+
attr_reader :argv
|
33
|
+
|
34
|
+
def initialize(argv)
|
35
|
+
@argv = argv
|
36
|
+
super() # mixlib-cli #initialize doesn't allow arguments
|
37
|
+
end
|
38
|
+
|
39
|
+
def run
|
40
|
+
subcommand_name, *subcommand_params = argv
|
41
|
+
|
42
|
+
ENV['DEBUG'] = true if verbose?
|
43
|
+
|
44
|
+
#
|
45
|
+
# Runs the appropriate subcommand if the given parameters contain any
|
46
|
+
# subcommands.
|
47
|
+
#
|
48
|
+
if subcommand_name.nil? || option?(subcommand_name)
|
49
|
+
handle_options
|
50
|
+
elsif have_command?(subcommand_name)
|
51
|
+
subcommand = instantiate_subcommand(subcommand_name)
|
52
|
+
exit_code = subcommand.run_with_default_options(subcommand_params)
|
53
|
+
exit normalized_exit_code(exit_code)
|
54
|
+
else
|
55
|
+
err "Unknown command `#{subcommand_name}'."
|
56
|
+
show_help
|
57
|
+
exit 1
|
58
|
+
end
|
59
|
+
rescue OptionParser::InvalidOption => e
|
60
|
+
err(e.message)
|
61
|
+
show_help
|
62
|
+
exit 1
|
63
|
+
end
|
64
|
+
|
65
|
+
# If no subcommand is given, then this class is handling the CLI request.
|
66
|
+
def handle_options
|
67
|
+
parse_options(argv)
|
68
|
+
if config[:version]
|
69
|
+
show_version
|
70
|
+
else
|
71
|
+
show_help
|
72
|
+
end
|
73
|
+
exit 0
|
74
|
+
end
|
75
|
+
|
76
|
+
def show_version
|
77
|
+
msg("Pfm Version: #{Pfm::VERSION}")
|
78
|
+
end
|
79
|
+
|
80
|
+
def show_help
|
81
|
+
msg(banner)
|
82
|
+
msg("\nAvailable Commands:")
|
83
|
+
|
84
|
+
justify_length = subcommands.map(&:length).max + 2
|
85
|
+
subcommand_specs.each do |name, spec|
|
86
|
+
msg(" #{name.ljust(justify_length)}#{spec.description}")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def exit(n)
|
91
|
+
Kernel.exit(n)
|
92
|
+
end
|
93
|
+
|
94
|
+
def commands_map
|
95
|
+
Pfm.commands_map
|
96
|
+
end
|
97
|
+
|
98
|
+
def have_command?(name)
|
99
|
+
commands_map.have_command?(name)
|
100
|
+
end
|
101
|
+
|
102
|
+
def subcommands
|
103
|
+
commands_map.command_names
|
104
|
+
end
|
105
|
+
|
106
|
+
def subcommand_specs
|
107
|
+
commands_map.command_specs
|
108
|
+
end
|
109
|
+
|
110
|
+
def option?(param)
|
111
|
+
param =~ /^-/
|
112
|
+
end
|
113
|
+
|
114
|
+
def verbose?
|
115
|
+
@config[:verbose]
|
116
|
+
end
|
117
|
+
|
118
|
+
def instantiate_subcommand(name)
|
119
|
+
commands_map.instantiate(name)
|
120
|
+
end
|
121
|
+
|
122
|
+
private
|
123
|
+
|
124
|
+
def normalized_exit_code(maybe_integer)
|
125
|
+
if maybe_integer.is_a?(Integer) && (0..255).cover?(maybe_integer)
|
126
|
+
maybe_integer
|
127
|
+
else
|
128
|
+
0
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# Find PATH or Path correctly if we are on Windows
|
133
|
+
def path_key
|
134
|
+
env.keys.grep(/\Apath\Z/i).first
|
135
|
+
end
|
136
|
+
|
137
|
+
# upcase drive letters for comparison since ruby has a String#capitalize function
|
138
|
+
def drive_upcase(path)
|
139
|
+
if Chef::Platform.windows? && path[0] =~ /^[A-Za-z]$/ && path[1, 2] == ':\\'
|
140
|
+
path.capitalize
|
141
|
+
else
|
142
|
+
path
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def env
|
147
|
+
ENV
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'idlc-sdk-pfm/command/base'
|
2
|
+
require 'mixlib/shellout'
|
3
|
+
|
4
|
+
module Pfm
|
5
|
+
module Command
|
6
|
+
class Apply < Base
|
7
|
+
banner 'Usage: pfm apply [options]'
|
8
|
+
|
9
|
+
option :app_release,
|
10
|
+
short: '-a VERSION',
|
11
|
+
long: '--app-release VERSION',
|
12
|
+
description: 'Application Version Number to Deploy',
|
13
|
+
default: ''
|
14
|
+
|
15
|
+
option :server_build,
|
16
|
+
short: '-b NUMBER',
|
17
|
+
long: '--server-build NUMBER',
|
18
|
+
description: 'Server Build Number to Deploy',
|
19
|
+
default: ENV['SERVER_BUILD']
|
20
|
+
|
21
|
+
def initialize
|
22
|
+
super
|
23
|
+
@params_valid = true
|
24
|
+
@errors = []
|
25
|
+
end
|
26
|
+
|
27
|
+
def run(params)
|
28
|
+
@params = params
|
29
|
+
read_and_validate_params
|
30
|
+
|
31
|
+
if params_valid?
|
32
|
+
deploy_setup
|
33
|
+
apply
|
34
|
+
# @workspace.cleanup causing bundler issues
|
35
|
+
0
|
36
|
+
else
|
37
|
+
@errors.each { |error| err("Error: #{error}") }
|
38
|
+
parse_options(params)
|
39
|
+
msg(opt_parser)
|
40
|
+
1
|
41
|
+
end
|
42
|
+
rescue DeploymentFailure => e
|
43
|
+
err("ERROR: #{e.message}\n")
|
44
|
+
1
|
45
|
+
end
|
46
|
+
|
47
|
+
def apply
|
48
|
+
Terraform::Binary.get("-update #{@workspace.tmp_dir}")
|
49
|
+
Terraform::Binary.apply(@workspace.tmp_dir.to_s) || raise
|
50
|
+
Terraform::Binary.remote('push')
|
51
|
+
rescue
|
52
|
+
raise DeploymentFailure, 'Finished with errors'
|
53
|
+
end
|
54
|
+
|
55
|
+
def read_and_validate_params
|
56
|
+
arguments = parse_options(@params)
|
57
|
+
|
58
|
+
@params_valid = case arguments.size
|
59
|
+
when 0
|
60
|
+
true
|
61
|
+
else
|
62
|
+
false
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def params_valid?
|
67
|
+
@params_valid
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|