wombat-cli 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/DESIGN.md +11 -3
  3. data/{cookbooks → generator_files/cookbooks}/workstation/recipes/browser.rb +14 -0
  4. data/{templates → generator_files/templates}/cfn.json.erb +12 -0
  5. data/lib/wombat/build.rb +29 -14
  6. data/lib/wombat/cli.rb +64 -47
  7. data/lib/wombat/common.rb +120 -32
  8. data/lib/wombat/deploy.rb +2 -67
  9. data/lib/wombat/init.rb +30 -0
  10. data/lib/wombat/update.rb +17 -0
  11. data/lib/wombat/version.rb +1 -1
  12. metadata +172 -171
  13. data/wombat.example.yml +0 -62
  14. /data/{Vagrantfile → generator_files/Vagrantfile} +0 -0
  15. /data/{cookbooks → generator_files/cookbooks}/automate/.gitignore +0 -0
  16. /data/{cookbooks → generator_files/cookbooks}/automate/.kitchen.ec2.yml +0 -0
  17. /data/{cookbooks → generator_files/cookbooks}/automate/.kitchen.yml +0 -0
  18. /data/{cookbooks → generator_files/cookbooks}/automate/Berksfile +0 -0
  19. /data/{cookbooks → generator_files/cookbooks}/automate/README.md +0 -0
  20. /data/{cookbooks → generator_files/cookbooks}/automate/chefignore +0 -0
  21. /data/{cookbooks → generator_files/cookbooks}/automate/libraries/_helper.rb +0 -0
  22. /data/{cookbooks → generator_files/cookbooks}/automate/libraries/delivery_api.rb +0 -0
  23. /data/{cookbooks → generator_files/cookbooks}/automate/libraries/delivery_project.rb +0 -0
  24. /data/{cookbooks → generator_files/cookbooks}/automate/libraries/dsl.rb +0 -0
  25. /data/{cookbooks → generator_files/cookbooks}/automate/metadata.rb +0 -0
  26. /data/{cookbooks → generator_files/cookbooks}/automate/recipes/default.rb +0 -0
  27. /data/{cookbooks → generator_files/cookbooks}/automate/recipes/update-users.rb +0 -0
  28. /data/{cookbooks → generator_files/cookbooks}/automate/templates/delivery.erb +0 -0
  29. /data/{cookbooks → generator_files/cookbooks}/automate/test/fixtures/cookbooks/mock_data/files/automate.crt +0 -0
  30. /data/{cookbooks → generator_files/cookbooks}/automate/test/fixtures/cookbooks/mock_data/files/automate.key +0 -0
  31. /data/{cookbooks → generator_files/cookbooks}/automate/test/fixtures/cookbooks/mock_data/files/chef.crt +0 -0
  32. /data/{cookbooks → generator_files/cookbooks}/automate/test/fixtures/cookbooks/mock_data/files/chef.key +0 -0
  33. /data/{cookbooks → generator_files/cookbooks}/automate/test/fixtures/cookbooks/mock_data/files/compliance.crt +0 -0
  34. /data/{cookbooks → generator_files/cookbooks}/automate/test/fixtures/cookbooks/mock_data/files/compliance.key +0 -0
  35. /data/{cookbooks → generator_files/cookbooks}/automate/test/fixtures/cookbooks/mock_data/files/private.pem +0 -0
  36. /data/{cookbooks → generator_files/cookbooks}/automate/test/fixtures/cookbooks/mock_data/files/public.pub +0 -0
  37. /data/{cookbooks → generator_files/cookbooks}/automate/test/fixtures/cookbooks/mock_data/metadata.rb +0 -0
  38. /data/{cookbooks → generator_files/cookbooks}/automate/test/fixtures/cookbooks/mock_data/recipes/default.rb +0 -0
  39. /data/{cookbooks → generator_files/cookbooks}/automate/test/integration/default/automate_spec.rb +0 -0
  40. /data/{cookbooks → generator_files/cookbooks}/build_node/.gitignore +0 -0
  41. /data/{cookbooks → generator_files/cookbooks}/build_node/.kitchen.ec2.yml +0 -0
  42. /data/{cookbooks → generator_files/cookbooks}/build_node/.kitchen.yml +0 -0
  43. /data/{cookbooks → generator_files/cookbooks}/build_node/Berksfile +0 -0
  44. /data/{cookbooks → generator_files/cookbooks}/build_node/README.md +0 -0
  45. /data/{cookbooks → generator_files/cookbooks}/build_node/chefignore +0 -0
  46. /data/{cookbooks → generator_files/cookbooks}/build_node/metadata.rb +0 -0
  47. /data/{cookbooks → generator_files/cookbooks}/build_node/recipes/default.rb +0 -0
  48. /data/{cookbooks → generator_files/cookbooks}/build_node/templates/client.erb +0 -0
  49. /data/{cookbooks → generator_files/cookbooks}/build_node/test/fixtures/cookbooks/mock_data/files/automate.crt +0 -0
  50. /data/{cookbooks → generator_files/cookbooks}/build_node/test/fixtures/cookbooks/mock_data/files/automate.key +0 -0
  51. /data/{cookbooks → generator_files/cookbooks}/build_node/test/fixtures/cookbooks/mock_data/files/chef.crt +0 -0
  52. /data/{cookbooks → generator_files/cookbooks}/build_node/test/fixtures/cookbooks/mock_data/files/chef.key +0 -0
  53. /data/{cookbooks → generator_files/cookbooks}/build_node/test/fixtures/cookbooks/mock_data/files/compliance.crt +0 -0
  54. /data/{cookbooks → generator_files/cookbooks}/build_node/test/fixtures/cookbooks/mock_data/files/compliance.key +0 -0
  55. /data/{cookbooks → generator_files/cookbooks}/build_node/test/fixtures/cookbooks/mock_data/files/private.pem +0 -0
  56. /data/{cookbooks → generator_files/cookbooks}/build_node/test/fixtures/cookbooks/mock_data/files/public.pub +0 -0
  57. /data/{cookbooks → generator_files/cookbooks}/build_node/test/fixtures/cookbooks/mock_data/metadata.rb +0 -0
  58. /data/{cookbooks → generator_files/cookbooks}/build_node/test/fixtures/cookbooks/mock_data/recipes/default.rb +0 -0
  59. /data/{cookbooks → generator_files/cookbooks}/build_node/test/integration/default/build-node_spec.rb +0 -0
  60. /data/{cookbooks → generator_files/cookbooks}/chef_server/.gitignore +0 -0
  61. /data/{cookbooks → generator_files/cookbooks}/chef_server/.kitchen.ec2.yml +0 -0
  62. /data/{cookbooks → generator_files/cookbooks}/chef_server/.kitchen.yml +0 -0
  63. /data/{cookbooks → generator_files/cookbooks}/chef_server/Berksfile +0 -0
  64. /data/{cookbooks → generator_files/cookbooks}/chef_server/README.md +0 -0
  65. /data/{cookbooks → generator_files/cookbooks}/chef_server/chefignore +0 -0
  66. /data/{cookbooks → generator_files/cookbooks}/chef_server/metadata.rb +0 -0
  67. /data/{cookbooks → generator_files/cookbooks}/chef_server/recipes/bootstrap_users.rb +0 -0
  68. /data/{cookbooks → generator_files/cookbooks}/chef_server/recipes/default.rb +0 -0
  69. /data/{cookbooks → generator_files/cookbooks}/chef_server/test/fixtures/cookbooks/mock_data/files/automate.crt +0 -0
  70. /data/{cookbooks → generator_files/cookbooks}/chef_server/test/fixtures/cookbooks/mock_data/files/automate.key +0 -0
  71. /data/{cookbooks → generator_files/cookbooks}/chef_server/test/fixtures/cookbooks/mock_data/files/chef.crt +0 -0
  72. /data/{cookbooks → generator_files/cookbooks}/chef_server/test/fixtures/cookbooks/mock_data/files/chef.key +0 -0
  73. /data/{cookbooks → generator_files/cookbooks}/chef_server/test/fixtures/cookbooks/mock_data/files/compliance.crt +0 -0
  74. /data/{cookbooks → generator_files/cookbooks}/chef_server/test/fixtures/cookbooks/mock_data/files/compliance.key +0 -0
  75. /data/{cookbooks → generator_files/cookbooks}/chef_server/test/fixtures/cookbooks/mock_data/files/private.pem +0 -0
  76. /data/{cookbooks → generator_files/cookbooks}/chef_server/test/fixtures/cookbooks/mock_data/files/public.pub +0 -0
  77. /data/{cookbooks → generator_files/cookbooks}/chef_server/test/fixtures/cookbooks/mock_data/metadata.rb +0 -0
  78. /data/{cookbooks → generator_files/cookbooks}/chef_server/test/fixtures/cookbooks/mock_data/recipes/default.rb +0 -0
  79. /data/{cookbooks → generator_files/cookbooks}/chef_server/test/integration/default/chef_server_spec.rb +0 -0
  80. /data/{cookbooks → generator_files/cookbooks}/compliance/.gitignore +0 -0
  81. /data/{cookbooks → generator_files/cookbooks}/compliance/.kitchen.ec2.yml +0 -0
  82. /data/{cookbooks → generator_files/cookbooks}/compliance/.kitchen.yml +0 -0
  83. /data/{cookbooks → generator_files/cookbooks}/compliance/Berksfile +0 -0
  84. /data/{cookbooks → generator_files/cookbooks}/compliance/README.md +0 -0
  85. /data/{cookbooks → generator_files/cookbooks}/compliance/chefignore +0 -0
  86. /data/{cookbooks → generator_files/cookbooks}/compliance/metadata.rb +0 -0
  87. /data/{cookbooks → generator_files/cookbooks}/compliance/recipes/default.rb +0 -0
  88. /data/{cookbooks → generator_files/cookbooks}/compliance/spec/spec_helper.rb +0 -0
  89. /data/{cookbooks → generator_files/cookbooks}/compliance/spec/unit/recipes/default_spec.rb +0 -0
  90. /data/{cookbooks → generator_files/cookbooks}/compliance/templates/default/chef-compliance.rb.erb +0 -0
  91. /data/{cookbooks → generator_files/cookbooks}/compliance/test/fixtures/cookbooks/mock_data/files/automate.crt +0 -0
  92. /data/{cookbooks → generator_files/cookbooks}/compliance/test/fixtures/cookbooks/mock_data/files/automate.key +0 -0
  93. /data/{cookbooks → generator_files/cookbooks}/compliance/test/fixtures/cookbooks/mock_data/files/chef.crt +0 -0
  94. /data/{cookbooks → generator_files/cookbooks}/compliance/test/fixtures/cookbooks/mock_data/files/chef.key +0 -0
  95. /data/{cookbooks → generator_files/cookbooks}/compliance/test/fixtures/cookbooks/mock_data/files/compliance.crt +0 -0
  96. /data/{cookbooks → generator_files/cookbooks}/compliance/test/fixtures/cookbooks/mock_data/files/compliance.key +0 -0
  97. /data/{cookbooks → generator_files/cookbooks}/compliance/test/fixtures/cookbooks/mock_data/files/private.pem +0 -0
  98. /data/{cookbooks → generator_files/cookbooks}/compliance/test/fixtures/cookbooks/mock_data/files/public.pub +0 -0
  99. /data/{cookbooks → generator_files/cookbooks}/compliance/test/fixtures/cookbooks/mock_data/metadata.rb +0 -0
  100. /data/{cookbooks → generator_files/cookbooks}/compliance/test/fixtures/cookbooks/mock_data/recipes/default.rb +0 -0
  101. /data/{cookbooks → generator_files/cookbooks}/compliance/test/integration/default/compliance.rb +0 -0
  102. /data/{cookbooks → generator_files/cookbooks}/infranodes/.gitignore +0 -0
  103. /data/{cookbooks → generator_files/cookbooks}/infranodes/.kitchen.ec2.yml +0 -0
  104. /data/{cookbooks → generator_files/cookbooks}/infranodes/.kitchen.yml +0 -0
  105. /data/{cookbooks → generator_files/cookbooks}/infranodes/Berksfile +0 -0
  106. /data/{cookbooks → generator_files/cookbooks}/infranodes/README.md +0 -0
  107. /data/{cookbooks → generator_files/cookbooks}/infranodes/attributes/default.rb +0 -0
  108. /data/{cookbooks → generator_files/cookbooks}/infranodes/chefignore +0 -0
  109. /data/{cookbooks → generator_files/cookbooks}/infranodes/metadata.rb +0 -0
  110. /data/{cookbooks → generator_files/cookbooks}/infranodes/recipes/default.rb +0 -0
  111. /data/{cookbooks → generator_files/cookbooks}/infranodes/spec/spec_helper.rb +0 -0
  112. /data/{cookbooks → generator_files/cookbooks}/infranodes/spec/unit/recipes/default_spec.rb +0 -0
  113. /data/{cookbooks → generator_files/cookbooks}/infranodes/templates/default/client.rb.erb +0 -0
  114. /data/{cookbooks → generator_files/cookbooks}/infranodes/test/fixtures/cookbooks/mock_data/files/automate.crt +0 -0
  115. /data/{cookbooks → generator_files/cookbooks}/infranodes/test/fixtures/cookbooks/mock_data/files/automate.key +0 -0
  116. /data/{cookbooks → generator_files/cookbooks}/infranodes/test/fixtures/cookbooks/mock_data/files/chef.crt +0 -0
  117. /data/{cookbooks → generator_files/cookbooks}/infranodes/test/fixtures/cookbooks/mock_data/files/chef.key +0 -0
  118. /data/{cookbooks → generator_files/cookbooks}/infranodes/test/fixtures/cookbooks/mock_data/files/compliance.crt +0 -0
  119. /data/{cookbooks → generator_files/cookbooks}/infranodes/test/fixtures/cookbooks/mock_data/files/compliance.key +0 -0
  120. /data/{cookbooks → generator_files/cookbooks}/infranodes/test/fixtures/cookbooks/mock_data/files/private.pem +0 -0
  121. /data/{cookbooks → generator_files/cookbooks}/infranodes/test/fixtures/cookbooks/mock_data/files/public.pub +0 -0
  122. /data/{cookbooks → generator_files/cookbooks}/infranodes/test/fixtures/cookbooks/mock_data/metadata.rb +0 -0
  123. /data/{cookbooks → generator_files/cookbooks}/infranodes/test/fixtures/cookbooks/mock_data/recipes/default.rb +0 -0
  124. /data/{cookbooks → generator_files/cookbooks}/infranodes/test/integration/default/infranodes_spec.rb +0 -0
  125. /data/{cookbooks → generator_files/cookbooks}/infranodes/test/integration/helpers/serverspec/spec_helper.rb +0 -0
  126. /data/{cookbooks → generator_files/cookbooks}/wombat/.gitignore +0 -0
  127. /data/{cookbooks → generator_files/cookbooks}/wombat/.kitchen.yml +0 -0
  128. /data/{cookbooks → generator_files/cookbooks}/wombat/Berksfile +0 -0
  129. /data/{cookbooks → generator_files/cookbooks}/wombat/README.md +0 -0
  130. /data/{cookbooks → generator_files/cookbooks}/wombat/attributes/default.rb +0 -0
  131. /data/{cookbooks → generator_files/cookbooks}/wombat/attributes/packer.rb +0 -0
  132. /data/{cookbooks → generator_files/cookbooks}/wombat/chefignore +0 -0
  133. /data/{cookbooks → generator_files/cookbooks}/wombat/metadata.rb +0 -0
  134. /data/{cookbooks → generator_files/cookbooks}/wombat/recipes/authorized-keys.rb +0 -0
  135. /data/{cookbooks → generator_files/cookbooks}/wombat/recipes/default.rb +0 -0
  136. /data/{cookbooks → generator_files/cookbooks}/wombat/recipes/etc-hosts.rb +0 -0
  137. /data/{cookbooks → generator_files/cookbooks}/workstation/.gitignore +0 -0
  138. /data/{cookbooks → generator_files/cookbooks}/workstation/.kitchen.ec2.yml +0 -0
  139. /data/{cookbooks → generator_files/cookbooks}/workstation/.kitchen.yml +0 -0
  140. /data/{cookbooks → generator_files/cookbooks}/workstation/Berksfile +0 -0
  141. /data/{cookbooks → generator_files/cookbooks}/workstation/README.md +0 -0
  142. /data/{cookbooks → generator_files/cookbooks}/workstation/chefignore +0 -0
  143. /data/{cookbooks → generator_files/cookbooks}/workstation/files/atom.apm.list +0 -0
  144. /data/{cookbooks → generator_files/cookbooks}/workstation/files/atom.config.cson +0 -0
  145. /data/{cookbooks → generator_files/cookbooks}/workstation/files/cmder.xml +0 -0
  146. /data/{cookbooks → generator_files/cookbooks}/workstation/metadata.rb +0 -0
  147. /data/{cookbooks → generator_files/cookbooks}/workstation/recipes/certs-keys.rb +0 -0
  148. /data/{cookbooks → generator_files/cookbooks}/workstation/recipes/chef.rb +0 -0
  149. /data/{cookbooks → generator_files/cookbooks}/workstation/recipes/default.rb +0 -0
  150. /data/{cookbooks → generator_files/cookbooks}/workstation/recipes/dotnet.rb +0 -0
  151. /data/{cookbooks → generator_files/cookbooks}/workstation/recipes/editor.rb +0 -0
  152. /data/{cookbooks → generator_files/cookbooks}/workstation/recipes/profile.rb +0 -0
  153. /data/{cookbooks → generator_files/cookbooks}/workstation/recipes/terminal.rb +0 -0
  154. /data/{cookbooks → generator_files/cookbooks}/workstation/templates/default/bookmarks.html.erb +0 -0
  155. /data/{cookbooks → generator_files/cookbooks}/workstation/templates/default/data_collector.rb.erb +0 -0
  156. /data/{cookbooks → generator_files/cookbooks}/workstation/templates/default/ise_profile.ps1.erb +0 -0
  157. /data/{cookbooks → generator_files/cookbooks}/workstation/templates/default/knife.rb.erb +0 -0
  158. /data/{cookbooks → generator_files/cookbooks}/workstation/templates/default/master_preferences.json.erb +0 -0
  159. /data/{cookbooks → generator_files/cookbooks}/workstation/templates/default/ssh_config.erb +0 -0
  160. /data/{cookbooks → generator_files/cookbooks}/workstation/test/fixtures/cookbooks/mock_data/files/chef-server.crt +0 -0
  161. /data/{cookbooks → generator_files/cookbooks}/workstation/test/fixtures/cookbooks/mock_data/files/chef-server.key +0 -0
  162. /data/{cookbooks → generator_files/cookbooks}/workstation/test/fixtures/cookbooks/mock_data/files/compliance.crt +0 -0
  163. /data/{cookbooks → generator_files/cookbooks}/workstation/test/fixtures/cookbooks/mock_data/files/compliance.key +0 -0
  164. /data/{cookbooks → generator_files/cookbooks}/workstation/test/fixtures/cookbooks/mock_data/files/delivery.crt +0 -0
  165. /data/{cookbooks → generator_files/cookbooks}/workstation/test/fixtures/cookbooks/mock_data/files/delivery.key +0 -0
  166. /data/{cookbooks → generator_files/cookbooks}/workstation/test/fixtures/cookbooks/mock_data/files/private.pem +0 -0
  167. /data/{cookbooks → generator_files/cookbooks}/workstation/test/fixtures/cookbooks/mock_data/files/public.pub +0 -0
  168. /data/{cookbooks → generator_files/cookbooks}/workstation/test/fixtures/cookbooks/mock_data/metadata.rb +0 -0
  169. /data/{cookbooks → generator_files/cookbooks}/workstation/test/fixtures/cookbooks/mock_data/recipes/default.rb +0 -0
  170. /data/{cookbooks → generator_files/cookbooks}/workstation/test/integration/default/workstation_spec.rb +0 -0
  171. /data/{packer → generator_files}/files/.gitkeep +0 -0
  172. /data/{packer → generator_files/packer}/automate.json +0 -0
  173. /data/{packer → generator_files/packer}/build-node.json +0 -0
  174. /data/{packer → generator_files/packer}/chef-server.json +0 -0
  175. /data/{packer → generator_files/packer}/compliance.json +0 -0
  176. /data/{packer → generator_files/packer}/infranodes-windows.json +0 -0
  177. /data/{packer → generator_files/packer}/infranodes.json +0 -0
  178. /data/{packer → generator_files/packer}/workstation.json +0 -0
  179. /data/{templates → generator_files/templates}/bootstrap-aws.erb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca6a1a2f8fb637c2d25dd3126f74592d8112e1e7
4
- data.tar.gz: 957f61652039515b6f3a072f0846b02e8d195c2a
3
+ metadata.gz: 3a1385b339efd13cc101dba5b385915f2cb21265
4
+ data.tar.gz: 327d68edbc797dce831d4e3ae53101f3625a0826
5
5
  SHA512:
6
- metadata.gz: 81f88a7148288add492bf6026bfdc22a13d3f7b607d65ffc3fe30e606a4b451320a46fc27696c58fb769974ac7a8d462dd07795d3e85953dee48ab76f1bae722
7
- data.tar.gz: 47b7e2ff045a4b939c4ab83f5251bfdbd24021278fe62fc7eb4178fa4d23310651f9566b14fbadea7727be5a0492c5171c4e5080feadc419646db4b9609f1de3
6
+ metadata.gz: 6134c463249083075e7bd4ba5b9c16ee5883af1d744509aa5206e3935c48bd6a8d3af9df5953797a6bf6700842243f83cb10da863f5f06cb2d786be044695ce3
7
+ data.tar.gz: 364be3f32ffdac77f61a9d2405eba09527041fc47088242080ca2aacd4e092b96eaded8195612cd00f2dd04494dc92076c5527c52788fdcbcf00bc742ae8c405
data/DESIGN.md CHANGED
@@ -26,11 +26,19 @@ The core of wombat is the binary `bin/wombat`.
26
26
 
27
27
  * If the TEMPLATE argument is not provided it will execute against all templates in `./packer/`
28
28
 
29
- `wombat deploy STACK`
29
+ `wombat update lock`
30
30
 
31
31
  1. Create/update wombat.lock based on most recent Packer logs
32
- 2. Create cfn/gdm configuration from lock data fed through template
33
- 3. Deploy cfn/gdm stack
32
+
33
+ `wombat update template`
34
+
35
+ 1. Create cfn/gdm configuration from lock
36
+
37
+ * If no argument is provided it will update _both_ lock and template
38
+
39
+ `wombat deploy STACK`
40
+
41
+ 1. Deploy cfn/gdm stack
34
42
 
35
43
  `wombat outputs STACK`
36
44
 
@@ -43,3 +43,17 @@ registry_key 'Set Chrome as default HTTPS protocol association' do
43
43
  {:name => 'ProgId', :type => :string, :data => 'ChromeHTML'}
44
44
  ]
45
45
  end
46
+
47
+ # Enable ClearType for Chrome 52+
48
+ registry_key "HKEY_CURRENT_USER\\Control Panel\\Desktop" do
49
+ values [{
50
+ :name => "FontSmoothing",
51
+ :type => :string,
52
+ :data => 2
53
+ },{
54
+ :name => "FontSmoothingType",
55
+ :type => :dword,
56
+ :data => 2
57
+ }]
58
+ action :create
59
+ end
@@ -77,6 +77,15 @@
77
77
  }
78
78
  },
79
79
  "Resources": {
80
+ <% if @iam_roles -%>
81
+ "InstanceProfile" : {
82
+ "Type" : "AWS::IAM::InstanceProfile",
83
+ "Properties" : {
84
+ "Path" : "/",
85
+ "Roles" : <%= @iam_roles %>
86
+ }
87
+ },
88
+ <% end -%>
80
89
  "VPC": {
81
90
  "Type": "AWS::EC2::VPC",
82
91
  "Properties": {
@@ -341,6 +350,9 @@
341
350
  "Type": "AWS::EC2::Instance",
342
351
  "Properties": {
343
352
  "InstanceType": "m3.large",
353
+ <% if @iam_roles -%>
354
+ "IamInstanceProfile" : {"Ref" : "InstanceProfile"},
355
+ <% end -%>
344
356
  "AvailabilityZone": { "Ref": "AvailabilityZone" },
345
357
  "NetworkInterfaces": [
346
358
  {
data/lib/wombat/build.rb CHANGED
@@ -10,13 +10,16 @@ class BuildRunner
10
10
  attr_reader :templates, :builder, :config, :parallel
11
11
 
12
12
  def initialize(opts)
13
- @templates = opts.templates
13
+ @templates = opts.templates.nil? ? calculate_templates : opts.templates
14
14
  @builder = opts.builder.nil? ? "amazon-ebs" : opts.builder
15
15
  @config = opts.config
16
16
  @parallel = opts.parallel
17
17
  end
18
18
 
19
19
  def start
20
+ if which('packer').nil?
21
+ raise "packer binary not found in path, exiting..."
22
+ end
20
23
  banner("Generating certs (if necessary)")
21
24
  wombat['certs'].each do |hostname|
22
25
  gen_x509_cert(hostname)
@@ -70,19 +73,19 @@ class BuildRunner
70
73
  }
71
74
  }
72
75
  end
73
- elsif template_name == 'build-node'
76
+ elsif template_name =~ /build-node/
74
77
  build_nodes.each do |name, num|
75
78
  proc_hash[name] = {
76
- 'template' => 'build-node',
79
+ 'template' => template_name,
77
80
  'options' => {
78
81
  'node-number' => num
79
82
  }
80
83
  }
81
84
  end
82
- elsif template_name == 'workstation'
85
+ elsif template_name =~ /workstation/
83
86
  workstations.each do |name, num|
84
87
  proc_hash[name] = {
85
- 'template' => 'workstation',
88
+ 'template' => template_name,
86
89
  'options' => {
87
90
  'os' => wombat['workstations']['platform'],
88
91
  'workstation-number' => num
@@ -117,7 +120,7 @@ class BuildRunner
117
120
  end
118
121
 
119
122
  def shell_out_command(command)
120
- cmd = Mixlib::ShellOut.new(a_to_s(command), :timeout => timeout, live_stream: STDOUT)
123
+ cmd = Mixlib::ShellOut.new(a_to_s(command), :timeout => conf['timeout'], live_stream: STDOUT)
121
124
  cmd.run_command
122
125
  cmd
123
126
  end
@@ -139,18 +142,18 @@ class BuildRunner
139
142
  else
140
143
  base = template.split('.json')[0].tr('-', '_')
141
144
  end
142
- rm_cmd = "rm -rf #{cookbook_dir}/#{base}/Berksfile.lock vendored-cookbooks/#{base}"
145
+ rm_cmd = "rm -rf #{conf['cookbook_dir']}/#{base}/Berksfile.lock vendored-cookbooks/#{base}"
143
146
  shell_out_command(rm_cmd)
144
- vendor_cmd = "berks vendor -q -b #{cookbook_dir}/#{base}/Berksfile vendored-cookbooks/#{base}"
147
+ vendor_cmd = "berks vendor -q -b #{conf['cookbook_dir']}/#{base}/Berksfile vendored-cookbooks/#{base}"
145
148
  shell_out_command(vendor_cmd)
146
149
  end
147
150
 
148
151
  def log(template, builder, options)
149
152
  cloud = b_to_c(builder)
150
153
  case template
151
- when 'build-node'
154
+ when /build-node/
152
155
  log_name = "#{cloud}-build-node-#{options['node-number']}-#{linux}"
153
- when 'workstation'
156
+ when /workstation/
154
157
  log_name = "#{cloud}-workstation-#{options['workstation-number']}-#{linux}"
155
158
  when /infranodes/
156
159
  if options['os'] =~ /windows/
@@ -161,13 +164,24 @@ class BuildRunner
161
164
  else
162
165
  log_name = "#{cloud}-#{template}-#{linux}"
163
166
  end
164
- log_file = "#{log_dir}/#{log_name}.log"
167
+ log_file = "#{conf['log_dir']}/#{log_name}.log"
168
+ end
169
+
170
+ def which(cmd)
171
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
172
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
173
+ exts.each { |ext|
174
+ exe = File.join(path, "#{cmd}#{ext}")
175
+ return exe if File.executable?(exe) && !File.directory?(exe)
176
+ }
177
+ end
178
+ return nil
165
179
  end
166
180
 
167
181
  def packer_build_cmd(template, builder, options)
168
182
  create_infranodes_json
169
183
 
170
- if template == 'workstation'
184
+ if template =~ /workstation/
171
185
  source_ami = wombat['aws']['source_ami']['windows']
172
186
  source_image = wombat['gce']['source_image']['windows']
173
187
  elsif template =~ /infranodes/
@@ -183,8 +197,9 @@ class BuildRunner
183
197
  source_image = wombat['gce']['source_image'][linux]
184
198
  end
185
199
 
186
- # TODO: fail if packer isn't found in a graceful way
187
- cmd = %W(packer build #{packer_dir}/#{template}.json | tee #{log(template, builder, options)})
200
+ Dir.mkdir(conf['log_dir'], 0755) unless File.exist?(conf['log_dir'])
201
+
202
+ cmd = %W(packer build #{conf['packer_dir']}/#{template}.json | tee #{log(template, builder, options)})
188
203
  cmd.insert(2, "--only #{builder}")
189
204
  cmd.insert(2, "--var org=#{wombat['org']}")
190
205
  cmd.insert(2, "--var domain=#{wombat['domain']}")
data/lib/wombat/cli.rb CHANGED
@@ -7,6 +7,8 @@ require 'wombat/build'
7
7
  require 'wombat/deploy'
8
8
  require 'wombat/output'
9
9
  require 'wombat/delete'
10
+ require 'wombat/update'
11
+ require 'wombat/init'
10
12
 
11
13
  class Options
12
14
 
@@ -14,7 +16,6 @@ class Options
14
16
 
15
17
  def self.parse(args)
16
18
  options = OpenStruct.new
17
- options.templates = calculate_templates("*.json")
18
19
 
19
20
  global = OptionParser.new do |opts|
20
21
  opts.banner = "Usage: #{NAME} [SUBCOMMAND [options]]"
@@ -22,23 +23,18 @@ class Options
22
23
  opts.version = Wombat::VERSION
23
24
  opts.separator <<-COMMANDS.gsub(/^ {8}/, "")
24
25
  build : build one or more templates
26
+ delete : delete a stack
27
+ deploy : deploy a stack
25
28
  help : prints this help message
29
+ init : create wombat skeleton project
26
30
  list : list all templates in project
27
- deploy : deploy a stack
28
31
  outputs : get outputs for a stack
29
- delete : delete a stack
32
+ update : update lock and/or cloud template
30
33
  COMMANDS
31
34
  end
32
35
 
33
36
  templates_argv_proc = proc { |options|
34
- options.templates = calculate_templates(args) unless args.empty?
35
-
36
- options.templates.each do |t|
37
- if !File.exists?("packer/#{t}.json")
38
- $stderr.puts "File packer/#{t}.json does not exist for template '#{t}'"
39
- exit(1)
40
- end
41
- end
37
+ options.templates = ARGV unless args.empty?
42
38
  }
43
39
 
44
40
  box_version_argv_proc = proc { |options|
@@ -50,14 +46,11 @@ class Options
50
46
  options.stack = ARGV[0]
51
47
  }
52
48
 
49
+ file_argv_proc = proc { |options|
50
+ options.file = ARGV[0]
51
+ }
52
+
53
53
  subcommand = {
54
- help: {
55
- parser: OptionParser.new {},
56
- argv: proc { |options|
57
- puts global
58
- exit(0)
59
- }
60
- },
61
54
  build: {
62
55
  class: BuildRunner,
63
56
  parser: OptionParser.new { |opts|
@@ -77,17 +70,14 @@ class Options
77
70
  },
78
71
  argv: templates_argv_proc
79
72
  },
80
- list: {
81
- class: ListRunner,
82
- parser: OptionParser.new { |opts|
83
- opts.banner = "Usage: #{NAME} list [TEMPLATE ...]"
84
- },
85
- argv: templates_argv_proc
86
- },
87
- outputs: {
88
- class: OutputRunner,
73
+ delete: {
74
+ class: DeleteRunner,
89
75
  parser: OptionParser.new { |opts|
90
- opts.banner = "Usage: #{NAME} outputs [TEMPLATE ...]"
76
+ opts.banner = "Usage: #{NAME} delete STACK"
77
+
78
+ opts.on("-c CLOUD", "--cloud CLOUD", "Select cloud") do |opt|
79
+ options.cloud = opt
80
+ end
91
81
  },
92
82
  argv: stack_argv_proc
93
83
  },
@@ -104,23 +94,54 @@ class Options
104
94
  options.update_lock = opt
105
95
  end
106
96
 
107
- opts.on("--create-template", "Create template") do |opt|
97
+ opts.on("--update-template", "Update template") do |opt|
108
98
  options.create_template = opt
109
99
  end
110
100
  },
111
101
  argv: stack_argv_proc
112
102
  },
113
- delete: {
114
- class: DeleteRunner,
103
+ help: {
104
+ parser: OptionParser.new {},
105
+ argv: proc { |options|
106
+ puts global
107
+ exit(0)
108
+ }
109
+ },
110
+ init: {
111
+ class: InitRunner,
115
112
  parser: OptionParser.new { |opts|
116
- opts.banner = "Usage: #{NAME} delete STACK"
113
+ opts.banner = "Usage: #{NAME} init"
114
+
115
+ opts.on("-p PATH", "--path PATH", "Path to copy skeleton") do |opt|
116
+ options.path = opt
117
+ end
118
+ },
119
+ argv: stack_argv_proc
120
+ },
121
+ list: {
122
+ class: ListRunner,
123
+ parser: OptionParser.new { |opts|
124
+ opts.banner = "Usage: #{NAME} list [TEMPLATE ...]"
125
+ },
126
+ argv: templates_argv_proc
127
+ },
128
+ outputs: {
129
+ class: OutputRunner,
130
+ parser: OptionParser.new { |opts|
131
+ opts.banner = "Usage: #{NAME} outputs [TEMPLATE ...]"
132
+ },
133
+ argv: stack_argv_proc
134
+ },
135
+ update: {
136
+ class: UpdateRunner,
137
+ parser: OptionParser.new { |opts|
138
+ opts.banner = "Usage: #{NAME} update [lock || template]"
117
139
 
118
140
  opts.on("-c CLOUD", "--cloud CLOUD", "Select cloud") do |opt|
119
141
  options.cloud = opt
120
142
  end
121
143
  },
122
-
123
- argv: stack_argv_proc
144
+ argv: file_argv_proc
124
145
  }
125
146
  }
126
147
 
@@ -135,17 +156,6 @@ class Options
135
156
 
136
157
  options
137
158
  end
138
-
139
- def self.calculate_templates(globs)
140
- Dir.chdir('packer') do
141
- Array(globs).
142
- map { |glob| result = Dir.glob("#{glob}"); result.empty? ? glob : result }.
143
- flatten.
144
- sort.
145
- delete_if { |file| file =~ /\.variables\./ }.
146
- map { |template| template.sub(/\.json$/, '') }
147
- end
148
- end
149
159
  end
150
160
 
151
161
  class ListRunner
@@ -155,11 +165,18 @@ class ListRunner
155
165
  attr_reader :templates
156
166
 
157
167
  def initialize(opts)
158
- @templates = opts.templates
168
+ @templates = opts.templates.nil? ? calculate_templates : opts.templates
159
169
  end
160
170
 
161
171
  def start
162
- templates.each { |template| puts template }
172
+ templates.each do |t|
173
+ if !File.exists?("#{conf['packer_dir']}/#{t}.json")
174
+ $stderr.puts "File #{conf['packer_dir']}/#{t}.json does not exist for template '#{t}'"
175
+ exit(1)
176
+ else
177
+ puts t
178
+ end
179
+ end
163
180
  end
164
181
  end
165
182
 
data/lib/wombat/common.rb CHANGED
@@ -4,6 +4,7 @@ require 'erb'
4
4
  require 'openssl'
5
5
  require 'net/ssh'
6
6
  require 'benchmark'
7
+ require 'fileutils'
7
8
 
8
9
  module Common
9
10
 
@@ -28,22 +29,28 @@ module Common
28
29
 
29
30
  def wombat
30
31
  if !File.exists?('wombat.yml')
31
- File.open('wombat.yml', 'w') do |f|
32
- f.puts File.read('wombat.example.yml')
33
- end
32
+ warn('No wombat.yml found, copying example')
33
+ gen_dir = "#{File.expand_path("../..", File.dirname(__FILE__))}/generator_files"
34
+ FileUtils.cp_r "#{gen_dir}/wombat.yml", Dir.pwd
34
35
  end
35
36
  YAML.load(File.read('wombat.yml'))
36
37
  end
37
38
 
38
39
  def lock
39
- JSON.parse(File.read('wombat.lock'))
40
+ if !File.exists?('wombat.lock')
41
+ warn('No wombat.lock found')
42
+ return 1
43
+ else
44
+ JSON.parse(File.read('wombat.lock'))
45
+ end
40
46
  end
41
47
 
42
48
  def bootstrap_aws
43
49
  @workstation_passwd = wombat['workstations']['password']
44
- rendered = ERB.new(File.read('templates/bootstrap-aws.erb'), nil, '-').result(binding)
45
- File.open("#{packer_dir}/scripts/bootstrap-aws.txt", 'w') { |file| file.puts rendered }
46
- banner("Generated: #{packer_dir}/scripts/bootstrap-aws.txt")
50
+ rendered = ERB.new(File.read("#{conf['template_dir']}/bootstrap-aws.erb"), nil, '-').result(binding)
51
+ Dir.mkdir("#{conf['packer_dir']}/scripts", 0755) unless File.exist?("#{conf['packer_dir']}/scripts")
52
+ File.open("#{conf['packer_dir']}/scripts/bootstrap-aws.txt", 'w') { |file| file.puts rendered }
53
+ banner("Generated: #{conf['packer_dir']}/scripts/bootstrap-aws.txt")
47
54
  end
48
55
 
49
56
  def gen_x509_cert(hostname)
@@ -72,12 +79,14 @@ module Common
72
79
  'keyid:always,issuer:always')
73
80
 
74
81
  cert.sign(rsa_key, OpenSSL::Digest::SHA256.new)
82
+
83
+ Dir.mkdir(conf['key_dir'], 0755) unless File.exist?(conf['key_dir'])
75
84
 
76
- if File.exist?("#{key_dir}/#{hostname}.crt") && File.exist?("#{key_dir}/#{hostname}.key")
85
+ if File.exist?("#{conf['key_dir']}/#{hostname}.crt") && File.exist?("#{conf['key_dir']}/#{hostname}.key")
77
86
  puts "An x509 certificate already exists for #{hostname}"
78
87
  else
79
- File.open("#{key_dir}/#{hostname}.crt", 'w') { |file| file.puts cert.to_pem }
80
- File.open("#{key_dir}/#{hostname}.key", 'w') { |file| file.puts rsa_key.to_pem }
88
+ File.open("#{conf['key_dir']}/#{hostname}.crt", 'w') { |file| file.puts cert.to_pem }
89
+ File.open("#{conf['key_dir']}/#{hostname}.key", 'w') { |file| file.puts rsa_key.to_pem }
81
90
  puts "Certificate created for #{wombat['domain_prefix']}#{hostname}.#{wombat['domain']}"
82
91
  end
83
92
  end
@@ -90,11 +99,13 @@ module Common
90
99
 
91
100
  openssh_format = "#{type} #{data}"
92
101
 
93
- if File.exist?("#{key_dir}/public.pub") && File.exist?("#{key_dir}/private.pem")
102
+ Dir.mkdir(conf['key_dir'], 0755) unless File.exist?(conf['key_dir'])
103
+
104
+ if File.exist?("#{conf['key_dir']}/public.pub") && File.exist?("#{conf['key_dir']}/private.pem")
94
105
  puts 'An SSH keypair already exists'
95
106
  else
96
- File.open("#{key_dir}/public.pub", 'w') { |file| file.puts openssh_format }
97
- File.open("#{key_dir}/private.pem", 'w') { |file| file.puts rsa_key.to_pem }
107
+ File.open("#{conf['key_dir']}/public.pub", 'w') { |file| file.puts openssh_format }
108
+ File.open("#{conf['key_dir']}/private.pem", 'w') { |file| file.puts rsa_key.to_pem }
98
109
  puts 'SSH Keypair created'
99
110
  end
100
111
  end
@@ -129,13 +140,13 @@ module Common
129
140
  end
130
141
 
131
142
  def create_infranodes_json
132
- if File.exists?("#{packer_dir}/file/infranodes-info.json")
143
+ if File.exists?("#{conf['packer_dir']}/file/infranodes-info.json")
133
144
  current_state = JSON(File.read('files/infranodes-info.json'))
134
145
  else
135
146
  current_state = nil
136
147
  end
137
148
  return if current_state == infranodes # yay idempotence
138
- File.open("#{packer_dir}/files/infranodes-info.json", 'w') do |f|
149
+ File.open("#{conf['packer_dir']}/files/infranodes-info.json", 'w') do |f|
139
150
  f.puts JSON.pretty_generate(infranodes)
140
151
  end
141
152
  end
@@ -144,35 +155,112 @@ module Common
144
155
  wombat['linux'].nil? ? 'ubuntu' : wombat['linux']
145
156
  end
146
157
 
147
- def key_dir
148
- wombat['conf'].nil? ? 'keys' : wombat['conf']['key_dir']
158
+ def conf
159
+ conf = wombat['conf']
160
+ conf ||= {}
161
+ conf['key_dir'] ||= 'keys'
162
+ conf['cookbook_dir'] ||= 'cookbooks'
163
+ conf['packer_dir'] ||= 'packer'
164
+ conf['log_dir'] ||= 'logs'
165
+ conf['stack_dir'] ||= 'stacks'
166
+ conf['template_dir'] ||= 'templates'
167
+ conf['timeout'] ||= 7200
168
+ conf['audio'] ||= false
169
+ conf
149
170
  end
150
171
 
151
- def cookbook_dir
152
- wombat['conf'].nil? ? 'cookbooks' : wombat['conf']['cookbook_dir']
172
+ def is_mac?
173
+ (/darwin/ =~ RUBY_PLATFORM) != nil
153
174
  end
154
175
 
155
- def packer_dir
156
- wombat['conf'].nil? ? 'packer' : wombat['conf']['packer_dir']
176
+ def audio?
177
+ is_mac? && conf['audio']
157
178
  end
158
179
 
159
- def log_dir
160
- wombat['conf'].nil? ? 'logs' : wombat['conf']['log_dir']
180
+ def logs
181
+ Dir.glob("#{conf['log_dir']}/#{cloud}*.log").reject { |l| !l.match(wombat['linux']) }
161
182
  end
162
183
 
163
- def stack_dir
164
- wombat['conf'].nil? ? 'stacks' : wombat['conf']['stack_dir']
184
+ def calculate_templates
185
+ globs = "*.json"
186
+ Dir.chdir(conf['packer_dir']) do
187
+ Array(globs).
188
+ map { |glob| result = Dir.glob("#{glob}"); result.empty? ? glob : result }.
189
+ flatten.
190
+ sort.
191
+ delete_if { |file| file =~ /\.variables\./ }.
192
+ map { |template| template.sub(/\.json$/, '') }
193
+ end
165
194
  end
166
195
 
167
- def timeout
168
- wombat['conf']['timeout'] ||= 7200
169
- end
196
+ def update_lock(cloud)
197
+ copy = {}
198
+ copy = wombat
199
+ region = copy[cloud]['region']
200
+ linux = copy['linux']
201
+ copy['amis'] = { region => {} }
170
202
 
171
- def is_mac?
172
- (/darwin/ =~ RUBY_PLATFORM) != nil
203
+ if logs.length == 0
204
+ warn('No logs found - skipping lock update')
205
+ else
206
+ logs.each do |log|
207
+ case log
208
+ when /build-node/
209
+ copy['amis'][region]['build-node'] ||= {}
210
+ num = log.split('-')[3]
211
+ copy['amis'][region]['build-node'].store(num, parse_log(log, cloud))
212
+ when /workstation/
213
+ copy['amis'][region]['workstation'] ||= {}
214
+ num = log.split('-')[2]
215
+ copy['amis'][region]['workstation'].store(num, parse_log(log, cloud))
216
+ when /infranodes/
217
+ copy['amis'][region]['infranodes'] ||= {}
218
+ name = log.split('-')[2]
219
+ copy['amis'][region]['infranodes'].store(name, parse_log(log, cloud))
220
+ else
221
+ instance = log.match("#{cloud}-(.*)-(.*)\.log")[1]
222
+ copy['amis'][region].store(instance, parse_log(log, cloud))
223
+ end
224
+ end
225
+ copy['last_updated'] = Time.now.gmtime.strftime('%Y%m%d%H%M%S')
226
+ banner('Updating wombat.lock')
227
+ File.open('wombat.lock', 'w') do |f|
228
+ f.write(JSON.pretty_generate(copy))
229
+ end
230
+ end
173
231
  end
174
232
 
175
- def audio?
176
- is_mac? && wombat['conf']['audio']
233
+ def update_template(cloud)
234
+ if lock == 1
235
+ warn('No lock - skipping template creation')
236
+ else
237
+ region = lock['aws']['region']
238
+ @chef_server_ami = lock['amis'][region]['chef-server']
239
+ @automate_ami = lock['amis'][region]['automate']
240
+ @compliance_ami = lock['amis'][region]['compliance']
241
+ @build_nodes = lock['build-nodes']['count'].to_i
242
+ @build_node_ami = {}
243
+ 1.upto(@build_nodes) do |i|
244
+ @build_node_ami[i] = lock['amis'][region]['build-node'][i.to_s]
245
+ end
246
+ @infra = {}
247
+ infranodes.each do |name, _rl|
248
+ @infra[name] = lock['amis'][region]['infranodes'][name]
249
+ end
250
+ @workstations = lock['workstations']['count'].to_i
251
+ @workstation_ami = {}
252
+ 1.upto(@workstations) do |i|
253
+ @workstation_ami[i] = lock['amis'][region]['workstation'][i.to_s]
254
+ end
255
+ @availability_zone = lock['aws']['az']
256
+ @iam_roles = lock['aws']['iam_roles']
257
+ @demo = lock['name']
258
+ @version = lock['version']
259
+ @ttl = lock['ttl']
260
+ rendered_cfn = ERB.new(File.read("#{conf['template_dir']}/cfn.json.erb"), nil, '-').result(binding)
261
+ Dir.mkdir(conf['stack_dir'], 0755) unless File.exist?(conf['stack_dir'])
262
+ File.open("#{conf['stack_dir']}/#{@demo}.json", 'w') { |file| file.puts rendered_cfn }
263
+ banner("Generated: #{conf['stack_dir']}/#{@demo}.json")
264
+ end
177
265
  end
178
266
  end