kitchenplan 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0ab17c34e465430b822955f8d10df1baf0dbe443
4
+ data.tar.gz: f5aeee65e69922c78c576fdc003e86b787dbfb26
5
+ SHA512:
6
+ metadata.gz: 630477b5c771bcee822617d7e34e520244743887e1232e6a99298cd59ba2731757cbafda32b2e9f1feed79e7edfd0dda07ccf5faf959a7db051acf9ff0ed2e94
7
+ data.tar.gz: 328a20e225235a41fe9bef8b10248bc8e70a4cedf50f349028e1efa0dd500ff0e819135658f03cb15dcf00fc841a555c7d28c1fa4729120d08a9ed801b841580
data/LICENSE.txt ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
data/README.md ADDED
@@ -0,0 +1,149 @@
1
+ # Kitchenplan
2
+
3
+ Kitchenplan is a small tool to fully automate the installation and configuration of an OSX workstation (or server for that matter) using Chef. But while doing so manually is not a trivial undertaking, Kitchenplan has abstracted away all the hard parts.
4
+
5
+ ## Important
6
+
7
+ I'm currently working on a brand new way of running Kitchenplan. If you are using Kitchenplan, please use [version2](https://github.com/kitchenplan/kitchenplan/blob/version2/README.md) for now.
8
+
9
+ ## To Do
10
+
11
+ * debug options
12
+ * installing a manual list of recipes
13
+ * --no-chef
14
+ * only update cookbooks if we run with -c
15
+
16
+ ## Using kitchenplan
17
+
18
+ ### Installation
19
+
20
+ First of all, you need to install the kitchenplan gem. It only depends on [thor](http://whatisthor.com), [gabba](https://github.com/hybridgroup/gabba) and [deep_merge](https://github.com/danielsdeleo/deep_merge) so it won't dirty up your brand new and clean install.
21
+
22
+ ```
23
+ gem install kitchenplan
24
+ ```
25
+
26
+ ### Setting up
27
+
28
+ Next up we can start the setup of Kitchenplan. Just run `kitchenplan setup` and you will see the following prompt
29
+
30
+ ```
31
+ _ ___ _ _ _
32
+ | |/ (_) | | | | |
33
+ | ' / _| |_ ___| |__ ___ _ __ _ __ | | __ _ _ __
34
+ | < | | __/ __| '_ \ / _ \ '_ \| '_ \| |/ _` | '_ \
35
+ | . \| | || (__| | | | __/ | | | |_) | | (_| | | | |
36
+ |_|\_\_|\__\___|_| |_|\___|_| |_| .__/|_|\__,_|_| |_|
37
+ | |
38
+ |_|
39
+
40
+ -> Installing XCode CLT
41
+ run sw_vers -productVersion | awk -F "." '{print $2}' from "."
42
+ run touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress from "."
43
+ run softwareupdate -l | grep -B 1 "Developer" | head -n 1 | awk -F"*" '{print $2}' from "."
44
+ run softwareupdate -i -v from "."
45
+
46
+ Do you have a config repository? [y,n] n
47
+ ```
48
+
49
+ If this is you first install using v2.1 of Kitchenplan, your aswer will be no. By doing so Kitchenplan will setup '/opt', create the kitchenplan folder structure, setup a bare configuration and put it all in a local git repository. Put this repository on Github (or any git server) and get to working on the configuration files.
50
+
51
+ ```
52
+ -> Making sure /opt exists and I can write to it
53
+ run sudo mkdir -p /opt from "."
54
+ run sudo chown -R roderik /opt from "."
55
+ -> Creating the config folder structure
56
+ run mkdir -p kitchenplan from "/opt"
57
+ run mkdir -p config from "/opt/kitchenplan"
58
+ run mkdir -p groups from "/opt/kitchenplan/config"
59
+ run mkdir -p people from "/opt/kitchenplan/config"
60
+ -> Creating the template config files
61
+ create /opt/kitchenplan/README.md
62
+ create /opt/kitchenplan/config/default.yml
63
+ create /opt/kitchenplan/config/groups/groupa.yml
64
+ create /opt/kitchenplan/config/groups/groupb.yml
65
+ create /opt/kitchenplan/config/people/roderik.yml
66
+ -> Preparing the Cookbook configuration
67
+ create /opt/kitchenplan/Cheffile
68
+ -> Setting up the git repo
69
+ create /opt/kitchenplan/.gitignore
70
+ run git init -q from "/opt/kitchenplan"
71
+ run git add -A . from "/opt/kitchenplan"
72
+ run git commit -q -m 'Clean installation of the Kitchenplan configs for user roderik' from "/opt/kitchenplan"
73
+ => Now start editing the config files in /opt/kitchenplan/config, push them to a git server and run 'kitchenplan provision'
74
+ ```
75
+
76
+ Now, if you have a config repository, you don't want to start with a bare config but use your version. Answer yes and enter your git repo in the next prompt. It will then fetch your configs.
77
+
78
+ ```
79
+ Do you have a config repository? [y,n] y
80
+ Please enter the clone URL of your git config repository: https://github.com/roderik/kitchenplan-config.git
81
+ -> Making sure /opt exists and I can write to it
82
+ run sudo mkdir -p /opt from "."
83
+ run sudo chown -R roderik /opt from "."
84
+ -> Fetching https://github.com/roderik/kitchenplan-config.git to /opt/kitchenplan.
85
+ run git clone -q https://github.com/roderik/kitchenplan-config.git kitchenplan from "/opt"
86
+ ```
87
+
88
+ ### Editing the config files in /opt/kitchenplan/config
89
+
90
+ The most important file is named after your user in config/people/. In my case a roderik.yml file since my username on my Mac is roderik. When running `kitchenplan setup` will create a YAML file in this folder with your username. You can use your config repository for everyone in your organisation by adding a file per username in the people folder.
91
+
92
+ The final config that will be compiled, will be default.yml + username.yml + the group YAML files defined in username.yml + the group YAML files defined in those groups + the group YAML files defined in default.yml. Everything that is a "list" is appended to each other, single value's are overridden.
93
+
94
+ Now, how you organise your config files is entirely up to you, but this is how I do it. default.yml are the apps that everyone in my company needs. Then I have a group file per department in our company, and sometimes for a specific subset of people in that department.
95
+
96
+ If you want to see [a fully implemented example, please see my config repository](https://github.com/roderik/kitchenplan-config)
97
+
98
+ ### Running the install procedure
99
+
100
+ Running Kitchenplan is as easy as running `kitchenplan provision`
101
+
102
+ ```
103
+ _ ___ _ _ _
104
+ | |/ (_) | | | | |
105
+ | ' / _| |_ ___| |__ ___ _ __ _ __ | | __ _ _ __
106
+ | < | | __/ __| '_ \ / _ \ '_ \| '_ \| |/ _` | '_ \
107
+ | . \| | || (__| | | | __/ | | | |_) | | (_| | | | |
108
+ |_|\_\_|\__\___|_| |_|\___|_| |_| .__/|_|\__,_|_| |_|
109
+ | |
110
+ |_|
111
+
112
+ -> Setting up bundler
113
+ create /opt/kitchenplan/Gemfile
114
+ run mkdir -p vendor/cache from "/opt/kitchenplan"
115
+ run rm -rf vendor/bundle/config from "/opt/kitchenplan"
116
+ run bundle install --quiet --binstubs vendor/bin --path vendor/bundle from "/opt/kitchenplan"
117
+ -> Sending a ping to Google Analytics
118
+ -> Compiling configurations
119
+ run mkdir -p tmp from "/opt/kitchenplan"
120
+ -> Fetch the chef cookbooks
121
+ run vendor/bin/librarian-chef install --clean --quiet --path=vendor/cookbooks from "/opt/kitchenplan"
122
+ run sudo vendor/bin/chef-solo -c tmp/solo.rb -j tmp/kitchenplan-attributes.json -o applications::create_var_chef_cache,homebrewalt::default,nodejs::default,... from "/opt/kitchenplan"
123
+ ```
124
+
125
+ At this point Chef will start installing everything you configured. Depending on your install list, this might take a while.
126
+
127
+
128
+ ## Some blogposts about Kitchenplan
129
+
130
+ * [Setting up my perfect dev environment on OSX 10.9 using Chef / Kitchenplan](http://vanderveer.be/setting-up-my-perfect-dev-environment-on-osx-10-9-using-chef-kitchenplan/)
131
+ * [Presenting Kitchenplan @ vanderveer.be](http://vanderveer.be/blog/2013/04/14/presenting-kitchenplan/)
132
+
133
+ ## Contributing to kitchenplan
134
+
135
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
136
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
137
+ * Fork the project.
138
+ * Start a feature/bugfix branch.
139
+ * Commit and push until you are happy with your contribution.
140
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
141
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
142
+
143
+ ## Copyright
144
+
145
+ Copyright (c) 2014 Roderik van der Veer. See LICENSE.txt for further details.
146
+
147
+ ## Acknowledgements
148
+
149
+ This project is inspired and built by using components and idea's from: Boxen, pivotal_workstation, Opscode cookbooks, and more. Please take any imitation as a the highest form of flattery. If you feel the source or acknowledgements are not sufficient, please let me know how you want it to be resolved.
data/bin/kitchenplan ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'kitchenplan/cli'
4
+
5
+ Kitchenplan::Cli.start(ARGV)
@@ -0,0 +1,227 @@
1
+ require 'thor'
2
+
3
+ module Kitchenplan
4
+ class Cli < Thor
5
+ include Thor::Actions
6
+
7
+ desc 'setup [<GITREPO>] [<TARGET DIRECTORY>]', 'setup Kitchenplan'
8
+ def setup(gitrepo=nil, targetdir='/opt')
9
+ logo
10
+ install_clt
11
+ if gitrepo
12
+ fetch(gitrepo, targetdir)
13
+ else
14
+ has_config = yes?('Do you have a config repository? [y,n]', :green)
15
+ if has_config
16
+ gitrepo = ask('Please enter the clone URL of your git config repository:', :green)
17
+ fetch(gitrepo, targetdir)
18
+ else
19
+ create(targetdir)
20
+ end
21
+ end
22
+ end
23
+
24
+ desc 'provision [<TARGET DIRECTORY>]', 'run Kitchenplan'
25
+ def provision(targetdir='/opt')
26
+ logo
27
+ install_bundler(targetdir)
28
+ send_ping
29
+ recipes = parse_config(targetdir)
30
+ fetch_cookbooks(targetdir)
31
+ run_chef(targetdir, recipes)
32
+ cleanup(targetdir)
33
+ print_notice('Installation complete!')
34
+ end
35
+
36
+ no_commands do
37
+
38
+ def run_chef(targetdir, recipes)
39
+ inside("#{targetdir}/kitchenplan") do
40
+ dorun "sudo vendor/bin/chef-solo -c tmp/solo.rb -j tmp/kitchenplan-attributes.json -o #{recipes.join(',')}"
41
+ end
42
+ end
43
+
44
+ def fetch_cookbooks(targetdir)
45
+ print_step('Fetch the chef cookbooks')
46
+ inside("#{targetdir}/kitchenplan") do
47
+ if File.exists?('vendor/cookbooks')
48
+ dorun 'vendor/bin/librarian-chef update 2>&1 > /dev/null'
49
+ else
50
+ dorun 'vendor/bin/librarian-chef install --clean --quiet --path=vendor/cookbooks'
51
+ end
52
+ end
53
+ end
54
+
55
+ def cleanup(targetdir)
56
+ print_step('Cleanup parsed configuration files')
57
+ inside("#{targetdir}/kitchenplan") do
58
+ dorun('rm -f kitchenplan-attributes.json')
59
+ dorun('rm -f solo.rb')
60
+ end
61
+ end
62
+
63
+ def parse_config(targetdir)
64
+ print_step('Compiling configurations')
65
+ require 'json'
66
+ require 'kitchenplan/config'
67
+ inside("#{targetdir}/kitchenplan") do
68
+ config = Kitchenplan::Config.new
69
+ dorun('mkdir -p tmp')
70
+ File.open('tmp/kitchenplan-attributes.json', 'w') do |out|
71
+ out.write(JSON.pretty_generate(config.config['attributes']))
72
+ end
73
+ File.open('tmp/solo.rb', 'w') do |out|
74
+ out.write("cookbook_path [ \"#{Dir.pwd}/vendor/cookbooks\" ]")
75
+ end
76
+ return config.config['recipes']
77
+ end
78
+ end
79
+
80
+ def send_ping
81
+ print_step('Sending a ping to Google Analytics')
82
+ require 'Gabba'
83
+ Gabba::Gabba.new('UA-46288146-1', 'github.com').event('Kitchenplan', 'Run', ENV['USER'])
84
+ end
85
+
86
+ def fetch(gitrepo, targetdir)
87
+ prepare_folders(targetdir)
88
+ if File.exists?("#{targetdir}/kitchenplan")
89
+ print_step "#{targetdir}/kitchenplan already exists, updating from git."
90
+ inside("#{targetdir}/kitchenplan") do
91
+ dorun('git pull -q')
92
+ end
93
+ else
94
+ print_step "Fetching #{gitrepo} to #{targetdir}/kitchenplan."
95
+ inside("#{targetdir}") do
96
+ dorun("git clone -q #{gitrepo} kitchenplan")
97
+ end
98
+ end
99
+ end
100
+
101
+ def create(targetdir)
102
+ print_failure "#{targetdir}/kitchenplan already exists, please remove it before continuing." if File.exists?("#{targetdir}/kitchenplan")
103
+ prepare_folders(targetdir)
104
+
105
+ print_step('Creating the config folder structure')
106
+ inside(targetdir) do
107
+ dorun('mkdir -p kitchenplan')
108
+ end
109
+ inside("#{targetdir}/kitchenplan") do
110
+ dorun('mkdir -p config')
111
+ end
112
+ inside("#{targetdir}/kitchenplan/config") do
113
+ dorun('mkdir -p groups')
114
+ dorun('mkdir -p people')
115
+ end
116
+
117
+ print_step('Creating the template config files')
118
+ template('README.md.erb', "#{targetdir}/kitchenplan/README.md")
119
+ template('default.yml.erb', "#{targetdir}/kitchenplan/config/default.yml")
120
+ template('groupa.yml.erb', "#{targetdir}/kitchenplan/config/groups/groupa.yml")
121
+ template('groupb.yml.erb', "#{targetdir}/kitchenplan/config/groups/groupb.yml")
122
+ template('user.yml.erb', "#{targetdir}/kitchenplan/config/people/#{ENV['USER']}.yml")
123
+
124
+ print_step('Preparing the Cookbook configuration')
125
+ template('Cheffile.erb', "#{targetdir}/kitchenplan/Cheffile")
126
+
127
+ print_step('Setting up the git repo')
128
+ template('gitignore.erb', "#{targetdir}/kitchenplan/.gitignore")
129
+ inside("#{targetdir}/kitchenplan") do
130
+ dorun('git init -q')
131
+ dorun('git add -A .')
132
+ dorun("git commit -q -m 'Clean installation of the Kitchenplan configs for user #{ENV['USER']}'")
133
+ end
134
+
135
+ print_notice("Now start editing the config files in #{targetdir}/kitchenplan/config, push them to a git server and run 'kitchenplan provision'")
136
+ end
137
+
138
+ def install_bundler(targetdir)
139
+ print_step('Setting up bundler')
140
+ template('Gemfile.erb', "#{targetdir}/kitchenplan/Gemfile")
141
+ inside("#{targetdir}/kitchenplan") do
142
+ dorun('mkdir -p vendor/cache')
143
+ dorun('sudo gem install bundler --no-rdoc --no-ri') unless Kernel.system "gem query --name-matches '^bundler$' --installed > /dev/null 2>&1"
144
+ dorun('rm -rf vendor/bundle/config')
145
+ dorun('bundle install --quiet --binstubs vendor/bin --path vendor/bundle')
146
+ end
147
+ end
148
+
149
+ def install_clt
150
+ print_step('Installing XCode CLT')
151
+ osx_ver = dorun('sw_vers -productVersion | awk -F "." \'{print $2}\'', true).to_i
152
+ if osx_ver >= 9
153
+ dorun('touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress')
154
+ prod = dorun('softwareupdate -l | grep -B 1 "Developer" | head -n 1 | awk -F"*" \'{print $2}\'', true)
155
+ dorun("softwareupdate -i #{prod} -v")
156
+ else
157
+ dmg = nil
158
+ if osx_ver == 7
159
+ dmg = 'http://devimages.apple.com/downloads/xcode/command_line_tools_for_xcode_os_x_lion_april_2013.dmg'
160
+ elsif osx_ver == 8
161
+ dmg = 'http://devimages.apple.com/downloads/xcode/command_line_tools_os_x_mountain_lion_for_xcode_october_2013.dmg'
162
+ else
163
+ print_failure('Install Xcode before continuing: https://developer.apple.com/xcode/') unless File.exists? '/usr/bin/cc'
164
+ end
165
+ dorun("curl \"#{dmg}\" -o \"clitools.dmg\"")
166
+ tmpmount = dorun('/usr/bin/mktemp -d /tmp/clitools.XXXX', true)
167
+ dorun("hdiutil attach \"clitools.dmg\" -mountpoint \"#{tmpmount}\"")
168
+ dorun("installer -pkg \"$(find #{tmpmount} -name '*.mpkg')\" -target /")
169
+ dorun("hdiutil detach \"#{tmpmount}\"")
170
+ dorun("rm -rf \"#{tmpmount}\"")
171
+ dorun("rm \"clitools.dmg\"")
172
+ end
173
+ end
174
+
175
+ def prepare_folders(targetdir)
176
+ print_step("Making sure #{targetdir} exists and I can write to it")
177
+ dorun("sudo mkdir -p #{targetdir}")
178
+ dorun("sudo chown -R #{ENV['USER']} #{targetdir}")
179
+ end
180
+
181
+ def dorun(command, capture=false)
182
+ status = run(command.chomp, :capture => capture)
183
+ if capture
184
+ return status
185
+ end
186
+ unless status
187
+ exit 1
188
+ end
189
+ end
190
+
191
+ def self.source_root
192
+ File.dirname(File.dirname(File.dirname(__FILE__))) + '/templates'
193
+ end
194
+
195
+ def logo
196
+ say ' _ ___ _ _ _ ', :yellow, true
197
+ say ' | |/ (_) | | | | | ', :yellow, true
198
+ say ' | \' / _| |_ ___| |__ ___ _ __ _ __ | | __ _ _ __ ', :yellow, true
199
+ say ' | < | | __/ __| \'_ \ / _ \ \'_ \| \'_ \| |/ _` | \'_ \ ', :yellow, true
200
+ say ' | . \| | || (__| | | | __/ | | | |_) | | (_| | | | |', :yellow, true
201
+ say ' |_|\_\_|\__\___|_| |_|\___|_| |_| .__/|_|\__,_|_| |_|', :yellow, true
202
+ say ' | | ', :yellow, true
203
+ say ' |_| ', :yellow, true
204
+ say ' ', :yellow, true
205
+ end
206
+
207
+ def print_step(description)
208
+ say "-> #{description.chomp}", :green, true
209
+ end
210
+
211
+ def print_notice(command)
212
+ say "=> #{command.chomp}", :blue, true
213
+ end
214
+
215
+ def print_failure(error)
216
+ say "!! FAILED: #{error.chomp}", :red, true
217
+ exit 1
218
+ end
219
+
220
+ def print_warning(warning)
221
+ say "=> WARNING: #{warning.chomp}", :yellow, true
222
+ end
223
+ end
224
+
225
+
226
+ end
227
+ end
@@ -0,0 +1,90 @@
1
+ require 'yaml'
2
+ require 'etc'
3
+ require 'ohai'
4
+ require 'erb'
5
+ require 'deep_merge'
6
+
7
+ module Kitchenplan
8
+
9
+ class Config
10
+
11
+ attr_reader :platform
12
+ attr_reader :default_config
13
+ attr_reader :people_config
14
+ attr_reader :group_configs
15
+
16
+ def initialize
17
+ self.detect_platform
18
+ self.parse_default_config
19
+ self.parse_people_config
20
+ self.parse_group_configs
21
+ end
22
+
23
+ def detect_platform
24
+ ohai = Ohai::System.new
25
+ ohai.require_plugin('os')
26
+ ohai.require_plugin('platform')
27
+ @platform = ohai[:platform_family]
28
+ end
29
+
30
+ def parse_default_config
31
+ default_config_path = 'config/default.yml'
32
+ @default_config = (YAML.load(ERB.new(File.read(default_config_path)).result) if File.exist?(default_config_path)) || {}
33
+ end
34
+
35
+ def parse_people_config
36
+ people_config_path = "config/people/#{Etc.getlogin}.yml"
37
+ @people_config = (YAML.load(ERB.new(File.read(people_config_path)).result) if File.exist?(people_config_path)) || YAML.load(ERB.new(File.read('config/people/roderik.yml')).result)
38
+ end
39
+
40
+ def parse_group_configs(group = (( @default_config['groups'] || [] ) | ( @people_config['groups'] || [] )))
41
+ @group_configs = @group_configs || {}
42
+ defined_groups = group || []
43
+ defined_groups.each do |group|
44
+ self.parse_group_config(group)
45
+ end
46
+ end
47
+
48
+ def parse_group_config(group)
49
+ unless @group_configs[group]
50
+ group_config_path = "config/groups/#{group}.yml"
51
+ @group_configs[group] = (YAML.load(ERB.new(File.read(group_config_path)).result) if File.exist?(group_config_path)) || {}
52
+ defined_groups = @group_configs[group]['groups']
53
+ if defined_groups
54
+ self.parse_group_configs(defined_groups)
55
+ end
56
+ end
57
+ end
58
+
59
+ def config
60
+ config = {}
61
+ config['recipes'] = []
62
+ config['recipes'] |= hash_path(@default_config, 'recipes', 'global') || []
63
+ config['recipes'] |= hash_path(@default_config, 'recipes', @platform) || []
64
+ @group_configs.each do |group_name, group_config|
65
+ config['recipes'] |= hash_path(group_config, 'recipes', 'global') || []
66
+ config['recipes'] |= hash_path(group_config, 'recipes', @platform) || []
67
+ end
68
+ people_recipes = @people_config['recipes'] || {}
69
+ config['recipes'] |= people_recipes['global'] || []
70
+ config['recipes'] |= people_recipes[@platform] || []
71
+ config['attributes'] = {}
72
+ config['attributes'].deep_merge!(@default_config['attributes'] || {}) { |key, old, new| Array.wrap(old) + Array.wrap(new) }
73
+ @group_configs.each do |group_name, group_config|
74
+ config['attributes'].deep_merge!(group_config['attributes']) { |key, old, new| Array.wrap(old) + Array.wrap(new) } unless group_config['attributes'].nil?
75
+ end
76
+ people_attributes = @people_config['attributes'] || {}
77
+ config['attributes'].deep_merge!(people_attributes) { |key, old, new| Array.wrap(old) + Array.wrap(new) }
78
+ config
79
+ end
80
+
81
+ private
82
+
83
+ # Fetches the value at a path in a nested hash or nil if the path is not present.
84
+ def hash_path(hash, *path)
85
+ path.inject(hash) { |hash, key| hash[key] if hash }
86
+ end
87
+
88
+ end
89
+
90
+ end
File without changes
@@ -0,0 +1,11 @@
1
+ site "http://community.opscode.com/api/v1"
2
+
3
+ cookbook "homebrewalt", :github => "kitchenplan/chef-homebrewalt", :ref => "v1.8.1"
4
+ cookbook "nodejs", :github => "kitchenplan/chef-nodejs", :ref => "v1.1"
5
+ cookbook "applications", :github => "kitchenplan/chef-applications", :ref => "v2.0.1"
6
+ cookbook "osxdefaults", :github => "kitchenplan/chef-osxdefaults", :ref => "v1.0.1"
7
+ cookbook "dotfiles", :github => "kitchenplan/chef-dotfiles", :ref => "v1.1"
8
+ cookbook "drivers", :github => "kitchenplan/chef-drivers", :ref => "v1.0"
9
+ cookbook "sudoalt", :github => "kitchenplan/chef-sudoalt", :ref => "v2.4"
10
+ cookbook "dmg", :github => "opscode-cookbooks/dmg", :ref => "v2.1.4"
11
+ cookbook "composer", :github => "kitchenplan/chef-composer", :ref => "v1.0"
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "librarian-chef", "~> 0.0.2"
@@ -0,0 +1,3 @@
1
+ # Kitchenplan Configuration
2
+
3
+ This is a Kitchenplan configuration repository. This repository contains all configuration to install and configure our OSX workstations. More information about Kitchenplan and on how to use it can be found in the [Kitchenplan README](https://github.com/kitchenplan/kitchenplan).
@@ -0,0 +1,15 @@
1
+ recipes: # Configs are parsed and every list is appended to each other, chef handles order and de-duplication
2
+ global: # Recipes mentioned under "global" are installed for all operating systems (we used to support linux, and may do so in the future)
3
+ - applications::create_var_chef_cache
4
+ mac_os_x: # Recipes mentioned under "mac_os_x" are installed on OSX and OSX Server
5
+ - homebrewalt::default # Installs homebrew and homebrew cask and installs all apps mentioned in the homebrewalt:apps and homebrewalt:cask_apps attributes
6
+ - nodejs::default # Installs nodejs and installs all nodejs packages mentioned in the nodejs:apps attribute
7
+ attributes:
8
+ homebrewalt:
9
+ apps:
10
+ - git
11
+ cask_apps:
12
+ - google-chrome
13
+ nodejs:
14
+ apps:
15
+ - bower
@@ -0,0 +1,8 @@
1
+ Gemfile
2
+ /vendor
3
+ kitchenplan-attributes.json
4
+ solo.rb
5
+ Cheffile.lock
6
+ .bundle
7
+ .librarian
8
+ Gemfile.lock
@@ -0,0 +1,11 @@
1
+ groups:
2
+ - groupb
3
+ recipes:
4
+ mac_os_x:
5
+ - osxdefaults::set_terminal_profile
6
+ attributes:
7
+ homebrewalt:
8
+ apps:
9
+ - git-extras
10
+ cask_apps:
11
+ - sourcetree
@@ -0,0 +1,9 @@
1
+ recipes:
2
+ mac_os_x:
3
+ - applications::sublime_text_3
4
+ attributes:
5
+ homebrewalt:
6
+ apps:
7
+ - git-flow
8
+ cask_apps:
9
+ - slack
@@ -0,0 +1,13 @@
1
+ groups:
2
+ - groupa
3
+ recipes:
4
+ mac_os_x:
5
+ - osxdefaults::set_computer_name
6
+ attributes:
7
+ osxdefaults:
8
+ computername: MyComputerName
9
+ homebrewalt:
10
+ apps:
11
+ - git-extras
12
+ cask_apps:
13
+ - sourcetree
metadata ADDED
@@ -0,0 +1,176 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kitchenplan
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Roderik van der Veer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.18.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.18.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: gabba
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: deep_merge
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: shoulda
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rdoc
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '3.12'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '3.12'
83
+ - !ruby/object:Gem::Dependency
84
+ name: bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '1.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '1.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: jeweler
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: 2.0.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 2.0.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Kitchenplan is a small tool to fully automate the installation and configuration
126
+ of an OSX workstation (or server for that matter) using Chef. But while doing so
127
+ manually is not a trivial undertaking, Kitchenplan has abstracted away all the hard
128
+ parts.
129
+ email: roderik@vanderveer.be
130
+ executables:
131
+ - kitchenplan
132
+ extensions: []
133
+ extra_rdoc_files:
134
+ - LICENSE.txt
135
+ - README.md
136
+ files:
137
+ - lib/kitchenplan.rb
138
+ - lib/kitchenplan/cli.rb
139
+ - lib/kitchenplan/config.rb
140
+ - templates/Cheffile.erb
141
+ - templates/Gemfile.erb
142
+ - templates/README.md.erb
143
+ - templates/default.yml.erb
144
+ - templates/gitignore.erb
145
+ - templates/groupa.yml.erb
146
+ - templates/groupb.yml.erb
147
+ - templates/user.yml.erb
148
+ - LICENSE.txt
149
+ - README.md
150
+ - bin/kitchenplan
151
+ homepage: http://github.com/kitchenplan/kitchenplan
152
+ licenses:
153
+ - Apache 2.0
154
+ metadata: {}
155
+ post_install_message:
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - '>='
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - '>='
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubyforge_project:
171
+ rubygems_version: 2.0.3
172
+ signing_key:
173
+ specification_version: 4
174
+ summary: Kitchenplan is a small tool to fully automate the installation and configuration
175
+ of an OSX workstation using chef
176
+ test_files: []