motherbrain 0.0.0.placeholder → 0.13.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +9 -0
  5. data/CHANGELOG.md +196 -0
  6. data/COMMANDS.md +9 -0
  7. data/CONTRIBUTING.md +24 -0
  8. data/Dockerfile +26 -0
  9. data/Gemfile +60 -2
  10. data/Guardfile +30 -0
  11. data/LICENSE +10 -0
  12. data/MANIFESTS.md +90 -0
  13. data/OPERATORS_GUIDE.md +195 -0
  14. data/PLUGINS.md +268 -0
  15. data/README.md +304 -16
  16. data/Thorfile +123 -0
  17. data/VAGRANT.md +116 -0
  18. data/bin/boot +9 -0
  19. data/bin/mb +5 -0
  20. data/bin/mbsrv +5 -0
  21. data/config.json +32 -0
  22. data/features/cli/bootstrap_command/configurable_scripts.feature +32 -0
  23. data/features/cli/configure_command.feature +57 -0
  24. data/features/cli/environment_command/create_command.feature +22 -0
  25. data/features/cli/environment_command/destroy_command.feature +33 -0
  26. data/features/cli/environment_command/from_command.feature +29 -0
  27. data/features/cli/environment_command/list_command.feature +0 -0
  28. data/features/cli/node_limiting.feature +47 -0
  29. data/features/cli/plugin_command/list_command.feature +46 -0
  30. data/features/cli/service_command/service_command.feature +21 -0
  31. data/features/cli/template_command.feature +10 -0
  32. data/features/cli/validate_config.feature +46 -0
  33. data/features/step_definitions/bootstrap_steps.rb +57 -0
  34. data/features/step_definitions/chef_server_steps.rb +3 -0
  35. data/features/step_definitions/configuration_steps.rb +18 -0
  36. data/features/step_definitions/core_cli_steps.rb +33 -0
  37. data/features/step_definitions/environment_steps.rb +43 -0
  38. data/features/step_definitions/node_steps.rb +3 -0
  39. data/features/step_definitions/plugin_steps.rb +15 -0
  40. data/features/step_definitions/template_steps.rb +7 -0
  41. data/features/support/env.rb +68 -0
  42. data/lib/mb/api.rb +8 -0
  43. data/lib/mb/api/application.rb +7 -0
  44. data/lib/mb/api/endpoint.rb +5 -0
  45. data/lib/mb/api/helpers.rb +38 -0
  46. data/lib/mb/api/v1.rb +56 -0
  47. data/lib/mb/api/v1/config_endpoint.rb +12 -0
  48. data/lib/mb/api/v1/environments_endpoint.rb +174 -0
  49. data/lib/mb/api/v1/jobs_endpoint.rb +31 -0
  50. data/lib/mb/api/v1/plugins_endpoint.rb +90 -0
  51. data/lib/mb/api/validators.rb +5 -0
  52. data/lib/mb/api/validators/sem_ver.rb +18 -0
  53. data/lib/mb/application.rb +148 -0
  54. data/lib/mb/berkshelf.rb +50 -0
  55. data/lib/mb/bootstrap.rb +9 -0
  56. data/lib/mb/bootstrap/manager.rb +250 -0
  57. data/lib/mb/bootstrap/manifest.rb +131 -0
  58. data/lib/mb/bootstrap/routine.rb +199 -0
  59. data/lib/mb/bootstrap/template.rb +73 -0
  60. data/lib/mb/bootstrap/worker.rb +227 -0
  61. data/lib/mb/chef.rb +6 -0
  62. data/lib/mb/chef/config.rb +69 -0
  63. data/lib/mb/chef/run_list_item.rb +115 -0
  64. data/lib/mb/chef_mutex.rb +304 -0
  65. data/lib/mb/clean_room_base.rb +39 -0
  66. data/lib/mb/cli.rb +50 -0
  67. data/lib/mb/cli/base.rb +51 -0
  68. data/lib/mb/cli/shell.rb +29 -0
  69. data/lib/mb/cli/shell/basic.rb +11 -0
  70. data/lib/mb/cli/shell/color.rb +11 -0
  71. data/lib/mb/cli/shell/ext.rb +41 -0
  72. data/lib/mb/cli/sub_command.rb +95 -0
  73. data/lib/mb/cli/sub_command/component.rb +56 -0
  74. data/lib/mb/cli/sub_command/plugin.rb +232 -0
  75. data/lib/mb/cli_client.rb +178 -0
  76. data/lib/mb/cli_gateway.rb +426 -0
  77. data/lib/mb/cli_gateway/sub_commands.rb +3 -0
  78. data/lib/mb/cli_gateway/sub_commands/environment.rb +124 -0
  79. data/lib/mb/cli_gateway/sub_commands/plugin.rb +148 -0
  80. data/lib/mb/command.rb +88 -0
  81. data/lib/mb/command_invoker.rb +235 -0
  82. data/lib/mb/command_invoker/worker.rb +40 -0
  83. data/lib/mb/command_runner.rb +233 -0
  84. data/lib/mb/component.rb +245 -0
  85. data/lib/mb/config.rb +275 -0
  86. data/lib/mb/config_manager.rb +75 -0
  87. data/lib/mb/console.rb +35 -0
  88. data/lib/mb/cookbook_metadata.rb +73 -0
  89. data/lib/mb/core_ext.rb +3 -0
  90. data/lib/mb/core_ext/dir.rb +37 -0
  91. data/lib/mb/core_ext/enumerable.rb +48 -0
  92. data/lib/mb/core_ext/file.rb +24 -0
  93. data/lib/mb/core_ext/signal.rb +11 -0
  94. data/lib/mb/environment_manager.rb +195 -0
  95. data/lib/mb/error_handler.rb +212 -0
  96. data/lib/mb/errors.rb +693 -0
  97. data/lib/mb/file_system.rb +60 -0
  98. data/lib/mb/file_system/tempfile.rb +25 -0
  99. data/lib/mb/gear.rb +154 -0
  100. data/lib/mb/gears.rb +8 -0
  101. data/lib/mb/gears/dynamic_service.rb +218 -0
  102. data/lib/mb/gears/jmx.rb +24 -0
  103. data/lib/mb/gears/jmx/action.rb +46 -0
  104. data/lib/mb/gears/mysql.rb +20 -0
  105. data/lib/mb/gears/mysql/action.rb +190 -0
  106. data/lib/mb/gears/service.rb +163 -0
  107. data/lib/mb/gears/service/action.rb +58 -0
  108. data/lib/mb/gears/service/action_runner.rb +161 -0
  109. data/lib/mb/grape_ext.rb +3 -0
  110. data/lib/mb/grape_ext/endpoint.rb +13 -0
  111. data/lib/mb/group.rb +143 -0
  112. data/lib/mb/job.rb +183 -0
  113. data/lib/mb/job/state_machine.rb +34 -0
  114. data/lib/mb/job/states.rb +46 -0
  115. data/lib/mb/job_manager.rb +96 -0
  116. data/lib/mb/job_record.rb +67 -0
  117. data/lib/mb/job_ticket.rb +25 -0
  118. data/lib/mb/lock_manager.rb +116 -0
  119. data/lib/mb/logging.rb +134 -0
  120. data/lib/mb/logging/basic_format.rb +31 -0
  121. data/lib/mb/manifest.rb +128 -0
  122. data/lib/mb/mixin.rb +3 -0
  123. data/lib/mb/mixin/attribute_setting.rb +265 -0
  124. data/lib/mb/mixin/coded_exit.rb +49 -0
  125. data/lib/mb/mixin/locks.rb +54 -0
  126. data/lib/mb/mixin/services.rb +100 -0
  127. data/lib/mb/node_filter.rb +97 -0
  128. data/lib/mb/node_querier.rb +527 -0
  129. data/lib/mb/plugin.rb +300 -0
  130. data/lib/mb/plugin_manager.rb +589 -0
  131. data/lib/mb/provisioner.rb +186 -0
  132. data/lib/mb/provisioner/manager.rb +213 -0
  133. data/lib/mb/provisioner/manifest.rb +125 -0
  134. data/lib/mb/provisioner/provision_data.rb +96 -0
  135. data/lib/mb/provisioners.rb +5 -0
  136. data/lib/mb/provisioners/aws.rb +395 -0
  137. data/lib/mb/rest_gateway.rb +72 -0
  138. data/lib/mb/ridley_ext.rb +5 -0
  139. data/lib/mb/ridley_ext/cookbook_object.rb +15 -0
  140. data/lib/mb/srv_ctl.rb +183 -0
  141. data/lib/mb/test.rb +104 -0
  142. data/lib/mb/thor_ext.rb +49 -0
  143. data/lib/mb/upgrade.rb +6 -0
  144. data/lib/mb/upgrade/manager.rb +85 -0
  145. data/lib/mb/upgrade/worker.rb +149 -0
  146. data/lib/mb/version.rb +1 -1
  147. data/lib/motherbrain.rb +166 -2
  148. data/man/man_helper.rb +81 -0
  149. data/man/mb.1 +494 -0
  150. data/man/mb.1.html +300 -0
  151. data/man/mb.1.ronn.erb +62 -0
  152. data/motherbrain.gemspec +56 -20
  153. data/scripts/node_name.rb +14 -0
  154. data/spec/fixtures/cb_metadata.json +7 -0
  155. data/spec/fixtures/cb_metadata.rb +14 -0
  156. data/spec/fixtures/fake_id_rsa +27 -0
  157. data/spec/fixtures/fake_key.pem +27 -0
  158. data/spec/fixtures/myface-0.1.0/metadata.rb +14 -0
  159. data/spec/fixtures/myface-0.1.0/motherbrain.rb +0 -0
  160. data/spec/fixtures/test_env.json +15 -0
  161. data/spec/spec_helper.rb +67 -0
  162. data/spec/support/actor_mocking.rb +7 -0
  163. data/spec/support/berkshelf.rb +24 -0
  164. data/spec/support/chef_server.rb +102 -0
  165. data/spec/support/doubles.rb +11 -0
  166. data/spec/support/klass.rb +10 -0
  167. data/spec/support/matchers/each.rb +12 -0
  168. data/spec/support/matchers/error_codes.rb +5 -0
  169. data/spec/support/matchers/exit_codes.rb +57 -0
  170. data/spec/support/matchers/jobs.rb +11 -0
  171. data/spec/support/spec_helpers.rb +145 -0
  172. data/spec/unit/mb/api/application_spec.rb +11 -0
  173. data/spec/unit/mb/api/helpers_spec.rb +5 -0
  174. data/spec/unit/mb/api/v1/config_endpoint_spec.rb +19 -0
  175. data/spec/unit/mb/api/v1/environments_endpoint_spec.rb +71 -0
  176. data/spec/unit/mb/api/v1/jobs_endpoint_spec.rb +24 -0
  177. data/spec/unit/mb/api/v1/plugins_endpoint_spec.rb +298 -0
  178. data/spec/unit/mb/api/v1_spec.rb +37 -0
  179. data/spec/unit/mb/api/validators/sem_ver_spec.rb +5 -0
  180. data/spec/unit/mb/application_spec.rb +19 -0
  181. data/spec/unit/mb/berkshelf_spec.rb +38 -0
  182. data/spec/unit/mb/bootstrap/manager_spec.rb +347 -0
  183. data/spec/unit/mb/bootstrap/manifest_spec.rb +333 -0
  184. data/spec/unit/mb/bootstrap/routine_spec.rb +393 -0
  185. data/spec/unit/mb/bootstrap/template_spec.rb +100 -0
  186. data/spec/unit/mb/bootstrap/worker_spec.rb +194 -0
  187. data/spec/unit/mb/chef/config_spec.rb +33 -0
  188. data/spec/unit/mb/chef/run_list_item_spec.rb +34 -0
  189. data/spec/unit/mb/chef_mutex_spec.rb +314 -0
  190. data/spec/unit/mb/clean_room_base_spec.rb +31 -0
  191. data/spec/unit/mb/cli/base_spec.rb +43 -0
  192. data/spec/unit/mb/cli/shell/basic_spec.rb +5 -0
  193. data/spec/unit/mb/cli/shell/color_spec.rb +5 -0
  194. data/spec/unit/mb/cli/shell/ext_spec.rb +11 -0
  195. data/spec/unit/mb/cli/shell_spec.rb +38 -0
  196. data/spec/unit/mb/cli/sub_command/base_spec.rb +102 -0
  197. data/spec/unit/mb/cli/sub_command/component_spec.rb +5 -0
  198. data/spec/unit/mb/cli/sub_command/plugin_spec.rb +91 -0
  199. data/spec/unit/mb/cli/sub_command_spec.rb +43 -0
  200. data/spec/unit/mb/cli/ui.rb +0 -0
  201. data/spec/unit/mb/cli_client_spec.rb +51 -0
  202. data/spec/unit/mb/cli_gateway_spec.rb +386 -0
  203. data/spec/unit/mb/command_invoker/worker_spec.rb +43 -0
  204. data/spec/unit/mb/command_invoker_spec.rb +230 -0
  205. data/spec/unit/mb/command_runner_spec.rb +299 -0
  206. data/spec/unit/mb/command_spec.rb +76 -0
  207. data/spec/unit/mb/component_spec.rb +185 -0
  208. data/spec/unit/mb/config_manager_spec.rb +31 -0
  209. data/spec/unit/mb/config_spec.rb +408 -0
  210. data/spec/unit/mb/cookbook_metadata_spec.rb +89 -0
  211. data/spec/unit/mb/core_ext/dir_spec.rb +92 -0
  212. data/spec/unit/mb/core_ext/enumerable_spec.rb +104 -0
  213. data/spec/unit/mb/core_ext/file_spec.rb +58 -0
  214. data/spec/unit/mb/core_ext/signal_spec.rb +24 -0
  215. data/spec/unit/mb/environment_manager_spec.rb +166 -0
  216. data/spec/unit/mb/error_handler_spec.rb +173 -0
  217. data/spec/unit/mb/errors_spec.rb +132 -0
  218. data/spec/unit/mb/file_system/tempfile_spec.rb +14 -0
  219. data/spec/unit/mb/file_system_spec.rb +69 -0
  220. data/spec/unit/mb/gear_spec.rb +125 -0
  221. data/spec/unit/mb/gears/dynamic_service_spec.rb +187 -0
  222. data/spec/unit/mb/gears/jmx/action_spec.rb +34 -0
  223. data/spec/unit/mb/gears/jmx_spec.rb +32 -0
  224. data/spec/unit/mb/gears/mysql/action_spec.rb +118 -0
  225. data/spec/unit/mb/gears/mysql_spec.rb +21 -0
  226. data/spec/unit/mb/gears/service/action_runner_spec.rb +182 -0
  227. data/spec/unit/mb/gears/service/action_spec.rb +44 -0
  228. data/spec/unit/mb/gears/service_spec.rb +124 -0
  229. data/spec/unit/mb/group_spec.rb +280 -0
  230. data/spec/unit/mb/job_manager_spec.rb +56 -0
  231. data/spec/unit/mb/job_record_spec.rb +60 -0
  232. data/spec/unit/mb/job_spec.rb +201 -0
  233. data/spec/unit/mb/locks_manager_spec.rb +88 -0
  234. data/spec/unit/mb/logging_spec.rb +133 -0
  235. data/spec/unit/mb/manifest_spec.rb +105 -0
  236. data/spec/unit/mb/mixin/attribute_setting_spec.rb +180 -0
  237. data/spec/unit/mb/mixin/coded_exit_spec.rb +25 -0
  238. data/spec/unit/mb/mixin/locks_spec.rb +32 -0
  239. data/spec/unit/mb/mixin/services_spec.rb +75 -0
  240. data/spec/unit/mb/node_filter_spec.rb +86 -0
  241. data/spec/unit/mb/node_querier_spec.rb +532 -0
  242. data/spec/unit/mb/plugin_manager_spec.rb +724 -0
  243. data/spec/unit/mb/plugin_spec.rb +247 -0
  244. data/spec/unit/mb/provisioner/manager_spec.rb +141 -0
  245. data/spec/unit/mb/provisioner/manifest_spec.rb +182 -0
  246. data/spec/unit/mb/provisioner/provision_data_spec.rb +113 -0
  247. data/spec/unit/mb/provisioner_spec.rb +251 -0
  248. data/spec/unit/mb/provisioners/aws_spec.rb +392 -0
  249. data/spec/unit/mb/provisioners/environment_factory_spec.rb +108 -0
  250. data/spec/unit/mb/rest_gateway_spec.rb +13 -0
  251. data/spec/unit/mb/ridley_ext/cookbook_object_spec.rb +105 -0
  252. data/spec/unit/mb/srv_ctl_spec.rb +142 -0
  253. data/spec/unit/mb/upgrade/manager_spec.rb +37 -0
  254. data/spec/unit/mb/upgrade/worker_spec.rb +219 -0
  255. data/spec/unit/motherbrain_spec.rb +58 -0
  256. data/templates/bootstrap.json +8 -0
  257. data/templates/motherbrain.rb +44 -0
  258. metadata +694 -15
  259. data/Rakefile +0 -1
data/VAGRANT.md ADDED
@@ -0,0 +1,116 @@
1
+
2
+ # Testing motherbrain Bootstrapping with Vagrant
3
+
4
+ One of the things we'd like to do is have a Vagrant or Virtualbox/VMware/etc provisioner, so that you can test provisioning locally. Until this is completed, you can test bootstrapping to a set of Vagrant boxes.
5
+
6
+ ## Setup Vagrant
7
+
8
+ First, make sure you have Vagrant installed by following the directions at [vagrantup.com](http://vagrantup.com). Test that Vagrant is installed correctly with `vagrant -v`:
9
+
10
+ ```
11
+ $ vagrant -v
12
+ Vagrant version 1.2.2
13
+ ```
14
+
15
+ ## Create a Vagrantfile
16
+
17
+ We'll want a Vagrantfile that gives us a box to bootstrap. This file can be anywhere, but it might be best to place it in its own folder, such as `motherbrain-boxes`. Here's the simplest one possible for our needs:
18
+
19
+ ```rb
20
+ Vagrant.configure('2') do |config|
21
+ config.vm.box = "opscode-centos-6.3"
22
+ config.vm.box_url = "https://opscode-vm.s3.amazonaws.com/vagrant/boxes/opscode-centos-6.3.box"
23
+ config.vm.network :private_network, ip: "33.33.33.101"
24
+ end
25
+ ```
26
+
27
+ If you wanted more than one box, you could use Ruby to create multiple boxes:
28
+
29
+ ```rb
30
+ count = 3
31
+
32
+ Vagrant.configure('2') do |config|
33
+ (1..count).each do |number|
34
+ config.vm.define name do |box|
35
+ box.vm.box = "opscode-centos-6.3"
36
+ box.vm.box_url = "https://opscode-vm.s3.amazonaws.com/vagrant/boxes/opscode-centos-6.3.box"
37
+ box.vm.hostname = "box#{number}"
38
+ box.vm.network :private_network, ip: "33.33.33.#{100 + number}"
39
+ end
40
+ end
41
+ end
42
+ ```
43
+
44
+ This will creates 3 boxes (box1, box2, box3) with sequential IP addresses (33.33.33.101, .102, .103).
45
+
46
+ > A more advanced Vagrantfile can be found at [justincampbell/boxen](https://github.com/justincampbell/boxen). This provides support for specifying the numbers of boxes on the command line, and automatically modifies your `/etc/hosts` file with the box hostnames (`33.33.33.101 box1`).
47
+
48
+ ## Start Vagrant boxes
49
+
50
+ Now just run `vagrant up`, and you should see the box being created:
51
+
52
+ ```
53
+ motherbrain-boxes$ vagrant up
54
+ Bringing machine 'default' up with 'virtualbox' provider...
55
+ [default] Importing base box 'opscode-centos-6.3'...
56
+ [default] Matching MAC address for NAT networking...
57
+ [default] Setting the name of the VM...
58
+ [default] Clearing any previously set forwarded ports...
59
+ [default] Creating shared folders metadata...
60
+ [default] Clearing any previously set network interfaces...
61
+ [default] Preparing network interfaces based on configuration...
62
+ [default] Forwarding ports...
63
+ [default] -- 22 => 2222 (adapter 1)
64
+ [default] Booting VM...
65
+ [default] Waiting for VM to boot. This can take a few minutes.
66
+ [default] VM booted and ready for use!
67
+ [default] Configuring and enabling network interfaces...
68
+ [default] Mounting shared folders...
69
+ [default] -- /vagrant
70
+ $
71
+ ```
72
+
73
+ We now have a CentOS 6.3 machine waiting for us at `33.33.33.101`.
74
+
75
+ ## Configure motherbrain
76
+
77
+ Next, we need to tell motherbrain to use the Vagrant SSH user and key. Assuming that we're bootstrapping a node with the "ohai" plugin (a simple cookbook with no dependencies), our bootstrap manifest should look like this:
78
+
79
+ ```json
80
+ {
81
+ "options": {
82
+ "ssh": {
83
+ "user": "vagrant",
84
+ "keys": ["~/.vagrant.d/insecure_private_key"]
85
+ }
86
+ },
87
+ "nodes": [
88
+ {
89
+ "groups": ["ohai::default"],
90
+ "hosts": ["33.33.33.101"]
91
+ }
92
+ ]
93
+ }
94
+ ```
95
+
96
+ The SSH options above will override those in our motherbrain config. Save this file as `vagrant.json`.
97
+
98
+ ## Bootstrapping
99
+
100
+ Now we're ready to bootstrap our node. We'll tell motherbrain to bootstrap our plugin (ohai in this case) with our `vagrant.json` manifest, and a Chef environment of our username with a `-vagrant` suffix:
101
+
102
+ ```
103
+ ohai$ mb ohai bootstrap vagrant.json -e jcampbell-vagrant
104
+ Determining best version of the ohai plugin to use with the jcampbell-vagrant environment. This may take a few seconds...
105
+ No environment named jcampbell-vagrant was found. Finding the latest version of the ohai plugin instead. This may take a few second...
106
+ using ohai (1.1.8)
107
+
108
+ Environment 'jcampbell-vagrant' does not exist, would you like to create it? ["y", "n", "q"] ("y") y
109
+ [bootstrap] searching for environment
110
+ [bootstrap] Locking chef_environment:jcampbell-vagrant
111
+ [bootstrap] performing bootstrap on group(s): ["ohai::default"]
112
+ [bootstrap] Unlocking chef_environment:jcampbell-vagrant
113
+ [bootstrap] Success
114
+ ```
115
+
116
+ That's it! motherbrain added our Vagrant box to Chef, set the run list, and ran `chef-client` on the box.
data/bin/boot ADDED
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+
3
+ mkdir -p /app/keys
4
+
5
+ echo $MB_API_KEY | base64 -d > /app/keys/kallan.pem
6
+ echo $MB_VALIDATOR_KEY | base64 -d > /app/keys/riot-validator.pem
7
+ echo $MB_EDB_KEY | base64 -d > /app/keys/encrypted_data_bag_key
8
+
9
+ exec bundle exec /app/bin/mbsrv -c /app/config.json
data/bin/mb ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ $:.push File.expand_path("../../lib", __FILE__)
3
+ require 'motherbrain'
4
+
5
+ MB::Cli::Runner.new(ARGV).execute!
data/bin/mbsrv ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ $:.push File.expand_path("../../lib", __FILE__)
3
+ require 'motherbrain'
4
+
5
+ MB::SrvCtl.run(ARGV, File.basename(__FILE__))
data/config.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "chef": {
3
+ "api_url": "https://chef.las1.riotgames.com/organizations/danger_zone",
4
+ "api_client": "kallan",
5
+ "api_key": "/app/keys/kallan.pem",
6
+ "validator_client": "riot-validator",
7
+ "validator_path": "/app/keys/riot-validator.pem",
8
+ "encrypted_data_bag_secret_path": "/app/keys/encrypted_data_bag_key"
9
+ },
10
+ "ssh": {
11
+ "user": "root",
12
+ "sudo": true,
13
+ "timeout": 15.0
14
+ },
15
+ "winrm": {
16
+ "user": "motherbrain",
17
+ "password": ""
18
+ },
19
+ "ssl": {
20
+ "verify": false
21
+ },
22
+ "log": {
23
+ "level": "DEBUG"
24
+ },
25
+ "plugin_manager": {
26
+ "eager_loading": false,
27
+ "async_loading": false
28
+ },
29
+ "rest_gateway": {
30
+ "enable": true
31
+ }
32
+ }
@@ -0,0 +1,32 @@
1
+ Feature: allow additional/configurable bootstrap scripts
2
+ As a user of the motherbrain (MB) command line interface (CLI)
3
+ I need a way to specify the bootstrap template to use
4
+ So I can control the way my nodes are created
5
+
6
+ Background:
7
+ Given a valid motherbrain configuration
8
+
9
+ Scenario: default template
10
+ Given a cookbook "awesomed" at version "1.2.3" with a plugin that can bootstrap
11
+ When I bootstrap "awesomed"
12
+ Then the exit status should be 0
13
+
14
+ Scenario: custom template
15
+ Given a cookbook "awesomed" at version "1.2.3" with a plugin that can bootstrap
16
+ And an extra bootstrap template
17
+ When I bootstrap "awesomed" with the "extra" bootstrap template
18
+ Then the exit status should be 0
19
+
20
+ Scenario: named template
21
+ Given a cookbook "awesomed" at version "1.2.3" with a plugin that can bootstrap
22
+ And an installed bootstrap template named "wibble"
23
+ When I bootstrap "awesomed" with the "wibble" bootstrap template
24
+ Then the exit status should be 0
25
+
26
+ Scenario: installing template from file
27
+ When I install a template named "foo" from "foo.erb"
28
+ Then the "foo" template should exist
29
+
30
+ Scenario: installing template from URL
31
+ When I install a template named "bar" from "http://gist.example.com/bar.gist"
32
+ Then the "bar" template should exist
@@ -0,0 +1,57 @@
1
+ Feature: configuring the motherbrain (MB) command line interface (CLI)
2
+ As a user of the motherbrain (MB) command line interface (CLI)
3
+ I need a way to configure my MB CLI based on answers I provide to a set of questions
4
+ So it is quick and easy for me to configure or reconfigure my MB CLI
5
+
6
+ @spawn
7
+ Scenario: generating a new config file
8
+ Given a motherbrain configuration does not exist
9
+ When I run the "configure" command interactively
10
+ And I type "https://api.opscode.com/organizations/vialstudio"
11
+ And I type "reset"
12
+ And I type "/Users/reset/.chef/reset.pem"
13
+ And I type "root"
14
+ And I type "secretpass"
15
+ Then the output should contain:
16
+ """
17
+ Config written to:
18
+ """
19
+ And the exit status should be 0
20
+ And a motherbrain config file should exist and contain:
21
+ | chef.api_url | https://api.opscode.com/organizations/vialstudio |
22
+ | chef.api_client | reset |
23
+ | chef.api_key | /Users/reset/.chef/reset.pem |
24
+ | ssh.user | root |
25
+ | ssh.password | secretpass |
26
+
27
+ @spawn
28
+ Scenario: attempting to generate a new config when one already exists
29
+ Given a valid motherbrain configuration
30
+ When I run the "configure" command interactively
31
+ Then the output should contain:
32
+ """
33
+ A configuration file already exists. Re-run with the --force flag if you wish to overwrite it.
34
+ """
35
+ And the exit status should be the code for error "ConfigExists"
36
+
37
+ @spawn
38
+ Scenario: forcefully generating a config when one already exists
39
+ Given a valid motherbrain configuration
40
+ When I run the "configure" command interactively with:
41
+ | --force |
42
+ And I type "https://api.opscode.com/organizations/vialstudio"
43
+ And I type "reset"
44
+ And I type "/Users/reset/.chef/reset.pem"
45
+ And I type "root"
46
+ And I type "secretpass"
47
+ Then the output should contain:
48
+ """
49
+ Config written to:
50
+ """
51
+ And the exit status should be 0
52
+ And a motherbrain config file should exist and contain:
53
+ | chef.api_url | https://api.opscode.com/organizations/vialstudio |
54
+ | chef.api_client | reset |
55
+ | chef.api_key | /Users/reset/.chef/reset.pem |
56
+ | ssh.user | root |
57
+ | ssh.password | secretpass |
@@ -0,0 +1,22 @@
1
+ Feature: Creating an environment
2
+ As a mb user
3
+ I can create an environment via motherbrain
4
+ So I can manage an environment without using other tools such as knife
5
+
6
+ @chef_server
7
+ Scenario: Create an environment
8
+ Given there is not an environment on the chef server named "test_env"
9
+ When I create an environment named "test_env"
10
+ Then the exit status should be 0
11
+ And there should be an environment "test_env" on the chef server
12
+
13
+ @chef_server
14
+ Scenario: Creating an existing environment
15
+ Given there is an environment on the chef server named "test_env"
16
+ When I create an environment named "test_env"
17
+ Then the output should contain:
18
+ """
19
+ An environment named 'test_env' already exists in the Chef Server.
20
+ """
21
+ And the exit status should be the code for error "EnvironmentExists"
22
+ And there should be an environment "test_env" on the chef server
@@ -0,0 +1,33 @@
1
+ Feature: Destroying an environment
2
+ As a mb user
3
+ I can destroy an environment via motherbrain
4
+ So I can manage an environment without using other tools such as knife
5
+
6
+ Background:
7
+ Given there is an environment on the chef server named "destroy_me"
8
+ And we have AWS credentials
9
+
10
+ @chef_server
11
+ Scenario: Destroying an environment
12
+ When I destroy the environment "destroy_me"
13
+ Then the exit status should be 0
14
+ And there should not be an environment "destroy_me" on the chef server
15
+
16
+ @chef_server
17
+ Scenario: Destroying a locked environment
18
+ Given the environment "destroy_me" is locked
19
+ When I destroy the environment "destroy_me"
20
+ Then the output should contain:
21
+ """
22
+ The environment "destroy_me" is locked. You may use --force to override this safeguard.
23
+ """
24
+ And the exit status should be the code for error "ResourceLocked"
25
+ And there should be an environment "destroy_me" on the chef server
26
+
27
+ @chef_server
28
+ Scenario: Destroying a locked environment with --force
29
+ Given the environment "destroy_me" is locked
30
+ When I destroy the environment "destroy_me" with flags:
31
+ | --force |
32
+ Then the exit status should be 0
33
+ And there should not be an environment "destroy_me" on the chef server
@@ -0,0 +1,29 @@
1
+ Feature: Creating an environment from file
2
+ As a mb user
3
+ I can create an environment via motherbrain from a file
4
+ So I can manage an environment without using other tools such as knife
5
+
6
+ Background:
7
+ Given there is a file from input named "spec/fixtures/test_env.json"
8
+
9
+ @chef_server
10
+ Scenario: Create an environment from file
11
+ Given there is not an environment on the chef server named "test_env"
12
+ When I create an environment from file "spec/fixtures/test_env.json"
13
+ Then the exit status should be 0
14
+ And there should be an environment "test_env" on the chef server
15
+
16
+ @chef_server
17
+ Scenario: Creating an existing environment from file
18
+ Given there is an environment on the chef server named "test_env"
19
+ When I create an environment from file "spec/fixtures/test_env.json"
20
+ Then the output should contain:
21
+ """
22
+ An environment named 'test_env' already exists in the Chef Server.
23
+ """
24
+ And the exit status should be the code for error "EnvironmentExists"
25
+ And there should be an environment "test_env" on the chef server
26
+
27
+
28
+
29
+
@@ -0,0 +1,47 @@
1
+ Feature: Limiting plugin commands to a subset of nodes
2
+ As an end-user of a motherbrain plugin
3
+ I want to be able to limit plugin commands to a subset of matching nodes
4
+ So I can selectively manage my infrastucture.
5
+
6
+ * Can specify one or more hostnames or IP addresses
7
+ * Can specify a range of IPs
8
+ * Maybe can specify a regex for hostname matches
9
+
10
+ Background:
11
+ Given a cookbook "foo" with a plugin command "bar" that affects 3 nodes
12
+
13
+ Scenario: limiting to a single node by full host + domain
14
+ When I run the "foo bar --only node1.example.com" command
15
+ Then the output should contain "Limiting to 1 node(s)"
16
+ And the exit status should be 0
17
+
18
+ Scenario: limiting to a single node by host only
19
+ When I run the "foo bar --only node1" command
20
+ Then the output should contain "Limiting to 1 node(s)"
21
+ And the exit status should be 0
22
+
23
+ Scenario: limiting to a single node by IP
24
+ When I run the "foo bar --only 192.168.1.1" command
25
+ Then the output should contain "Limiting to 1 node(s)"
26
+ And the exit status should be 0
27
+
28
+ Scenario: limiting to a set of nodes by full host + domain
29
+ When I run the "foo bar --only node1.example.com,node2.example.com" command
30
+ Then the output should contain "Limiting to 2 node(s)"
31
+ And the exit status should be 0
32
+
33
+ Scenario: limiting to a set of nodes by host only
34
+ When I run the "foo bar --only node1,node2" command
35
+ Then the output should contain "Limiting to 2 node(s)"
36
+ And the exit status should be 0
37
+
38
+ Scenario: limiting to a set of nodes by IP
39
+ When I run the "foo bar --only 192.168.1.1,192.168.1.2" command
40
+ Then the output should contain "Limiting to 2 node(s)"
41
+ And the exit status should be 0
42
+
43
+ Scenario: limiting to a set of nodes by IP range
44
+ When I run the "foo bar --only 192.168.1.1-2" command
45
+ Then the output should contain "Limiting to 2 node(s)"
46
+ And the exit status should be 0
47
+
@@ -0,0 +1,46 @@
1
+ Feature: listing the plugins available to motherbrain
2
+ As a user of the motherbrain command line interface
3
+ I need a way to list all of the available plugins and versions
4
+ So I can see what plugins and versions of those plugins I have installed
5
+
6
+ Background:
7
+ Given a valid motherbrain configuration
8
+ And I have an empty Berkshelf
9
+ And the Chef Server is empty
10
+
11
+ Scenario: listing all plugins
12
+ Given a cookbook "pvpnet" at version "1.2.3" with a plugin
13
+ And a cookbook "pvpnet" at version "2.3.4" with a plugin
14
+ And a cookbook "league" at version "1.0.0" with a plugin
15
+ When I run the "plugin list" command
16
+ Then the output should contain:
17
+ """
18
+
19
+ ** listing installed plugins...
20
+
21
+ pvpnet: 1.2.3, 2.3.4
22
+ league: 1.0.0
23
+ """
24
+ And the exit status should be 0
25
+
26
+ Scenario: listing plugins when there are no plugins installed
27
+ When I run the "plugin list" command
28
+ Then the output should contain:
29
+ """
30
+ No plugins found in your Berkshelf:
31
+ """
32
+ And the exit status should be 0
33
+
34
+ Scenario: listing remote plugins
35
+ Given a cookbook on the Chef Server "ruby" at version "1.2.3" with a plugin
36
+ And a cookbook on the Chef Server "elixir" at version "2.0.0" with a plugin
37
+ When I run the "plugin list" command with:
38
+ | --remote |
39
+ Then the output should contain:
40
+ """
41
+ ** listing installed and remote plugins...
42
+
43
+ ruby: 1.2.3
44
+ elixir: 2.0.0
45
+ """
46
+ And the exit status should be 0