Commit d4af4bf8119660a975c487d70dc1a2483e337967
1 parent
92dd6a9fdb
Update our boxen template with the latest and greatest
Showing 26 changed files with 247 additions and 42 deletions Side-by-side Diff
- Gemfile
- Gemfile.lock
- Puppetfile
- Puppetfile.lock
- docs/personal-configuration.md
- docs/puppet.md
- docs/rails.md
- manifests/site.pp
- script/bootstrap
- script/boxen-my-config
- script/nuke
- vendor/cache/boxen-0.7.1.gem
- vendor/cache/boxen-0.7.3.gem
- vendor/cache/builder-3.1.4.gem
- vendor/cache/json_pure-1.7.6.gem
- vendor/cache/json_pure-1.7.7.gem
- vendor/cache/multi_json-1.5.0.gem
- vendor/cache/multi_json-1.6.0.gem
- vendor/cache/net-ssh-2.6.5.gem
- vendor/cache/octokit-1.22.0.gem
- vendor/cache/octokit-1.23.0.gem
- vendor/cache/rbvmomi-1.6.0.gem
- vendor/cache/trollop-2.0.gem
- vendor/puppet/cache/boxen-puppet-ruby-0.5.1.tar.gz
- vendor/puppet/cache/boxen-puppet-ruby-0.7.1.tar.gz
- vendor/shims/xcrun
Gemfile
Gemfile.lock
1 | 1 | GEM |
2 | - remote: http://rubygems.org/ | |
2 | + remote: https://rubygems.org/ | |
3 | 3 | specs: |
4 | 4 | addressable (2.3.2) |
5 | 5 | ansi (1.4.3) |
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | json (~> 1.4) |
8 | 8 | nokogiri (>= 1.4.4) |
9 | 9 | uuidtools (~> 2.1) |
10 | - boxen (0.7.1) | |
10 | + boxen (0.7.3) | |
11 | 11 | ansi (~> 1.4) |
12 | 12 | hiera (~> 1.0.0) |
13 | 13 | highline (~> 1.6) |
... | ... | @@ -15,6 +15,7 @@ |
15 | 15 | librarian-puppet (~> 0.9) |
16 | 16 | octokit (~> 1.15) |
17 | 17 | puppet (~> 3.0) |
18 | + builder (3.1.4) | |
18 | 19 | facter (1.6.17) |
19 | 20 | faraday (0.8.5) |
20 | 21 | multipart-post (~> 1.1) |
21 | 22 | |
22 | 23 | |
23 | 24 | |
... | ... | @@ -24,16 +25,17 @@ |
24 | 25 | hiera (1.0.0) |
25 | 26 | highline (1.6.15) |
26 | 27 | json (1.7.6) |
27 | - json_pure (1.7.6) | |
28 | + json_pure (1.7.7) | |
28 | 29 | librarian-puppet (0.9.7) |
29 | 30 | json |
30 | 31 | puppet |
31 | 32 | thor (~> 0.15) |
32 | - multi_json (1.5.0) | |
33 | + multi_json (1.6.0) | |
33 | 34 | multipart-post (1.1.5) |
35 | + net-ssh (2.6.5) | |
34 | 36 | netrc (0.7.7) |
35 | 37 | nokogiri (1.5.6) |
36 | - octokit (1.22.0) | |
38 | + octokit (1.23.0) | |
37 | 39 | addressable (~> 2.2) |
38 | 40 | faraday (~> 0.8) |
39 | 41 | faraday_middleware (~> 0.9) |
40 | 42 | |
... | ... | @@ -43,7 +45,12 @@ |
43 | 45 | puppet (3.1.0) |
44 | 46 | facter (~> 1.6) |
45 | 47 | hiera (~> 1.0) |
48 | + rbvmomi (1.6.0) | |
49 | + builder | |
50 | + nokogiri (>= 1.4.1) | |
51 | + trollop | |
46 | 52 | thor (0.17.0) |
53 | + trollop (2.0) | |
47 | 54 | uuidtools (2.1.3) |
48 | 55 | |
49 | 56 | PLATFORMS |
... | ... | @@ -51,5 +58,7 @@ |
51 | 58 | |
52 | 59 | DEPENDENCIES |
53 | 60 | aws-sdk |
54 | - boxen (~> 0.7) | |
61 | + boxen (= 0.7.3) | |
62 | + net-ssh | |
63 | + rbvmomi |
Puppetfile
1 | +# This file manages Puppet module dependencies. | |
2 | +# | |
1 | 3 | # It works a lot like Bundler. We provide some core modules by |
2 | 4 | # default. This ensures at least the ability to construct a basic |
3 | 5 | # environment. |
... | ... | @@ -28,7 +30,7 @@ |
28 | 30 | github "nginx", "0.2.1" |
29 | 31 | github "nodejs", "0.0.2" |
30 | 32 | github "nvm", "0.0.5" |
31 | -github "ruby", "0.5.1" | |
33 | +github "ruby", "0.7.1" | |
32 | 34 | github "stdlib", "3.0.0", :repo => "puppetlabs/puppetlabs-stdlib" |
33 | 35 | github "sudo", "0.0.1" |
34 | 36 |
Puppetfile.lock
... | ... | @@ -46,7 +46,7 @@ |
46 | 46 | GITHUBTARBALL |
47 | 47 | remote: boxen/puppet-ruby |
48 | 48 | specs: |
49 | - ruby (0.5.1) | |
49 | + ruby (0.7.1) | |
50 | 50 | |
51 | 51 | GITHUBTARBALL |
52 | 52 | remote: boxen/puppet-sudo |
... | ... | @@ -74,7 +74,7 @@ |
74 | 74 | nginx (= 0.2.1) |
75 | 75 | nodejs (= 0.0.2) |
76 | 76 | nvm (= 0.0.5) |
77 | - ruby (= 0.5.1) | |
77 | + ruby (= 0.7.1) | |
78 | 78 | stdlib (= 3.0.0) |
79 | 79 | sudo (= 0.0.1) |
docs/personal-configuration.md
... | ... | @@ -7,30 +7,60 @@ |
7 | 7 | |
8 | 8 | How? The personal manifest. |
9 | 9 | |
10 | +## What even is a personal manifest? | |
11 | + | |
10 | 12 | Personal manifests live in `modules/people/manifests/<name>.pp`, |
11 | 13 | where `<name>` is your GitHub username. |
12 | -A basic personal manifest might look like so: | |
13 | 14 | |
15 | +The simplest personal manifest looks like this: | |
16 | + | |
14 | 17 | ``` puppet |
15 | 18 | class people::wfarr { |
16 | 19 | notify { 'hello world': } |
17 | 20 | } |
18 | 21 | ``` |
19 | 22 | |
20 | -Now, each time `wfarr` runs Boxen it'll automatically print out "hello world" | |
21 | -somewhere during the run. | |
22 | -You can even run `boxen-my-config` to generate a default template for you | |
23 | -and open it up in your editor. | |
24 | -When you're done, you can simply run `boxen` and it'll include your changes | |
25 | -in your personal manifest. | |
26 | -**You should always keep your manifest committed and pushed to your repository**. | |
27 | -Otherwise, auto-updates won't work! | |
23 | +Ah, the good old "Hello World". | |
24 | +It's boring, but you can see there's really not much boilerplate involved. | |
25 | +Let's try something *real* this time: | |
28 | 26 | |
29 | -The whole point of these personal manifest are they are _your_ manifest. | |
30 | -You shouldn't worry if the things in here are work-related or not. | |
31 | -This is about full automation. | |
32 | -Want to install Minecraft and Rdio by default? | |
33 | -Do it in your personal manifest. | |
27 | +``` puppet | |
28 | +class people::wfarr { | |
29 | + include boxen::development | |
30 | +} | |
31 | +``` | |
34 | 32 | |
35 | -You can check out the [projects README](../modules/projects/README.md) for further examples. | |
33 | +So what does this do? | |
34 | +It clones every repo in the Boxen org to `~/src/boxen/<repo>`. | |
35 | +How? | |
36 | +Well, we can refer to [the source code](https://github.com/boxen/puppet-boxen/blob/master/manifests/development.pp)! | |
37 | +If you're new to Puppet, or are unsure of what that class is doing, check out | |
38 | +the [intro to puppet](./puppet.md) we've put together. | |
39 | + | |
40 | +## Running different code on multiple machines | |
41 | + | |
42 | +Puppet has conditionals and switching. | |
43 | +Typically, the most reliable way to ensure some code runs on one machine but not | |
44 | +others is to use the `case` statement on the `hostname` fact. | |
45 | +Example: | |
46 | + | |
47 | +``` puppet | |
48 | +case $::hostname { | |
49 | + 'scruffy': { | |
50 | + notify { "I'm Scruffy. The Janitor.": } | |
51 | + } | |
52 | + | |
53 | + 'bender': { | |
54 | + notify { "My full name is Bender Bending Rodriguez": } | |
55 | + } | |
56 | + | |
57 | + default: { | |
58 | + notify { "Wha?": } | |
59 | + } | |
60 | +} | |
61 | +``` | |
62 | + | |
63 | +One thing to note here is that Puppet always **requires** a default path | |
64 | +on a case statement. | |
65 | +Default is equivalent to "anything that isn't matched above". |
docs/puppet.md
1 | +# wtf is a puppet? | |
2 | + | |
3 | +Puppet is configuration management tool, written in Ruby, that compiles | |
4 | +and runs code written in the Puppet language. | |
5 | + | |
6 | +But what does that actually mean in words a human can understand? | |
7 | +Puppet is a tool that runs some code and that code can do all sorts of | |
8 | +really powerful things to configure computers for you. | |
9 | + | |
10 | +Why do I want code mucking about with my laptop though? | |
11 | +For the exact same reasons you want code configuring your server. | |
12 | +In particular, homogeneity, reproducibility, reusability, and automation. | |
13 | +When you use code to express how a machine should be configured, | |
14 | +you know that all of your machines are configured the same way, | |
15 | +that you can repeat that configuration any number of times, | |
16 | +and that you don't have to do it manually each time. | |
17 | + | |
18 | +## How does Puppet work? | |
19 | + | |
20 | +A Puppet run has two main steps: compilation and application. | |
21 | + | |
22 | +The compilations step starts with reading in what's called the site manifest. | |
23 | +The site manifest is a single file that contains Puppet code that is responsible | |
24 | +for telling the compiler what other Puppet code it should compile. | |
25 | + | |
26 | +Here are the first few lines of the default site manifest for Boxen: | |
27 | + | |
28 | +``` | |
29 | +include boxen::environment | |
30 | +include homebrew | |
31 | +include gcc | |
32 | +``` | |
33 | + | |
34 | +This tells the Puppet compiler that it must include the classes | |
35 | +`boxen::environment`, `homebrew`, and `gcc`. | |
36 | +Puppet will look for those classes on the modulepath. | |
37 | +Typically, these files would be located at | |
38 | +`$modulepath/boxen/manifests/environment.pp` and | |
39 | +`$modulepath/homebrew/manifests/init.pp`. | |
40 | + | |
41 | +These might include other classes as well, or define **resources**. | |
42 | +Resources are the building blocks of Puppet. | |
43 | +A resource is an abstract description about a **thing** and the **state** | |
44 | +that thing should be in. | |
45 | +Every resource has a **type**, which is just a classification of resources. | |
46 | +For example, we might have a resource `Package[mysql]` and its type would be | |
47 | +`Package`. | |
48 | +Puppet also supports multiple providers for types which act as pluggable | |
49 | +backends depending on the operating system it's running on or the tools | |
50 | +available on a particular system (in the case of the `Package` type, | |
51 | +we might have providers for `yum` and for `aptget`). | |
52 | + | |
53 | +So now the Puppet compiler has finished tracking down and loading all the | |
54 | +classes and resources it needs. | |
55 | +Assuming we haven't encountered any compile-time errors, Puppet then begins | |
56 | +the next phase of a run: applying the catalog. | |
57 | + | |
58 | +All of the resources Puppet has collected into the catalog have formed a | |
59 | +DAG (directed, acyclic graph) that represents the order in which all these | |
60 | +resources can be applied in a correct order. | |
61 | +Puppet simply grabs the first "node" in this graph and traverses all nodes | |
62 | +in the graph, applying each resource as it goes. | |
63 | + | |
64 | +Application of an individual resource starts with Puppet asking "is this | |
65 | +resource in the state requested?" If the answer is yes, Puppet moves onto the | |
66 | +next node and repeats this process. If the answer is no, Puppet will make | |
67 | +whatever changes it can to reconcile the current state of the resource with | |
68 | +what it should be, and then continues on. | |
69 | + | |
70 | +Once all resources have been applied, the Puppet run is complete. | |
71 | + | |
72 | +## Declarative by nature | |
73 | + | |
74 | +One of the most confusing parts of the Puppet language to many newcomers is | |
75 | +how the Puppet catalog orders and applies resources. | |
76 | +The key thing to remember is that Puppet is a **declarative** language rather | |
77 | +than a procedural one. | |
78 | +In human words, the only order that matters in Puppet is order specified by | |
79 | +relationships between resources. | |
80 | + | |
81 | +Here's an example of how someone new to Puppet might write a class: | |
82 | + | |
83 | +``` puppet | |
84 | +class mysql { | |
85 | + file { '/etc/my.cnf': source => 'puppet:///modules/mysql/my.cnf.erb' ; } | |
86 | + package { 'mysql': } | |
87 | + service { 'mysql': } | |
88 | +} | |
89 | +``` | |
90 | + | |
91 | +Someone expecting Puppet to be procedural would read this manifest as a list | |
92 | +saying: | |
93 | + | |
94 | +* First create the my.cnf file | |
95 | +* Then install the mysql package | |
96 | +* Then start the mysql service | |
97 | + | |
98 | +The problem is, they would be **wrong**. | |
99 | +There is no guarantee Puppet will apply these resources in that order, | |
100 | +and it's quite likely that it won't. | |
101 | + | |
102 | +The proper way to ensure ordering in Puppet is to use one of the four | |
103 | +**relationship metaparameters**: | |
104 | + | |
105 | +* before - Run this resource before another resource | |
106 | +* notify - Same as before, but triggers a refresh on that resource | |
107 | +* require - Run this resource after another resource | |
108 | +* subscribe - Same as require, but triggers a refresh on that resource | |
109 | + | |
110 | +The behavior of these metaparameters should be pretty clear. | |
111 | +Triggering a resource simply means that a resource will "refresh" itself. | |
112 | +That typically means something like a `Service` resource restarting itself. | |
113 | +It's important to remember that these metaparameters are valid on **any** resource. | |
114 | + | |
115 | +So, let's rewrite our example properly: | |
116 | + | |
117 | +``` puppet | |
118 | +class mysql { | |
119 | + file { '/etc/my.cnf': | |
120 | + source => 'puppet:///modules/mysql/my.cnf.erb', | |
121 | + notify => Service['mysql'] | |
122 | + } | |
123 | + | |
124 | + package { 'mysql': | |
125 | + notify => Service['mysql'] | |
126 | + } | |
127 | + | |
128 | + service { 'mysql': } | |
129 | +} | |
130 | +``` | |
131 | + | |
132 | +Now we're telling Puppet what order to apply these resources in: | |
133 | + | |
134 | +* Make sure /etc/my.cnf is in place before we start the mysql service | |
135 | +* If /etc/my.cnf changes, tell mysql to restart | |
136 | +* Make sure the mysql package is in place before we start the mysql service | |
137 | +* If the mysql package changes, tell mysql to restart | |
138 | + | |
139 | +It's important to note that we didn't tell Puppet if `File[/etc/my.cnf]` | |
140 | +should come before or after `Package[mysql]`. | |
141 | +This is intentional. | |
142 | +Most package managers won't overwrite a configuration file that already exists | |
143 | +at package install-time, so in this case, we can assume installing the mysql | |
144 | +package won't clobber our custom `/etc/my.cnf` file. |
docs/rails.md
manifests/site.pp
1 | 1 | require boxen::environment |
2 | -require homebrew::repo | |
2 | +require homebrew | |
3 | +require gcc | |
3 | 4 | |
4 | 5 | Exec { |
5 | 6 | group => 'staff', |
... | ... | @@ -8,6 +9,8 @@ |
8 | 9 | |
9 | 10 | path => [ |
10 | 11 | "${boxen::config::home}/rbenv/shims", |
12 | + "${boxen::config::hime}/rbenv/bin", | |
13 | + "${boxen::config::hime}/rbenv/plugins/ruby-build/bin", | |
11 | 14 | "${boxen::config::home}/homebrew/bin", |
12 | 15 | '/usr/bin', |
13 | 16 | '/bin', |
... | ... | @@ -16,7 +19,7 @@ |
16 | 19 | ], |
17 | 20 | |
18 | 21 | environment => [ |
19 | - "HOMEBREW_CACHE=${homebrew::cachedir}", | |
22 | + "HOMEBREW_CACHE=${homebrew::config::cachedir}", | |
20 | 23 | "HOME=/Users/${::luser}" |
21 | 24 | ] |
22 | 25 | } |
... | ... | @@ -42,6 +45,8 @@ |
42 | 45 | Service { |
43 | 46 | provider => ghlaunchd |
44 | 47 | } |
48 | + | |
49 | +Homebrew::Formula <| |> -> Package <| |> | |
45 | 50 | |
46 | 51 | node default { |
47 | 52 | # core modules, needed for most things |
script/bootstrap
... | ... | @@ -13,11 +13,8 @@ |
13 | 13 | rm -rf .bundle/config |
14 | 14 | rm -rf .librarian/puppet/config |
15 | 15 | |
16 | -# Export CC to explicitly set the compiler used for cexts. | |
17 | - | |
18 | -export CC=gcc | |
19 | - | |
20 | 16 | # Bundle install unless we're already up to date. |
21 | 17 | |
18 | +export PATH=$(pwd)/vendor/shims:$PATH | |
22 | 19 | bundle install --binstubs bin --path .bundle --quiet "$@" |
script/boxen-my-config
script/nuke
... | ... | @@ -14,11 +14,13 @@ |
14 | 14 | OptionParser.new do |o| |
15 | 15 | o.banner = "Remove most traces of Boxen from your machine." |
16 | 16 | |
17 | - o.on("--all", "Remove everything possible.") { all = true } | |
18 | - o.on("--force", "Actually do it.") { force = true } | |
19 | - o.on("--help", "Show this help.") { abort o.to_s } | |
20 | - o.on("--opt", "Remove /opt/boxen.") { opt = true } | |
21 | - o.on("--services", "Remove and unload services.") { services = true } | |
17 | + o.on("--all", "Remove everything possible.") { all = true } | |
18 | + o.on("--force", "Actually do it.") { force = true } | |
19 | + o.on("--help", "Show this help.") { abort o.to_s } | |
20 | + o.on("--opt", "Remove /opt/boxen.") { opt = true } | |
21 | + o.on("--services", "Remove and unload services.") { services = true } | |
22 | + o.on("--receipts", "Remove package receipts used by Puppet.") { receipts = true } | |
23 | + o.on("--gitconfig", "Remove Boxen-provided git credential helper config.") { gitconfig = true } | |
22 | 24 | |
23 | 25 | o.parse! |
24 | 26 | |
... | ... | @@ -31,7 +33,7 @@ |
31 | 33 | |
32 | 34 | if all || services |
33 | 35 | boxen_services = [] |
34 | - boxen_services << Dir["/Library/Launch*/com.boxen.*.plist"] | |
36 | + boxen_services << Dir["/Library/Launch*/dev.*.plist"] | |
35 | 37 | |
36 | 38 | boxen_services.flatten.each do |plist| |
37 | 39 | warn "-> Removing #{plist}." |
... | ... | @@ -48,5 +50,15 @@ |
48 | 50 | if all || opt |
49 | 51 | warn "-> Removing /opt/boxen." |
50 | 52 | system "rm", "-rf", "/opt/boxen" if force |
53 | +end | |
54 | + | |
55 | +if all || receipts | |
56 | + warn "-> Removing /var/db/.puppet_*." | |
57 | + system "rm", "-rf", "/var/db/.puppet_*" if force | |
58 | +end | |
59 | + | |
60 | +if all || gitconfig | |
61 | + warn "-> Removing git credential helper config." | |
62 | + system "/usr/bin/git", "config", "--global", "--unset", "credential.helper" | |
51 | 63 | end |
vendor/cache/boxen-0.7.1.gem
No preview for this file type
vendor/cache/boxen-0.7.3.gem
No preview for this file type
vendor/cache/builder-3.1.4.gem
No preview for this file type
vendor/cache/json_pure-1.7.6.gem
No preview for this file type
vendor/cache/json_pure-1.7.7.gem
No preview for this file type
vendor/cache/multi_json-1.5.0.gem
No preview for this file type
vendor/cache/multi_json-1.6.0.gem
No preview for this file type
vendor/cache/net-ssh-2.6.5.gem
No preview for this file type
vendor/cache/octokit-1.22.0.gem
No preview for this file type
vendor/cache/octokit-1.23.0.gem
No preview for this file type
vendor/cache/rbvmomi-1.6.0.gem
No preview for this file type
vendor/cache/trollop-2.0.gem
No preview for this file type
vendor/puppet/cache/boxen-puppet-ruby-0.5.1.tar.gz
No preview for this file type
vendor/puppet/cache/boxen-puppet-ruby-0.7.1.tar.gz
No preview for this file type
vendor/shims/xcrun