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
@@ -0,0 +1,195 @@
1
+ motherbrain is a tool used to orchestrate clusters of nodes.
2
+
3
+ It does this through plugins provided by cookbooks that are stored on the Chef Server. These plugins define commands that control various services and other configurations on the servers. Plugins are collections of components which contain groups which are collections of nodes.
4
+
5
+ ### Q: What is a plugin?
6
+ A plugin is a part of a cookbook that provides information to motherbrain to give the ability to orchestrate an environment.
7
+
8
+ ### Q: What is a component?
9
+ A component is a part of a plugin that defines details about a service or part of a service that is running as part of the application that the cookbook deploys.
10
+
11
+ ### Q: What is a group?
12
+ A group is how the component identifies the nodes that are part of the component. This is done via the run list of the nodes.
13
+
14
+ ### Q: What is a command?
15
+ A command allows users to perform an action on a group of nodes. An action can be something like changing the state of a service to started or stopped, migrating a database, or clearing an application's cache.
16
+
17
+ Commands can be run on a component level to manipulate *just* that component or a command can exist at the plugin level and executing multiple component commands.
18
+
19
+ ## Basic Usage
20
+
21
+ To find out what commands are available for a given plugin contained inside a particular cookbook, you can get help output:
22
+
23
+ ```
24
+ $ mb pvpnet_core --environment NA_production
25
+ Finding the latest version of the pvpnet_core plugin. This may take a few seconds...
26
+ using pvpnet_core (2.3.189)
27
+
28
+ Commands:
29
+ mb pvpnet_core bootstrap MANIFEST # Bootstrap a manifest of node groups
30
+ mb pvpnet_core broker [COMMAND] # command and control the brokers
31
+ mb pvpnet_core coherence [COMMAND] # command and control the coherence app
32
+ mb pvpnet_core help [COMMAND] # Describe subcommands or one specific subcommand
33
+ mb pvpnet_core nodes # List all nodes grouped by Component and Group
34
+ mb pvpnet_core platform_content [COMMAND] # command and control platform content
35
+ mb pvpnet_core platform_database [COMMAND] # command and control the database
36
+ mb pvpnet_core provision MANIFEST # Create a cluster of nodes and add them to a Chef environment
37
+ mb pvpnet_core tomcat [COMMAND] # comand and control the tomcat app
38
+ mb pvpnet_core upgrade # Upgrade an environment to the specified versions
39
+ ```
40
+
41
+ By calling the cookbook name, few commands and a bunch of components (which may each have their own commands) are displayed.
42
+
43
+ These are basic motherbrain commands not defined by a specific plugin:
44
+
45
+ * mb pvpnet_core bootstrap MANIFEST - takes a MANIFEST (which is a JSON file) that contains information about what a cluster of nodes should look like. This will apply run lists to nodes as defined in the MANIFEST JSON.
46
+ * mb pvpnet_core nodes - takes an environment (via --environment) and returns the nodes that are running components of pvpnet_core.
47
+ * mb pvpnet_core provision MANIFEST - similar to bootstrap, however before performing a bootstrap, it will request new VMs from a cloud provider and then use those new instances to create a cluster of machines.
48
+ * mb pvpnet_core upgrade - this allows users to upgrade the version of the software running on various components that are controlled by the cookbook. Example: `mb pvpnet_core upgrade --components broker:1.2.4 coherence:4.2.3`
49
+
50
+ The rest of the entries above are components. To see what motherbrain knows about a specific component, you can ask mb similar to the above:
51
+
52
+ ```
53
+ $ mb pvpnet_core coherence --environment NA_production
54
+ using pvpnet_core (2.3.189)
55
+
56
+ Commands:
57
+ mb coherence fluff # Execute a fluff on the core coherence servers
58
+ mb coherence fluffcontentcaches # Execute a fluffcontentcaches on the core coherence servers
59
+ mb coherence fluffindexes # Execute a fluffindexes on the core coherence servers
60
+ mb coherence help [COMMAND] # Describe subcommands or one specific subcommand
61
+ mb coherence nodes # List all nodes grouped by Group
62
+ mb coherence start # Execute a start on the core coherence servers
63
+ mb coherence stop # Execute a stop on the core coherence servers
64
+ ```
65
+
66
+ Again there is the motherbrain provided `nodes` command which will provide nodes that are a part of this component.
67
+
68
+ Other than `help`, the rest of commands are generated from the plugin and have a description that describe what each command does and will be unique to each component. For example, here are the tomcat commands:
69
+
70
+ ```
71
+ mb pvpnet_core tomcat --environment NA_production
72
+ using pvpnet_core (2.3.189)
73
+
74
+ Commands:
75
+ mb tomcat help [COMMAND] # Describe subcommands or one specific subcommand
76
+ mb tomcat nodes # List all nodes grouped by Group
77
+ mb tomcat start # Start the pvpnet_core platform
78
+ mb tomcat stop # Stop the pvpnet_core platform
79
+ ```
80
+
81
+ CAVEAT: The mb help output is not displaying the plugin name. This is a quirk of the command line tool framework motherbrain uses under the hood to generate commands.
82
+
83
+ ## motherbrain Flow
84
+
85
+ ### `mb pvpnet_core tomcat nodes --environment NA_production`
86
+
87
+ This fetches the nodes associated with the component `tomcat` in the environment "NA_production"
88
+
89
+ * Gather the run list entries specified by the **groups** defined in the component `tomcat`
90
+ * Do a node search on the chef server using a string compiled from all of the run list entries inside the **groups** (the search is also constrained by the environment specified)
91
+ * Print a list of the nodes that are associated with this component as returned by the search
92
+
93
+ ### `mb pvpnet_core tomcat start --environment NA_production`
94
+
95
+ This runs the start command on the component tomcat
96
+
97
+ * Load the "start" command in the pvpnet_core plugin
98
+ * Based on how the plugin is implemented, perform actions on various **groups** defined on the `tomcat` component
99
+ * Perform attribute modifications and other steps defined in the start action. Most actions are a simple attribute toggle on the environment, for example, a `tomcat` start might look like this:
100
+
101
+ ```ruby
102
+ node_attribute "pvpnet_core.tomcat.service_state", "start"
103
+ ```
104
+
105
+ This sets the attribute service_state attribute (under pvpnet_core.tomcat) to "start", which will cause the next chef-client run on the box to ensure that the service is running because the recipe looks something like this:
106
+
107
+ ```ruby
108
+ service 'tomcat' do
109
+ action node[:pvpnet_core][:tomcat][:service_state]
110
+ end
111
+ ```
112
+
113
+ * After the attributes are all set, kick off a chef-client run on the nodes that match a search for nodes matching the component's groups that the command says to run on. Commands specify groups like this:
114
+
115
+ ```ruby
116
+ command 'start' do
117
+ on("tomcat_servers") do
118
+ service("tomcat").run(:start)
119
+ end
120
+ end
121
+ ```
122
+
123
+ This says, "on the `tomcat` servers, run the action start from the service `tomcat`". In this case, the group `tomcat_servers` is what motherbrain will be searching for when it finds the nodes that need a `chef-client` run started. Remember that a group is defined by the run list entries in the plugin file.
124
+
125
+ * When all of the nodes' `chef-client` runs complete, motherbrain will report success or failure based on those runs.
126
+
127
+ ### `mb pvpnet_core provision provision_manifest.json \`
128
+ ### `--environment my_new_environment`
129
+
130
+ This creates a new environment using a VM provider such as Eucalyptus or AWS and bootstraps the boxes into a new Chef environment after they are available using the environment name provided.
131
+
132
+ * motherbrain reads the provision_manifest.json to figure out what boxes are required for the new environment. The provision_manifest.json looks like this:
133
+
134
+ ```json
135
+ {
136
+ "nodes": [
137
+ {
138
+ "groups": [ "pvpnet_core::feapp", "pvpnet_core::beapp" ],
139
+ "type": "m1.large",
140
+ "count": 2
141
+ },
142
+ {
143
+ "groups": ["pvpnet_core::database"],
144
+ "type": "m1.large",
145
+ "count": 1
146
+ }
147
+ ]
148
+ }
149
+ ```
150
+
151
+ With the Eucalyptus provisioner, this will create 3 new m1.large nodes, install boostrap Chef onto the boxes with the runlists provided by the groups' definitions in the plugin.
152
+
153
+ * Next, a `mb bootstrap` is run on the nodes to install chef and run `chef-client` with the proper run list (see the `mb bootstrap` section)
154
+
155
+ ### `mb bootstrap bootstrap_manifest.json \`
156
+ ###`--environment my_existing_environment`
157
+
158
+ Provided the nodes exist already, a bootstrap is required to get the nodes placed in the correct environment and capable of running `chef-client`. The bootstrap_manifest.json looks like this:
159
+
160
+ ```json
161
+ {
162
+ "nodes": [
163
+ {
164
+ "groups": [
165
+ "platform_database::platform",
166
+ "platform_database::platform_audit",
167
+ "platform_database::platform_csr",
168
+ "platform_database::platform_stats",
169
+ "platform_database::platform_kudos",
170
+ "platform_content::content"
171
+ ],
172
+ "hosts": ["10.11.12.40"]
173
+ },
174
+ {
175
+ "groups": ["coherence::coherence-app"],
176
+ "hosts": ["10.11.12.1", "10.11.12.2", "10.11.12.3"]
177
+ },
178
+ {
179
+ "groups": [
180
+ "tomcat::beapp",
181
+ "tomcat::feapp",
182
+ "tomcat::game_allocation",
183
+ "tomcat::matchmaking",
184
+ "tomcat::csr_services",
185
+ "tomcat::login_queue",
186
+ "tomcat::platform_auth"
187
+ ],
188
+ "hosts": ["10.11.12.50"]
189
+ }
190
+ ]
191
+ }
192
+ ```
193
+
194
+ When the bootstrap command is run, the run lists from the groups in each node section of the json are applied to the hosts in the array in that same section. Chef will be installed if it needs to be installed and then motherbrain will run `chef-client` on all of the nodes.
195
+
data/PLUGINS.md ADDED
@@ -0,0 +1,268 @@
1
+ # Plugin DSL
2
+
3
+ # `component`
4
+
5
+ Components are logical groupings of elements that make up an application.
6
+
7
+ ```ruby
8
+ component "webserver" do
9
+ description "My webserver that serves webs"
10
+ end
11
+ ```
12
+
13
+ ## `description`
14
+
15
+ Provides text to be displayed in the help output generated for the component
16
+
17
+ ```ruby
18
+ component "webserver" do
19
+ description "serves the myface PHP web application"
20
+ end
21
+ ```
22
+
23
+ ## `versioned`
24
+
25
+ Declares that the component is versioned.
26
+
27
+ ```ruby
28
+ component "webserver" do
29
+ versioned
30
+ end
31
+ ```
32
+
33
+ This will default to the 'webserver.version' attribute, seen in recipes as `node[:webserver][:version]`. Declaring this will allow you to use the `mb plugin upgrade` command:
34
+
35
+ ```sh
36
+ mb myface upgrade --components webserver:1.2.3
37
+ ```
38
+
39
+ You can also specify a custom version attribute:
40
+
41
+ ```ruby
42
+ component "webserver" do
43
+ versioned_with "web"
44
+ end
45
+ ```
46
+
47
+ THis would use the attribute 'web', seen in recipes as `node[:web]`.
48
+
49
+ ## `command`
50
+
51
+ Defines a command to be added to the mb cli generated for the plugin.
52
+
53
+ ```ruby
54
+ command "start" do
55
+ description "Start the web server"
56
+ execute do
57
+ on("default") do
58
+ service("apache").run(:start)
59
+ end
60
+ end
61
+ end
62
+ ```
63
+
64
+ ### `description`
65
+
66
+ Provides text to be displayed in the help output generated for the plugin
67
+
68
+ ```ruby
69
+ command "start" do
70
+ description "Start the web server"
71
+ # ...
72
+ end
73
+ ```
74
+
75
+ ### `execute`
76
+
77
+ Execute provides a place to define which actions are to be run during a command's run
78
+
79
+ ```ruby
80
+ command "start" do
81
+ execute do
82
+ on("default") do
83
+ service("server").run(:start)
84
+ end
85
+ end
86
+ end
87
+ ```
88
+
89
+ #### `on`
90
+
91
+ `on` specifies a group to perform the actions contained in the block on. These actions will be performed in parallel. If actions need to be performed in sequence, use multiple `on` blocks.
92
+
93
+ Invocation of actions in `on` blocks follows this syntax: service("service_name").run(:action_name)
94
+
95
+ ```ruby
96
+ command "start" do
97
+ execute do
98
+ on("default") do
99
+ service("server").run(:start)
100
+ end
101
+ end
102
+ end
103
+ ```
104
+
105
+ **`service`**
106
+
107
+ `service` is used to invoke actions in a `command` `on` block. See `on` for more details
108
+
109
+ ```ruby
110
+ on("default") do
111
+ service("server").run(:start)
112
+ end
113
+ ```
114
+
115
+ **`any`**
116
+
117
+ To run a command only on portion of the nodes:
118
+
119
+ ```ruby
120
+ on("default", any: 2) do
121
+ ...
122
+ end
123
+ ```
124
+
125
+ The nodes will be chosen at random.
126
+
127
+ **`max_concurrent`**
128
+
129
+ To run a command on all nodes, but limit how many are running at once:
130
+
131
+ ```ruby
132
+ on("default", max_concurrent: 2) do
133
+ ...
134
+ end
135
+ ```
136
+
137
+ ## `group`
138
+
139
+ Groups allow motherbrain to identify nodes on which `actions` are taken.
140
+
141
+ ```ruby
142
+ component "webserver" do
143
+ description "My webserver that serves webs"
144
+
145
+ group "default" do
146
+ recipe "myface::webserver"
147
+ end
148
+ end
149
+ ```
150
+
151
+ Also supported
152
+
153
+ ```ruby
154
+ group "default" do
155
+ role "webserver"
156
+ end
157
+ ```
158
+ ```ruby
159
+ group "default" do
160
+ attribute "activemq.master", true
161
+ end
162
+ ```
163
+
164
+ ### `recipe`
165
+
166
+ Used in a `group` to identify a server by a recipe entry on its runlist
167
+
168
+ ```ruby
169
+ group "default" do
170
+ recipe "myface::webserver"
171
+ end
172
+ ```
173
+
174
+ ### `role`
175
+
176
+ Used in a `group` to identify a server by a role entry on its runlist
177
+
178
+ ```ruby
179
+ group "default" do
180
+ role "webserver"
181
+ end
182
+ ```
183
+
184
+ ### `attribute`
185
+
186
+ Used in a `group` to identify a server by a node attribute
187
+
188
+ ```ruby
189
+ group "default" do
190
+ attribute "activemq.master", true
191
+ end
192
+ ```
193
+
194
+
195
+
196
+ ## `service`
197
+
198
+ Services are defined to represent the running processes on a given node that make up a component.
199
+
200
+ ```ruby
201
+ component "webserver" do
202
+ # ...
203
+ service "apache" do
204
+ # ...
205
+ end
206
+ end
207
+ ```
208
+
209
+ ### `action`
210
+
211
+ Actions provide a way of interacting with the chef server to change the state of a service. Following the block, `chef-client` will be run on the nodes matched by the `group`.
212
+
213
+ ```ruby
214
+ service "apache" do
215
+ action :start do
216
+ node_attribute 'myface.apache.enable', true
217
+ node_attribute 'myface.apache.start', true
218
+ end
219
+
220
+ action :stop do
221
+ node_attribute 'myface.apache.enable', false
222
+ node_attribute 'myface.apache.start', false
223
+ end
224
+ end
225
+ ```
226
+
227
+ #### `node_attribute`
228
+
229
+ Used in an `action` to specify the value a node attribute should be set to
230
+
231
+ ```ruby
232
+ action :start do
233
+ node_attribute 'myface.apache.enable', true
234
+ node_attribute 'myface.apache.start', true
235
+ end
236
+ ```
237
+
238
+ **`toggle`**
239
+
240
+ To toggle an attribute for just this Chef run:
241
+
242
+ ```ruby
243
+ action :start do
244
+ node_attribute 'myface.apache.restart', true, toggle: true
245
+ end
246
+ ```
247
+
248
+ The attribute will be set to true, and then set back to its original value after the Chef run.
249
+
250
+ # `stack_order`
251
+
252
+ A stack order specifies the order in which a bootstrap or Chef run occurs.
253
+
254
+ ```ruby
255
+ stack_order do
256
+ bootstrap("webserver::default")
257
+ end
258
+ ```
259
+
260
+ ## `bootstrap`
261
+
262
+ Used in a `stack_order` block to specify what `component` and `group` should be bootstrapped during a provision
263
+
264
+ ```ruby
265
+ stack_order do
266
+ bootstrap("webserver::default")
267
+ end
268
+ ```