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.
Files changed (101) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/.yardopts +3 -0
  6. data/Gemfile +6 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +37 -0
  9. data/Rakefile +6 -0
  10. data/bin/pfm +8 -0
  11. data/docs/GettingStarted.md +299 -0
  12. data/idlc-sdk-pfm.gemspec +44 -0
  13. data/lib/idlc-sdk-pfm/builtin_commands.rb +11 -0
  14. data/lib/idlc-sdk-pfm/cli.rb +150 -0
  15. data/lib/idlc-sdk-pfm/command/apply.rb +71 -0
  16. data/lib/idlc-sdk-pfm/command/base.rb +195 -0
  17. data/lib/idlc-sdk-pfm/command/build.rb +120 -0
  18. data/lib/idlc-sdk-pfm/command/configure.rb +41 -0
  19. data/lib/idlc-sdk-pfm/command/destroy.rb +61 -0
  20. data/lib/idlc-sdk-pfm/command/exec.rb +24 -0
  21. data/lib/idlc-sdk-pfm/command/format.rb +64 -0
  22. data/lib/idlc-sdk-pfm/command/generate.rb +83 -0
  23. data/lib/idlc-sdk-pfm/command/generator_commands/base.rb +50 -0
  24. data/lib/idlc-sdk-pfm/command/generator_commands/server_build.rb +58 -0
  25. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/Berksfile +3 -0
  26. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/build_cookbook/.kitchen.yml +21 -0
  27. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/build_cookbook/README.md +146 -0
  28. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/build_cookbook/test-fixture-recipe.rb +8 -0
  29. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/chefignore +107 -0
  30. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/cookbook_readmes/README-policy.md +9 -0
  31. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/cookbook_readmes/README.md +54 -0
  32. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/delivery-config.json +12 -0
  33. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/delivery-project.toml +36 -0
  34. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/gitignore +21 -0
  35. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/README.md +24 -0
  36. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/cookbooks/example/README.md +27 -0
  37. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb +7 -0
  38. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/cookbooks/example/metadata.rb +6 -0
  39. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +8 -0
  40. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/data_bags/README.md +56 -0
  41. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/data_bags/example/example_item.json +4 -0
  42. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/dot-chef-repo.txt +6 -0
  43. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/environments/README.md +9 -0
  44. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/environments/example.json +13 -0
  45. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/policies/README.md +24 -0
  46. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/roles/README.md +9 -0
  47. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/roles/example.json +13 -0
  48. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/spec_helper.rb +2 -0
  49. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/spec_helper_policyfile.rb +2 -0
  50. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/metadata.rb +7 -0
  51. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/app.rb +89 -0
  52. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/attribute.rb +12 -0
  53. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/build_cookbook.rb +182 -0
  54. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/cookbook.rb +144 -0
  55. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/cookbook_file.rb +24 -0
  56. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/lwrp.rb +23 -0
  57. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/policyfile.rb +8 -0
  58. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/recipe.rb +51 -0
  59. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/repo.rb +67 -0
  60. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/template.rb +32 -0
  61. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/LICENSE.all_rights.erb +3 -0
  62. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/LICENSE.apachev2.erb +201 -0
  63. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/LICENSE.gplv2.erb +339 -0
  64. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/LICENSE.gplv3.erb +674 -0
  65. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/LICENSE.mit.erb +21 -0
  66. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/Policyfile.rb.erb +25 -0
  67. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/README.md.erb +4 -0
  68. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/attribute.rb.erb +0 -0
  69. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/build_cookbook/Berksfile.erb +7 -0
  70. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/build_cookbook/metadata.rb.erb +10 -0
  71. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/build_cookbook/recipe.rb.erb +8 -0
  72. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/cookbook_file.erb +0 -0
  73. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/inspec_default_test.rb.erb +18 -0
  74. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/kitchen.yml.erb +26 -0
  75. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/kitchen_policyfile.yml.erb +33 -0
  76. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/metadata.rb.erb +20 -0
  77. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/provider.rb.erb +0 -0
  78. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/recipe.rb.erb +5 -0
  79. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/recipe_spec.rb.erb +22 -0
  80. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/repo/gitignore.erb +128 -0
  81. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/resource.rb.erb +0 -0
  82. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/template.erb +0 -0
  83. data/lib/idlc-sdk-pfm/command/generator_commands.rb +34 -0
  84. data/lib/idlc-sdk-pfm/command/plan.rb +80 -0
  85. data/lib/idlc-sdk-pfm/command/templates/app/files/config/client.rb.template +9 -0
  86. data/lib/idlc-sdk-pfm/command/templates/app/files/config/init.ps1.userdata +16 -0
  87. data/lib/idlc-sdk-pfm/command/templates/base/files/config/client.rb.template +6 -0
  88. data/lib/idlc-sdk-pfm/command/templates/base/files/config/init.ps1.userdata +219 -0
  89. data/lib/idlc-sdk-pfm/command/validate.rb +85 -0
  90. data/lib/idlc-sdk-pfm/command/validator_commands/base.rb +65 -0
  91. data/lib/idlc-sdk-pfm/command/validator_commands/infrastructure.rb +46 -0
  92. data/lib/idlc-sdk-pfm/command/validator_commands/server_build.rb +135 -0
  93. data/lib/idlc-sdk-pfm/command/validator_commands.rb +32 -0
  94. data/lib/idlc-sdk-pfm/commands_map.rb +61 -0
  95. data/lib/idlc-sdk-pfm/generator.rb +52 -0
  96. data/lib/idlc-sdk-pfm/helpers.rb +49 -0
  97. data/lib/idlc-sdk-pfm/settings.rb +205 -0
  98. data/lib/idlc-sdk-pfm/validator.rb +52 -0
  99. data/lib/idlc-sdk-pfm/version.rb +3 -0
  100. data/lib/idlc-sdk-pfm.rb +24 -0
  101. metadata +342 -0
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) <%= year %> <%= copyright_holder %>
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.
@@ -0,0 +1,25 @@
1
+ # Policyfile.rb - Describe how you want Chef to build your system.
2
+ #
3
+ # For more information on the Policyfile feature, visit
4
+ # https://docs.chef.io/policyfile.html
5
+
6
+ # A name that describes what the system you're building with Chef does.
7
+ name "<%= policy_name %>"
8
+
9
+ <% if include_chef_repo_source %>
10
+ # This lets you source cookbooks from your chef-repo.
11
+ default_source :chef_repo, "../"
12
+
13
+ <% end -%>
14
+ # Where to find external cookbooks:
15
+ default_source :supermarket
16
+
17
+ # run_list: chef-client will run these recipes in the order specified.
18
+ run_list "<%= policy_run_list %>"
19
+
20
+ # Specify a custom source for a single cookbook:
21
+ <% if policy_local_cookbook.nil? %>
22
+ # cookbook "example_cookbook", path: "../cookbooks/example_cookbook"
23
+ <% else %>
24
+ cookbook "<%= cookbook_name %>", path: "."
25
+ <% end %>
@@ -0,0 +1,4 @@
1
+ # <%= cookbook_name %>
2
+
3
+ TODO: Enter the cookbook description here.
4
+
@@ -0,0 +1,7 @@
1
+ source 'https://supermarket.chef.io'
2
+
3
+ metadata
4
+
5
+ group :delivery do
6
+ cookbook 'test', path: './test/fixtures/cookbooks/test'
7
+ end
@@ -0,0 +1,10 @@
1
+ name 'build_cookbook'
2
+ maintainer '<%= copyright_holder %>'
3
+ maintainer_email '<%= email %>'
4
+ license '<%= license %>'
5
+ version '0.1.0'
6
+ chef_version '>= 12.1' if respond_to?(:chef_version)
7
+ <% if build_cookbook_parent_is_cookbook -%>
8
+
9
+ depends 'delivery-truck'
10
+ <% end -%>
@@ -0,0 +1,8 @@
1
+ #
2
+ # Cookbook:: build_cookbook
3
+ # Recipe:: <%= @phase %>
4
+ #
5
+ <%= license_description('#') %>
6
+ <% if build_cookbook_parent_is_cookbook -%>
7
+ include_recipe 'delivery-truck::<%= @phase %>'
8
+ <% end -%>
@@ -0,0 +1,18 @@
1
+ # # encoding: utf-8
2
+
3
+ # Inspec test for recipe <%= cookbook_name %>::<%= recipe_name %>
4
+
5
+ # The Inspec reference, with examples and extensive documentation, can be
6
+ # found at http://inspec.io/docs/reference/resources/
7
+
8
+ unless os.windows?
9
+ # This is an example test, replace with your own test.
10
+ describe user('root'), :skip do
11
+ it { should exist }
12
+ end
13
+ end
14
+
15
+ # This is an example test, replace it with your own test.
16
+ describe port(80), :skip do
17
+ it { should_not be_listening }
18
+ end
@@ -0,0 +1,26 @@
1
+ ---
2
+ driver:
3
+ name: vagrant
4
+
5
+ provisioner:
6
+ name: chef_zero
7
+ # You may wish to disable always updating cookbooks in CI or other testing environments.
8
+ # For example:
9
+ # always_update_cookbooks: <%%= !ENV['CI'] %>
10
+ always_update_cookbooks: true
11
+
12
+ verifier:
13
+ name: inspec
14
+
15
+ platforms:
16
+ - name: ubuntu-16.04
17
+ - name: centos-7.3
18
+
19
+ suites:
20
+ - name: default
21
+ run_list:
22
+ - recipe[<%= cookbook_name %>::default]
23
+ verifier:
24
+ inspec_tests:
25
+ - test/smoke/default
26
+ attributes:
@@ -0,0 +1,33 @@
1
+ ---
2
+ driver:
3
+ name: vagrant
4
+
5
+ ## The forwarded_port port feature lets you connect to ports on the VM guest via
6
+ ## localhost on the host.
7
+ ## see also: https://docs.vagrantup.com/v2/networking/forwarded_ports.html
8
+
9
+ # network:
10
+ # - ["forwarded_port", {guest: 80, host: 8080}]
11
+
12
+ provisioner:
13
+ name: policyfile_zero
14
+
15
+ ## require_chef_omnibus specifies a specific chef version to install. You can
16
+ ## also set this to `true` to always use the latest version.
17
+ ## see also: https://docs.chef.io/config_yml_kitchen.html
18
+
19
+ # require_chef_omnibus: 12.8.1
20
+
21
+ verifier:
22
+ name: inspec
23
+
24
+ platforms:
25
+ - name: ubuntu-16.04
26
+ - name: centos-7.3
27
+
28
+ suites:
29
+ - name: default
30
+ verifier:
31
+ inspec_tests:
32
+ - test/smoke/default
33
+ attributes:
@@ -0,0 +1,20 @@
1
+ name '<%= cookbook_name %>'
2
+ maintainer '<%= copyright_holder %>'
3
+ maintainer_email '<%= email %>'
4
+ license '<%= @spdx_license %>'
5
+ description 'Installs/Configures <%= cookbook_name %>'
6
+ long_description 'Installs/Configures <%= cookbook_name %>'
7
+ version '0.1.0'
8
+ chef_version '>= 12.1' if respond_to?(:chef_version)
9
+
10
+ # The `issues_url` points to the location where issues for this cookbook are
11
+ # tracked. A `View Issues` link will be displayed on this cookbook's page when
12
+ # uploaded to a Supermarket.
13
+ #
14
+ # issues_url 'https://github.com/<insert_org_here>/<%= cookbook_name %>/issues'
15
+
16
+ # The `source_url` points to the development reposiory for this cookbook. A
17
+ # `View Source` link will be displayed on this cookbook's page when uploaded to
18
+ # a Supermarket.
19
+ #
20
+ # source_url 'https://github.com/<insert_org_here>/<%= cookbook_name %>'
@@ -0,0 +1,5 @@
1
+ #
2
+ # Cookbook:: <%= cookbook_name %>
3
+ # Recipe:: <%= recipe_name %>
4
+ #
5
+ <%= license_description('#') %>
@@ -0,0 +1,22 @@
1
+ #
2
+ # Cookbook:: <%= cookbook_name %>
3
+ # Spec:: default
4
+ #
5
+ <%= license_description('#') %>
6
+
7
+ require 'spec_helper'
8
+
9
+ describe '<%= cookbook_name %>::<%= recipe_name %>' do
10
+ context 'When all attributes are default, on an Ubuntu 16.04' do
11
+ let(:chef_run) do
12
+ # for a complete list of available platforms and versions see:
13
+ # https://github.com/customink/fauxhai/blob/master/PLATFORMS.md
14
+ runner = ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04')
15
+ runner.converge(described_recipe)
16
+ end
17
+
18
+ it 'converges successfully' do
19
+ expect { chef_run }.to_not raise_error
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,128 @@
1
+ ## Below are example of common git excludes.
2
+ ## Please note that /cookbooks folder is ignored. This allows users to
3
+ ## clone individual cookbooks into the /cookbook folder of the chef repo
4
+ ## and work on them in parallel. This pattern also allows for chef-workstation
5
+ ## pattern, where base repo also builds out a dynamic chef workstation.
6
+ ## Examples of workstation cookbooks:
7
+ ## https://github.com/mwrock/chef_workstation
8
+ ## https://github.com/Nordstrom/chefdk_bootstrap
9
+
10
+
11
+ ## Ignore Chef related files and secrets
12
+ .chef
13
+ .chef/*.pem
14
+ .chef/encrypted_data_bag_secret
15
+ <%- if policy_only -%>
16
+ cookbooks/**
17
+ !cookbooks/README.md
18
+ <%- end -%>
19
+
20
+ ## Ignore Chef-Zero files
21
+ clients
22
+ nodes
23
+
24
+ # ## OS junk files
25
+ # [Tt]humbs.db
26
+ # *.DS_Store
27
+
28
+ # ## Example of the workstation pattern.
29
+ # !/cookbooks/chef_workstation/files/default/bundler/Gemfile
30
+ # !/cookbooks/chef_workstation/files/default/bundler/Gemfile.lock
31
+ # cookbooks/*
32
+ # !cookbooks/chef_workstation
33
+
34
+ # ##Chef
35
+ # .kitchen/
36
+ # .vagrant
37
+ # nodes
38
+ # metadata.json
39
+
40
+ # ##ruby
41
+ # *.gem
42
+ # Gemfile
43
+ # Gemfile.lock
44
+ .rake_test_cache
45
+
46
+ # ## Rails Heroku and other bits to ignore
47
+ # *.log
48
+ # *.sqlite3
49
+ # db/*.sqlite3
50
+ # .bundle
51
+ # log/*
52
+ # tmp/*
53
+ # public/system/*
54
+
55
+ # ##nodejs
56
+ # node_modules
57
+
58
+ # # Nuget (exclude all exes except for the one in the global build folder)
59
+ # nuget.exe
60
+ # !build/nuget/nuget.exe
61
+ # *.nupkg
62
+ # # NuGet packages (based on default naming convention)
63
+ # [Bb]uild/[Pp]ackages/
64
+
65
+ # # Build System # common build output folders
66
+ # build-common/
67
+ # output/
68
+
69
+ # ## Probably not a good idea to be keeing VM inages in source control
70
+ # *.vhd
71
+ # *.vhdx
72
+
73
+ # ## Pester Test summary
74
+ # Test.xml
75
+
76
+ # ##Webstorm files
77
+ # *.idea
78
+ # .idea
79
+ # .idea/
80
+
81
+ # ##Mono (or something?) files
82
+ # *.pidb
83
+ # *.userprefs
84
+
85
+ # ## Visual Studio files
86
+ # *.docstates
87
+ # *.[Oo]bj
88
+ # *.dat
89
+ # *.crc
90
+ # *.dbmdl
91
+ # *.pdb
92
+ # *.user
93
+ # *.aps
94
+ # *.pch
95
+ # *.vspscc
96
+ # *.vssscc
97
+ # *_i.c
98
+ # *_p.c
99
+ # *.ncb
100
+ # *.suo
101
+ # *.tlb
102
+ # *.tlh
103
+ # *.bak
104
+ # *.[Cc]ache
105
+ # *.ilk
106
+ # *.log
107
+ # *.lib
108
+ # *.sbr
109
+ # *.schemaview
110
+ # ipch/
111
+ # [Oo]bj/
112
+ # [Bb]in/*
113
+ # [Dd]ebug*/
114
+ # [Rr]elease*/
115
+ # Ankh.NoLoad
116
+
117
+ # ##Tooling
118
+ # _ReSharper*/
119
+ # *.[Rr]e[Ss]harper
120
+ # [Tt]est[Rr]esult*
121
+ # .[Jj]ust[Cc]ode
122
+ # *ncrunch*
123
+
124
+ # ##Subversion files
125
+ # .svn
126
+
127
+ # ## Office Temp Files
128
+ # ~$*
@@ -0,0 +1,34 @@
1
+ require 'mixlib/cli'
2
+ require 'rbconfig'
3
+ require 'pathname'
4
+ require 'idlc-sdk-pfm/command/base'
5
+ require 'idlc-sdk-pfm/generator'
6
+
7
+ module Pfm
8
+ module Command
9
+ # ## SharedGeneratorOptions
10
+ #
11
+ # These CLI options are shared amongst the generator commands
12
+ module SharedGeneratorOptions
13
+ include Mixlib::CLI
14
+
15
+ # You really want these to have default values, as
16
+ # they will likely be used all over the place.
17
+ # option :verbose,
18
+ # short: '-V',
19
+ # long: '--verbose',
20
+ # description: 'Show detailed output from the generator',
21
+ # boolean: true,
22
+ # default: false
23
+ end
24
+
25
+ # ## GeneratorCommands
26
+ #
27
+ # This module is the namespace for all subcommands of `pfm generate`
28
+ module GeneratorCommands
29
+ def self.build(class_name, params)
30
+ const_get(class_name).new(params)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,80 @@
1
+ require 'idlc-sdk-pfm/command/base'
2
+ require 'mixlib/shellout'
3
+
4
+ module Pfm
5
+ module Command
6
+ class Plan < Base
7
+ banner 'Usage: pfm plan [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
+ option :landscape,
22
+ short: '-l',
23
+ long: '--landscape',
24
+ description: 'Format the output with the terraform_landscape gem',
25
+ boolean: true,
26
+ default: false
27
+
28
+ def initialize
29
+ super
30
+ @params_valid = true
31
+ @errors = []
32
+ end
33
+
34
+ def run(params)
35
+ @params = params
36
+ read_and_validate_params
37
+
38
+ if params_valid?
39
+ deploy_setup
40
+ plan
41
+ # @workspace.cleanup causing bundler issues
42
+ 0
43
+ else
44
+ @errors.each { |error| err("Error: #{error}") }
45
+ parse_options(params)
46
+ msg(opt_parser)
47
+ 1
48
+ end
49
+ rescue DeploymentFailure => e
50
+ err("ERROR: #{e.message}\n")
51
+ 1
52
+ end
53
+
54
+ def plan
55
+ begin
56
+ Terraform::Binary.get("-update #{@workspace.tmp_dir}")
57
+ Terraform::Binary.plan(@workspace.tmp_dir) unless @config[:landscape]
58
+ Terraform::Binary.plan("#{@workspace.tmp_dir} | landscape") if @config[:landscape]
59
+ rescue
60
+ raise DeploymentFailure, 'Finished with errors'
61
+ end
62
+ end
63
+
64
+ def read_and_validate_params
65
+ arguments = parse_options(@params)
66
+
67
+ case arguments.size
68
+ when 0
69
+ @params_valid = true
70
+ else
71
+ @params_valid = false
72
+ end
73
+ end
74
+
75
+ def params_valid?
76
+ @params_valid
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,9 @@
1
+ log_level :info
2
+ log_location STDOUT
3
+ local_mode true
4
+ chef_zero.enabled true
5
+ ssl_verify_mode "verify_peer"
6
+ cookbook_path [
7
+ "c:/chef/bake/cookbooks",
8
+ "c:/chef/vendor/cookbooks"
9
+ ]
@@ -0,0 +1,16 @@
1
+ <powershell>
2
+ $logfile="C:\\Program Files\\Amazon\\Ec2ConfigService\\Logs\\packer-build-userdata.log"
3
+ # Allow script execution
4
+ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force
5
+ #PS Remoting and & winrm.cmd basic config
6
+ Enable-PSRemoting -Force -SkipNetworkProfileCheck
7
+ & winrm.cmd set winrm/config '@{MaxTimeoutms="1800000"}' >> $logfile
8
+ & winrm.cmd set winrm/config/winrs '@{MaxMemoryPerShellMB="1024"}' >> $logfile
9
+ & winrm.cmd set winrm/config/winrs '@{MaxShellsPerUser="50"}' >> $logfile
10
+ #Server settings - support username/password login
11
+ & winrm.cmd set winrm/config/service/auth '@{Basic="true"}' >> $logfile
12
+ & winrm.cmd set winrm/config/service '@{AllowUnencrypted="true"}' >> $logfile
13
+ & winrm.cmd set winrm/config/winrs '@{MaxMemoryPerShellMB="1024"}' >> $logfile
14
+ #Firewall Config
15
+ & netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" profile=public protocol=tcp localport=5985 remoteip=localsubnet new remoteip=any >> $logfile
16
+ </powershell>
@@ -0,0 +1,6 @@
1
+ log_level :info
2
+ log_location STDOUT
3
+ local_mode true
4
+ chef_zero.enabled true
5
+ ssl_verify_mode "verify_peer"
6
+ cookbook_path [ "{{user `chef_dir`}}/cookbooks", "{{user `chef_dir`}}/vendor/cookbooks"]