Commit 3a47d364c85d04b6e6bf7e5917b879c154dafa5b
0 parents
Exists in
master
Remove caches for fast download
Showing 40 changed files with 2126 additions and 0 deletions Inline Diff
- .gitignore
- .ruby-version
- Gemfile
- Gemfile.lock
- LICENSE
- Puppetfile
- Puppetfile.lock
- README.md
- config/basic.rb
- config/boxen.rb
- config/hiera.yaml
- docs/faq.md
- docs/modules.md
- docs/personal-configuration.md
- docs/puppet.md
- docs/rails.md
- hiera/common.yaml.example
- hiera/users/hanjianwei.yaml
- lib/.gitkeep
- manifests/site.pp
- modules/people/README.md
- modules/people/manifests/.gitkeep
- modules/people/manifests/hanjianwei.pp
- modules/people/manifests/hanjianwei/applications.pp
- modules/people/manifests/hanjianwei/config.pp
- modules/people/manifests/hanjianwei/mirrors.pp
- modules/people/manifests/hanjianwei/osx.pp
- modules/people/manifests/hanjianwei/repositories.pp
- modules/projects/README.md
- modules/projects/manifests/.gitkeep
- modules/projects/manifests/all.pp
- modules/projects/templates/shared/nginx.conf.erb
- script/bootstrap
- script/boxen
- script/boxen-bootstrap
- script/boxen-git-credential
- script/boxen-my-config
- script/nuke
- script/sync
- shared/README.md
.gitignore
| File was created | 1 | /.bundle | ||
| 2 | /.librarian | |||
| 3 | /.projects | |||
| 4 | /.snapshot | |||
| 5 | /.tmp | |||
| 6 | /bin | |||
| 7 | /config/local.rb | |||
| 8 | /log | |||
| 9 | /tmp | |||
| 10 | /shared/* | |||
| 11 | !/shared/README.md | |||
| 12 | /vendor/ |
.ruby-version
| File was created | 1 | system |
Gemfile
| File was created | 1 | source "http://mirrors.aliyun.com/rubygems/" | ||
| 2 | ||||
| 3 | gem "boxen", "~> 2.6" | |||
| 4 | gem "hiera", "~> 1.3.3" | |||
| 5 | gem "librarian-puppet", "~> 1.0.2" | |||
| 6 | gem "puppet", "3.6.1" | |||
| 7 | gem "puppet-lint", "0.3.2" | |||
| 8 | gem "puppetlabs_spec_helper", "0.4.1" | |||
| 9 | gem "open4", "~> 1.3.4" | |||
| 10 | gem "rake", "10.3.2" | |||
| 11 | gem "rspec-puppet", "1.0.1" | |||
| 12 | gem "deep_merge", "~> 1.0" | |||
| 13 | ||||
| 14 | group :development do | |||
| 15 | gem "aws-sdk", "~> 1.42" | |||
| 16 | gem "net-ssh" |
Gemfile.lock
| File was created | 1 | GEM | ||
| 2 | remote: https://rubygems.org/ | |||
| 3 | specs: | |||
| 4 | CFPropertyList (2.2.8) | |||
| 5 | addressable (2.3.6) | |||
| 6 | ansi (1.4.3) | |||
| 7 | aws-sdk (1.42.0) | |||
| 8 | json (~> 1.4) | |||
| 9 | nokogiri (>= 1.4.4) | |||
| 10 | boxen (2.6.0) | |||
| 11 | ansi (~> 1.4) | |||
| 12 | hiera (~> 1.0) | |||
| 13 | highline (~> 1.6) | |||
| 14 | json_pure (>= 1.7.7, < 2.0) | |||
| 15 | librarian-puppet (~> 1.0.0) | |||
| 16 | octokit (~> 2.7, >= 2.7.1) | |||
| 17 | puppet (~> 3.0) | |||
| 18 | builder (3.2.2) | |||
| 19 | deep_merge (1.0.1) | |||
| 20 | diff-lcs (1.2.5) | |||
| 21 | facter (2.0.1) | |||
| 22 | CFPropertyList (~> 2.2.6) | |||
| 23 | faraday (0.9.0) | |||
| 24 | multipart-post (>= 1.2, < 3) | |||
| 25 | hiera (1.3.3) | |||
| 26 | json_pure | |||
| 27 | highline (1.6.21) | |||
| 28 | json (1.8.1) | |||
| 29 | json_pure (1.8.1) | |||
| 30 | librarian (0.1.2) | |||
| 31 | highline | |||
| 32 | thor (~> 0.15) | |||
| 33 | librarian-puppet (1.0.2) | |||
| 34 | json | |||
| 35 | librarian (>= 0.1.2) | |||
| 36 | metaclass (0.0.4) | |||
| 37 | mini_portile (0.6.0) | |||
| 38 | mocha (1.1.0) | |||
| 39 | metaclass (~> 0.0.1) | |||
| 40 | multipart-post (2.0.0) | |||
| 41 | net-ssh (2.9.1) | |||
| 42 | nokogiri (1.6.2.1) | |||
| 43 | mini_portile (= 0.6.0) | |||
| 44 | octokit (2.7.2) | |||
| 45 | sawyer (~> 0.5.2) | |||
| 46 | open4 (1.3.4) | |||
| 47 | puppet (3.6.1) | |||
| 48 | facter (> 1.6, < 3) | |||
| 49 | hiera (~> 1.0) | |||
| 50 | json_pure | |||
| 51 | rgen (~> 0.6.5) | |||
| 52 | puppet-lint (0.3.2) | |||
| 53 | puppetlabs_spec_helper (0.4.1) | |||
| 54 | mocha (>= 0.10.5) | |||
| 55 | rake | |||
| 56 | rspec (>= 2.9.0) | |||
| 57 | rspec-puppet (>= 0.1.1) | |||
| 58 | rake (10.3.2) | |||
| 59 | rbvmomi (1.8.1) | |||
| 60 | builder | |||
| 61 | nokogiri (>= 1.4.1) | |||
| 62 | trollop | |||
| 63 | rgen (0.6.6) | |||
| 64 | rspec (3.0.0) | |||
| 65 | rspec-core (~> 3.0.0) | |||
| 66 | rspec-expectations (~> 3.0.0) | |||
| 67 | rspec-mocks (~> 3.0.0) | |||
| 68 | rspec-core (3.0.0) | |||
| 69 | rspec-support (~> 3.0.0) | |||
| 70 | rspec-expectations (3.0.0) | |||
| 71 | diff-lcs (>= 1.2.0, < 2.0) | |||
| 72 | rspec-support (~> 3.0.0) | |||
| 73 | rspec-mocks (3.0.0) | |||
| 74 | rspec-support (~> 3.0.0) | |||
| 75 | rspec-puppet (1.0.1) | |||
| 76 | rspec | |||
| 77 | rspec-support (3.0.0) | |||
| 78 | sawyer (0.5.4) | |||
| 79 | addressable (~> 2.3.5) | |||
| 80 | faraday (~> 0.8, < 0.10) | |||
| 81 | thor (0.19.1) | |||
| 82 | trollop (2.0) | |||
| 83 | ||||
| 84 | PLATFORMS | |||
| 85 | ruby | |||
| 86 | ||||
| 87 | DEPENDENCIES | |||
| 88 | aws-sdk (~> 1.42) | |||
| 89 | boxen (~> 2.6) | |||
| 90 | deep_merge (~> 1.0) | |||
| 91 | hiera (~> 1.3.3) | |||
| 92 | librarian-puppet (~> 1.0.2) | |||
| 93 | net-ssh | |||
| 94 | open4 (~> 1.3.4) | |||
| 95 | puppet (= 3.6.1) | |||
| 96 | puppet-lint (= 0.3.2) | |||
| 97 | puppetlabs_spec_helper (= 0.4.1) | |||
| 98 | rake (= 10.3.2) |
LICENSE
| File was created | 1 | Copyright (c) 2012 GitHub, Inc. | ||
| 2 | ||||
| 3 | Permission is hereby granted, free of charge, to any person obtaining | |||
| 4 | a copy of this software and associated documentation files (the | |||
| 5 | "Software"), to deal in the Software without restriction, including | |||
| 6 | without limitation the rights to use, copy, modify, merge, publish, | |||
| 7 | distribute, sublicense, and/or sell copies of the Software, and to | |||
| 8 | permit persons to whom the Software is furnished to do so, subject to | |||
| 9 | the following conditions: | |||
| 10 | ||||
| 11 | The above copyright notice and this permission notice shall be | |||
| 12 | included in all copies or substantial portions of the Software. | |||
| 13 | ||||
| 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |||
| 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |||
| 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |||
| 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
Puppetfile
| File was created | 1 | # This file manages Puppet module dependencies. | ||
| 2 | # | |||
| 3 | # It works a lot like Bundler. We provide some core modules by | |||
| 4 | # default. This ensures at least the ability to construct a basic | |||
| 5 | # environment. | |||
| 6 | ||||
| 7 | # Shortcut for a module from GitHub's boxen organization | |||
| 8 | def github(name, *args) | |||
| 9 | options ||= if args.last.is_a? Hash | |||
| 10 | args.last | |||
| 11 | else | |||
| 12 | {} | |||
| 13 | end | |||
| 14 | ||||
| 15 | if path = options.delete(:path) | |||
| 16 | mod name, :path => path | |||
| 17 | else | |||
| 18 | version = args.first | |||
| 19 | options[:repo] ||= "boxen/puppet-#{name}" | |||
| 20 | mod name, version, :github_tarball => options[:repo] | |||
| 21 | end | |||
| 22 | end | |||
| 23 | ||||
| 24 | # Shortcut for a module under development | |||
| 25 | def dev(name, *args) | |||
| 26 | mod name, :path => "#{ENV['HOME']}/src/boxen/puppet-#{name}" | |||
| 27 | end | |||
| 28 | ||||
| 29 | # Includes many of our custom types and providers, as well as global | |||
| 30 | # config. Required. | |||
| 31 | ||||
| 32 | github "boxen", "3.6.1" | |||
| 33 | ||||
| 34 | # Support for default hiera data in modules | |||
| 35 | ||||
| 36 | github "module-data", "0.0.3", :repo => "ripienaar/puppet-module-data" | |||
| 37 | ||||
| 38 | # Core modules for a basic development environment. You can replace | |||
| 39 | # some/most of these if you want, but it's not recommended. | |||
| 40 | ||||
| 41 | github "dnsmasq", "1.0.1" | |||
| 42 | github "gcc", "2.0.101" | |||
| 43 | github "git", "2.4.0" | |||
| 44 | github "homebrew", "1.9.4.rc", :repo => "hanjianwei/puppet-homebrew" | |||
| 45 | github "hub", "1.3.0" | |||
| 46 | github "inifile", "1.0.3", :repo => "puppetlabs/puppetlabs-inifile" | |||
| 47 | github "nginx", "1.4.3" | |||
| 48 | github "nodejs", "3.7.0" | |||
| 49 | github "openssl", "1.0.0" | |||
| 50 | github "pkgconfig", "1.0.0" | |||
| 51 | github "repository", "2.3.0" |
Puppetfile.lock
| File was created | 1 | GITHUBTARBALL | ||
| 2 | remote: boxen/puppet-boxen | |||
| 3 | specs: | |||
| 4 | boxen (3.6.1) | |||
| 5 | ||||
| 6 | GITHUBTARBALL | |||
| 7 | remote: boxen/puppet-dnsmasq | |||
| 8 | specs: | |||
| 9 | dnsmasq (1.0.1) | |||
| 10 | ||||
| 11 | GITHUBTARBALL | |||
| 12 | remote: boxen/puppet-gcc | |||
| 13 | specs: | |||
| 14 | gcc (2.0.101) | |||
| 15 | ||||
| 16 | GITHUBTARBALL | |||
| 17 | remote: boxen/puppet-git | |||
| 18 | specs: | |||
| 19 | git (2.4.0) | |||
| 20 | ||||
| 21 | GITHUBTARBALL | |||
| 22 | remote: boxen/puppet-hub | |||
| 23 | specs: | |||
| 24 | hub (1.3.0) | |||
| 25 | ||||
| 26 | GITHUBTARBALL | |||
| 27 | remote: boxen/puppet-nginx | |||
| 28 | specs: | |||
| 29 | nginx (1.4.3) | |||
| 30 | ||||
| 31 | GITHUBTARBALL | |||
| 32 | remote: boxen/puppet-nodejs | |||
| 33 | specs: | |||
| 34 | nodejs (3.7.0) | |||
| 35 | ||||
| 36 | GITHUBTARBALL | |||
| 37 | remote: boxen/puppet-openssl | |||
| 38 | specs: | |||
| 39 | openssl (1.0.0) | |||
| 40 | ||||
| 41 | GITHUBTARBALL | |||
| 42 | remote: boxen/puppet-osx | |||
| 43 | specs: | |||
| 44 | osx (2.7.0) | |||
| 45 | ||||
| 46 | GITHUBTARBALL | |||
| 47 | remote: boxen/puppet-pkgconfig | |||
| 48 | specs: | |||
| 49 | pkgconfig (1.0.0) | |||
| 50 | ||||
| 51 | GITHUBTARBALL | |||
| 52 | remote: boxen/puppet-repository | |||
| 53 | specs: | |||
| 54 | repository (2.3.0) | |||
| 55 | ||||
| 56 | GITHUBTARBALL | |||
| 57 | remote: boxen/puppet-ruby | |||
| 58 | specs: | |||
| 59 | ruby (8.0.4) | |||
| 60 | ||||
| 61 | GITHUBTARBALL | |||
| 62 | remote: boxen/puppet-sudo | |||
| 63 | specs: | |||
| 64 | sudo (1.0.0) | |||
| 65 | ||||
| 66 | GITHUBTARBALL | |||
| 67 | remote: boxen/puppet-xquartz | |||
| 68 | specs: | |||
| 69 | xquartz (1.1.1) | |||
| 70 | ||||
| 71 | GITHUBTARBALL | |||
| 72 | remote: glarizza/puppet-property_list_key | |||
| 73 | specs: | |||
| 74 | property_list_key (0.2.1) | |||
| 75 | ||||
| 76 | GITHUBTARBALL | |||
| 77 | remote: hanjianwei/puppet-brewcask | |||
| 78 | specs: | |||
| 79 | brewcask (0.0.4.rc2) | |||
| 80 | ||||
| 81 | GITHUBTARBALL | |||
| 82 | remote: hanjianwei/puppet-homebrew | |||
| 83 | specs: | |||
| 84 | homebrew (1.9.4.rc) | |||
| 85 | ||||
| 86 | GITHUBTARBALL | |||
| 87 | remote: puppetlabs/puppetlabs-inifile | |||
| 88 | specs: | |||
| 89 | inifile (1.0.3) | |||
| 90 | ||||
| 91 | GITHUBTARBALL | |||
| 92 | remote: puppetlabs/puppetlabs-stdlib | |||
| 93 | specs: | |||
| 94 | stdlib (4.2.1) | |||
| 95 | ||||
| 96 | GITHUBTARBALL | |||
| 97 | remote: ripienaar/puppet-module-data | |||
| 98 | specs: | |||
| 99 | module-data (0.0.3) | |||
| 100 | ||||
| 101 | DEPENDENCIES |
README.md
| File was created | 1 | # Our Boxen | ||
| 2 | ||||
| 3 | This is a template Boxen project designed for your organization to fork and | |||
| 4 | modify appropriately. | |||
| 5 | The Boxen rubygem and the Boxen puppet modules are only a framework for getting | |||
| 6 | things done. | |||
| 7 | This repository template is just a basic example of _how_ to do things with them. | |||
| 8 | ||||
| 9 | ## Getting Started | |||
| 10 | ||||
| 11 | To give you a brief overview, we're going to: | |||
| 12 | ||||
| 13 | * Install dependencies (basically Xcode) | |||
| 14 | * Bootstrap a boxen for your self/team/org/company | |||
| 15 | * Then convert your local copy of that boxen to the post-bootstrapped version | |||
| 16 | ||||
| 17 | There are a few potential conflicts to keep in mind. | |||
| 18 | Boxen does its best not to get in the way of a dirty system, | |||
| 19 | but you should check into the following before attempting to install your | |||
| 20 | boxen on any machine (we do some checks before every Boxen run to try | |||
| 21 | and detect most of these and tell you anyway): | |||
| 22 | ||||
| 23 | * Boxen __requires__ at least the Xcode Command Line Tools installed. | |||
| 24 | * Boxen __will not__ work with an existing rvm install. | |||
| 25 | * Boxen __may not__ play nice with a GitHub username that includes dash(-) | |||
| 26 | * Boxen __may not__ play nice with an existing rbenv install. | |||
| 27 | * Boxen __may not__ play nice with an existing chruby install. | |||
| 28 | * Boxen __may not__ play nice with an existing homebrew install. | |||
| 29 | * Boxen __may not__ play nice with an existing nvm install. | |||
| 30 | * Boxen __recommends__ installing the full Xcode. | |||
| 31 | ||||
| 32 | ### Dependencies | |||
| 33 | ||||
| 34 | **Install the Xcode Command Lines Tools and/or full Xcode.** | |||
| 35 | This will grant you the most predictable behavior in building apps like | |||
| 36 | MacVim. | |||
| 37 | ||||
| 38 | How do you do it? | |||
| 39 | ||||
| 40 | #### OS X 10.9 (Mavericks) | |||
| 41 | ||||
| 42 | If you are using [`b26abd0` of boxen-web](https://github.com/boxen/boxen-web/commit/b26abd0d681129eba0b5f46ed43110d873d8fdc2) | |||
| 43 | or newer, it will be automatically installed as part of Boxen. | |||
| 44 | Otherwise, follow instructions below. | |||
| 45 | ||||
| 46 | #### OS X < 10.9 | |||
| 47 | ||||
| 48 | 1. Install Xcode from the Mac App Store. | |||
| 49 | 1. Open Xcode. | |||
| 50 | 1. Open the Preferences window (`Cmd-,`). | |||
| 51 | 1. Go to the Downloads tab. | |||
| 52 | 1. Install the Command Line Tools. | |||
| 53 | ||||
| 54 | ### Bootstrapping | |||
| 55 | ||||
| 56 | Create a **new** git repository somewhere on the internet. | |||
| 57 | It can be private or public -- it really doesn't matter. | |||
| 58 | If you're making a repository on GitHub, you _may not_ want to fork this repo | |||
| 59 | to get started. | |||
| 60 | The reason for that is that you can't really make private forks of public | |||
| 61 | repositories easily. | |||
| 62 | ||||
| 63 | Once you've done that, you can run the following to bootstrap | |||
| 64 | your boxen: | |||
| 65 | ||||
| 66 | ``` | |||
| 67 | sudo mkdir -p /opt/boxen | |||
| 68 | sudo chown ${USER}:staff /opt/boxen | |||
| 69 | git clone https://github.com/boxen/our-boxen /opt/boxen/repo | |||
| 70 | cd /opt/boxen/repo | |||
| 71 | git remote rm origin | |||
| 72 | git remote add origin <the location of my new git repository> | |||
| 73 | git push -u origin master | |||
| 74 | ``` | |||
| 75 | ||||
| 76 | Now that your boxen is bootstrapped, you can run the following to | |||
| 77 | install the default configuration from this repo: | |||
| 78 | ||||
| 79 | ``` | |||
| 80 | cd /opt/boxen/repo | |||
| 81 | ./script/boxen | |||
| 82 | ``` | |||
| 83 | ||||
| 84 | ### Distributing | |||
| 85 | ||||
| 86 | That's enough to get your boxen into a usable state on other machines, | |||
| 87 | usually. | |||
| 88 | From there, we recommend setting up | |||
| 89 | [boxen-web](https://github.com/boxen/boxen-web) | |||
| 90 | as an easy way to automate letting other folks install your boxen. | |||
| 91 | ||||
| 92 | If you _don't_ want to use boxen-web, folks can get using your boxen like so: | |||
| 93 | ||||
| 94 | ``` | |||
| 95 | sudo mkdir -p /opt/boxen | |||
| 96 | sudo chown ${USER}:staff /opt/boxen | |||
| 97 | git clone <location of my new git repository> /opt/boxen/repo | |||
| 98 | cd /opt/boxen/repo | |||
| 99 | ./script/boxen | |||
| 100 | ``` | |||
| 101 | ||||
| 102 | Keep in mind this requires you to encrypt your hard drive by default. | |||
| 103 | If you do not want to do encrypt your hard drive, you can use the `--no-fde`. | |||
| 104 | ||||
| 105 | ``` | |||
| 106 | ./script/boxen --no-fde | |||
| 107 | ``` | |||
| 108 | ||||
| 109 | It should run successfully, and should tell you to source a shell script | |||
| 110 | in your environment. | |||
| 111 | For users without a bash or zsh config or a `~/.profile` file, | |||
| 112 | Boxen will create a shim for you that will work correctly. | |||
| 113 | If you do have a `~/.bashrc` or `~/.zshrc`, your shell will not use | |||
| 114 | `~/.profile` so you'll need to add a line like so at _the end of your config_: | |||
| 115 | ||||
| 116 | ``` sh | |||
| 117 | [ -f /opt/boxen/env.sh ] && source /opt/boxen/env.sh | |||
| 118 | ``` | |||
| 119 | ||||
| 120 | Once your shell is ready, open a new tab/window in your Terminal | |||
| 121 | and you should be able to successfully run `boxen --env`. | |||
| 122 | If that runs cleanly, you're in good shape. | |||
| 123 | ||||
| 124 | ## What You Get | |||
| 125 | ||||
| 126 | This template project provides the following by default: | |||
| 127 | ||||
| 128 | * Homebrew | |||
| 129 | * Git | |||
| 130 | * Hub | |||
| 131 | * dnsmasq w/ .dev resolver for localhost | |||
| 132 | * rbenv | |||
| 133 | * Full Disk Encryption requirement | |||
| 134 | * Node.js 0.6 | |||
| 135 | * Node.js 0.8 | |||
| 136 | * Node.js 0.10 | |||
| 137 | * Ruby 1.9.3 | |||
| 138 | * Ruby 2.0.0 | |||
| 139 | * Ruby 2.1.0 | |||
| 140 | * Ruby 2.1.1 | |||
| 141 | * ack | |||
| 142 | * Findutils | |||
| 143 | * GNU tar | |||
| 144 | ||||
| 145 | ## Customizing | |||
| 146 | ||||
| 147 | You can always check out the number of existing modules we already | |||
| 148 | provide as optional installs under the | |||
| 149 | [boxen organization](https://github.com/boxen). These modules are all | |||
| 150 | tested to be compatible with Boxen. Use the `Puppetfile` to pull them | |||
| 151 | in dependencies automatically whenever `boxen` is run. | |||
| 152 | ||||
| 153 | ### Including boxen modules from github (boxen/puppet-<name>) | |||
| 154 | ||||
| 155 | You must add the github information for your added Puppet module into your Puppetfile at the root of your | |||
| 156 | boxen repo (ex. /path/to/your-boxen/Puppetfile): | |||
| 157 | ||||
| 158 | # Core modules for a basic development environment. You can replace | |||
| 159 | # some/most of these if you want, but it's not recommended. | |||
| 160 | ||||
| 161 | github "repository", "2.0.2" | |||
| 162 | github "dnsmasq", "1.0.0" | |||
| 163 | github "gcc", "1.0.0" | |||
| 164 | github "git", "1.2.2" | |||
| 165 | github "homebrew", "1.1.2" | |||
| 166 | github "hub", "1.0.0" | |||
| 167 | github "inifile", "0.9.0", :repo => "cprice404/puppetlabs-inifile" | |||
| 168 | github "nginx", "1.4.0" | |||
| 169 | github "nodejs", "2.2.0" | |||
| 170 | github "ruby", "4.1.0" | |||
| 171 | github "stdlib", "4.0.2", :repo => "puppetlabs/puppetlabs-stdlib" | |||
| 172 | github "sudo", "1.0.0" | |||
| 173 | ||||
| 174 | # Optional/custom modules. There are tons available at | |||
| 175 | # https://github.com/boxen. | |||
| 176 | ||||
| 177 | github "java", "1.1.0" | |||
| 178 | ||||
| 179 | In the above snippet of a customized Puppetfile, the bottom line | |||
| 180 | includes the Java module from Github using the tag "1.1.0" from the github repository | |||
| 181 | "boxen/puppet-java". The function "github" is defined at the top of the Puppetfile | |||
| 182 | and takes the name of the module, the version, and optional repo location: | |||
| 183 | ||||
| 184 | def github(name, version, options = nil) | |||
| 185 | options ||= {} | |||
| 186 | options[:repo] ||= "boxen/puppet-#{name}" | |||
| 187 | mod name, version, :github_tarball => options[:repo] | |||
| 188 | end | |||
| 189 | ||||
| 190 | Now Puppet knows where to download the module from when you include it in your site.pp or mypersonal.pp file: | |||
| 191 | ||||
| 192 | # include the java module referenced in my Puppetfile with the line | |||
| 193 | # github "java", "1.1.0" | |||
| 194 | include java | |||
| 195 | ||||
| 196 | ### Hiera | |||
| 197 | ||||
| 198 | Hiera is preferred mechanism to make changes to module defaults (e.g. default | |||
| 199 | global ruby version, service ports, etc). This repository supplies a | |||
| 200 | starting point for your Hiera configuration at `config/hiera.yml`, and an | |||
| 201 | example data file at `hiera/common.yaml`. See those files for more details. | |||
| 202 | ||||
| 203 | The default `config/hiera.yml` is configured with a hierarchy that allows | |||
| 204 | individuals to have their own hiera data file in | |||
| 205 | `hiera/users/{github_login}.yaml` which augments and overrides | |||
| 206 | site-wide values in `hiera/common.yaml`. This default is, as with most of the | |||
| 207 | configuration in the example repo, a great starting point for many | |||
| 208 | organisations, but is totally up to you. You might want to, for | |||
| 209 | example, have a set of values that can't be overridden by adding a file to | |||
| 210 | the top of the hierarchy, or to have values set on specific OS | |||
| 211 | versions: | |||
| 212 | ||||
| 213 | ```yaml | |||
| 214 | # ... | |||
| 215 | :hierarchy: | |||
| 216 | - "global-overrides.yaml" | |||
| 217 | - "users/%{::github_login}" | |||
| 218 | - "osx-%{::macosx_productversion_major}" | |||
| 219 | - common | |||
| 220 | ``` | |||
| 221 | ||||
| 222 | ### Node definitions | |||
| 223 | ||||
| 224 | Puppet has the concept of a | |||
| 225 | ['node'](http://docs.puppetlabs.com/references/glossary.html#agent), | |||
| 226 | which is essentially the machine on which Puppet is running. Puppet looks for | |||
| 227 | [node definitions](http://docs.puppetlabs.com/learning/agent_master_basic.html#node-definitions) | |||
| 228 | in the `manifests/site.pp` file in the Boxen repo. You'll see a default node | |||
| 229 | declaration that looks like the following: | |||
| 230 | ||||
| 231 | ``` puppet | |||
| 232 | node default { | |||
| 233 | # core modules, needed for most things | |||
| 234 | include dnsmasq | |||
| 235 | ||||
| 236 | # more... | |||
| 237 | } | |||
| 238 | ``` | |||
| 239 | ||||
| 240 | ### How Boxen interacts with Puppet | |||
| 241 | ||||
| 242 | Boxen runs everything declared in `manifests/site.pp` by default. | |||
| 243 | But just like any other source code, throwing all your work into one massive | |||
| 244 | file is going to be difficult to work with. Instead, we recommend you | |||
| 245 | use modules in the `Puppetfile` when you can and make new modules |
config/basic.rb
| File was created | 1 | # Set up the execution environment. Load this file before trying to do | ||
| 2 | # anything else. This file assumes that the repo's been bootstrapped. | |||
| 3 | ||||
| 4 | require "pathname" | |||
| 5 | ||||
| 6 | # Make sure we're in the repo's root directory. | |||
| 7 | ||||
| 8 | Dir.chdir Pathname.new(__FILE__).realpath + "../.." | |||
| 9 | ||||
| 10 | # Load custom config. | |||
| 11 | ||||
| 12 | load File.expand_path "../boxen.rb", __FILE__ | |||
| 13 | ||||
| 14 | # Load local config if it exists. This file is ignored by Git, and can | |||
| 15 | # be used for personal config. | |||
| 16 | ||||
| 17 | local = File.expand_path "../local.rb", __FILE__ |
config/boxen.rb
| File was created | 1 | # This file will be loaded by config/basic early in a Boxen run. Use | ||
| 2 | # it to provide any custom code or behavior your Boxen setup requires. | |||
| 3 | ||||
| 4 | # Change the prefix boxen is installed to. | |||
| 5 | # ENV['BOXEN_HOME'] = '/opt/boxen' | |||
| 6 | ||||
| 7 | # Change the repo boxen will use. | |||
| 8 | # ENV['BOXEN_REPO_NAME'] = 'boxen/our-boxen' | |||
| 9 | ||||
| 10 | # Boxen binary packaging | |||
| 11 | # ENV["BOXEN_S3_ACCESS_KEY"] = '' | |||
| 12 | # ENV["BOXEN_S3_SECRET_KEY"] = '' | |||
| 13 | # ENV["BOXEN_S3_BUCKET"] = '' | |||
| 14 | ||||
| 15 | # Auto-report issues on failed runs | |||
| 16 | # ENV["BOXEN_ISSUES_ENABLED"] = 'yes' | |||
| 17 | ||||
| 18 | # Submit audit data to an arbitrary HTTP endpoint | |||
| 19 | # ENV["BOXEN_WEB_HOOK_URL"] = 'https://some-uri.com/boxen' |
config/hiera.yaml
| File was created | 1 | --- | ||
| 2 | # This file configures the hiera "database" for Boxen. As with most files in | |||
| 3 | # this repo, it's just an example, and you should feel free to make any | |||
| 4 | # changes suited to your organisation. | |||
| 5 | ||||
| 6 | # The defaults here should give you a solid start; put global defaults in | |||
| 7 | # a file named hiera/common.yaml, and individuals can supplement and/or override | |||
| 8 | # them in hiera/{github_login}.yaml | |||
| 9 | ||||
| 10 | :backends: | |||
| 11 | - yaml | |||
| 12 | :yaml: | |||
| 13 | :datadir: "%{::boxen_home}/repo/hiera" | |||
| 14 | :hierarchy: | |||
| 15 | - "users/%{github_login}" | |||
| 16 | - common | |||
| 17 | ||||
| 18 | # Many modules make their own hiera data available through the use of | |||
| 19 | # puppet-module-data. Some depend on the 'deeper' merge_behavior setting, so | |||
| 20 | # remove it at your own risk! | |||
| 21 | # ... |
docs/faq.md
| File was created | 1 | # FAQ | ||
| 2 | ||||
| 3 | Below you can find common questions and answers. | |||
| 4 | ||||
| 5 | ### Q: How do you uninstall an application and get it to reinstall in the application folder with boxen? | |||
| 6 | ||||
| 7 | When removing applications make sure to remove the corresponding `/var/db/.puppet_appdmg_installed_application` so that boxen will reinstall it. | |||
| 8 | ||||
| 9 | ### Q: How do you remove Boxen? | |||
| 10 | ||||
| 11 | Run `script/nuke` from inside the `/opt/boxen/repo` directory. | |||
| 12 | ||||
| 13 | ### Q: How do you upgrade your boxen from the public our-boxen? | |||
| 14 | Anwser distilled from http://grahamgilbert.com/blog/2014/04/04/updating-boxen/ | |||
| 15 | As Boxen is made by GitHub, updating it is much like updating any other project on there that youโve made a fork of. First weโre going to add it as a remote repository: | |||
| 16 | ||||
| 17 | ```bash | |||
| 18 | cd ~/src/our-boxen | |||
| 19 | git remote add upstream https://github.com/boxen/our-boxen.git | |||
| 20 | ``` | |||
| 21 | Then weโre going to fetch the stuff from the upstream repository: | |||
| 22 | ||||
| 23 | ```bash | |||
| 24 | git fetch upstream | |||
| 25 | ``` | |||
| 26 | ||||
| 27 | Now weโre going to merge the updated repository with our own: | |||
| 28 | ||||
| 29 | ```bash | |||
| 30 | git checkout master | |||
| 31 | git merge upstream/master | |||
| 32 | ``` | |||
| 33 | ||||
| 34 | Now deal with conflicts in (Puppetfile, manifests/site.pp), ignore any diffs in Puppetfile.lock and Gemfile.lock. | |||
| 35 | ||||
| 36 | ||||
| 37 | ```bash | |||
| 38 | git mergetool | |||
| 39 | ``` | |||
| 40 | ||||
| 41 | The next step is to update your Puppet modules and RubyGems. First delete Puppetfile.lock and Gemfile.lock. Now go back to your trusty Terminal and: | |||
| 42 | ||||
| 43 | ```bash | |||
| 44 | rm Puppetfile.lock Gemfile.lock | |||
| 45 | bundle install --no-deployment --without development |
docs/modules.md
| File was created | 1 | # Writing Puppet modules for Boxen | ||
| 2 | ||||
| 3 | Writing Puppet modules for Boxen is easy. | |||
| 4 | ||||
| 5 | ## Tooling | |||
| 6 | ||||
| 7 | * Always use Bundler | |||
| 8 | * Always use librarian-puppet | |||
| 9 | * Always use puppet-lint | |||
| 10 | * Always use rspec-puppet | |||
| 11 | ||||
| 12 | ## Directory structure | |||
| 13 | ||||
| 14 | We follow Puppet's recommended structure very closely. | |||
| 15 | Here's the directory structure from the boxen Puppet module: | |||
| 16 | ||||
| 17 | ``` | |||
| 18 | โโโ Gemfile | |||
| 19 | โโโ Gemfile.lock | |||
| 20 | โโโ README.md | |||
| 21 | โโโ files | |||
| 22 | โย ย โโโ README.md | |||
| 23 | โย ย โโโ gemrc | |||
| 24 | โโโ lib | |||
| 25 | โย ย โโโ facter | |||
| 26 | โย ย โย ย โโโ boxen.rb | |||
| 27 | โย ย โย ย โโโ root_encrypted.rb | |||
| 28 | โย ย โโโ puppet | |||
| 29 | โย ย โโโ parser | |||
| 30 | โย ย โย ย โโโ functions | |||
| 31 | โย ย โย ย โโโ file_exists.rb | |||
| 32 | โย ย โย ย โโโ include_all_projects.rb | |||
| 33 | โย ย โย ย โโโ include_projects_from_boxen_cli.rb | |||
| 34 | โย ย โโโ provider | |||
| 35 | โย ย โย ย โโโ package | |||
| 36 | โย ย โย ย โย ย โโโ compressed_app.rb | |||
| 37 | โย ย โย ย โย ย โโโ hax.rb | |||
| 38 | โย ย โย ย โย ย โโโ homebrew.rb | |||
| 39 | โย ย โย ย โโโ repository | |||
| 40 | โย ย โย ย โย ย โโโ git.rb | |||
| 41 | โย ย โย ย โโโ service | |||
| 42 | โย ย โย ย โโโ ghlaunchd.rb | |||
| 43 | โย ย โโโ type | |||
| 44 | โย ย โโโ repository.rb | |||
| 45 | โโโ manifests | |||
| 46 | โย ย โโโ bin.pp | |||
| 47 | โย ย โโโ config.pp | |||
| 48 | โย ย โโโ development | |||
| 49 | โย ย โย ย โโโ project.pp | |||
| 50 | โย ย โโโ development.pp | |||
| 51 | โย ย โโโ environment.pp | |||
| 52 | โย ย โโโ gemrc.pp | |||
| 53 | โย ย โโโ janitor.pp | |||
| 54 | โย ย โโโ osx_defaults.pp | |||
| 55 | โย ย โโโ personal.pp | |||
| 56 | โย ย โโโ profile.pp | |||
| 57 | โย ย โโโ project.pp | |||
| 58 | โย ย โโโ repo.pp | |||
| 59 | โย ย โโโ security.pp | |||
| 60 | โย ย โโโ sudoers.pp | |||
| 61 | โย ย โโโ zipped_widget.pp | |||
| 62 | โโโ script | |||
| 63 | โย ย โโโ bootstrap | |||
| 64 | โย ย โโโ cibuild | |||
| 65 | โย ย โโโ lint | |||
| 66 | โย ย โโโ specs | |||
| 67 | โย ย โโโ syntax | |||
| 68 | โโโ spec | |||
| 69 | โย ย โโโ classes | |||
| 70 | โย ย โย ย โโโ bin_spec.rb | |||
| 71 | โย ย โย ย โโโ environment_spec.rb | |||
| 72 | โย ย โโโ fixtures | |||
| 73 | โย ย โย ย โโโ Puppetfile | |||
| 74 | โย ย โย ย โโโ Puppetfile.lock | |||
| 75 | โย ย โย ย โโโ manifests | |||
| 76 | โย ย โย ย โย ย โโโ site.pp | |||
| 77 | โย ย โย ย โโโ modules | |||
| 78 | โย ย โย ย โโโ boxen | |||
| 79 | โย ย โย ย โย ย โโโ files -> ../../../../files | |||
| 80 | โย ย โย ย โย ย โโโ lib -> ../../../../lib | |||
| 81 | โย ย โย ย โย ย โโโ manifests -> ../../../../manifests | |||
| 82 | โย ย โย ย โย ย โโโ templates -> ../../../../templates | |||
| 83 | โย ย โย ย โโโ projects | |||
| 84 | โย ย โย ย โโโ manifests | |||
| 85 | โย ย โย ย โโโ test.pp | |||
| 86 | โย ย โโโ spec_helper.rb | |||
| 87 | โย ย โโโ unit | |||
| 88 | โย ย โโโ puppet | |||
| 89 | โย ย โโโ type | |||
| 90 | โย ย โโโ repository_spec.rb | |||
| 91 | โโโ templates | |||
| 92 | โโโ config.sh.erb | |||
| 93 | โโโ env.sh.erb | |||
| 94 | โโโ gh_creds.sh.erb | |||
| 95 | ``` | |||
| 96 | ||||
| 97 | Of note, we do not use things like `rake` to drive specs. | |||
| 98 | Instead, we bias towards simple, portable shell scripts that can be consumed | |||
| 99 | by other shell scripts. | |||
| 100 |
docs/personal-configuration.md
| File was created | 1 | # Personal Configuration | ||
| 2 | ||||
| 3 | One of the design choices of Boxen very early on was that we didn't want to | |||
| 4 | dictate down to users "you can do this, but you can't do that". | |||
| 5 | We do so as little as possible in the core, and we don't do it at all for | |||
| 6 | per-user configurations. | |||
| 7 | ||||
| 8 | How? The personal manifest. | |||
| 9 | ||||
| 10 | ## What even is a personal manifest? | |||
| 11 | ||||
| 12 | Personal manifests live in `modules/people/manifests/<name>.pp`, | |||
| 13 | where `<name>` is your GitHub username. | |||
| 14 | ||||
| 15 | The simplest personal manifest looks like this: | |||
| 16 | ||||
| 17 | ``` puppet | |||
| 18 | class people::wfarr { | |||
| 19 | notify { 'hello world': } | |||
| 20 | } | |||
| 21 | ``` | |||
| 22 | ||||
| 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: | |||
| 26 | ||||
| 27 | ``` puppet | |||
| 28 | class people::wfarr { | |||
| 29 | include boxen::development | |||
| 30 | } | |||
| 31 | ``` | |||
| 32 | ||||
| 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.": } |
docs/puppet.md
| File was created | 1 | # What 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. |
docs/rails.md
| File was created | 1 | # Using Boxen with Rails Projects | ||
| 2 | ||||
| 3 | Boxen is designed to work extremely well with Rails. | |||
| 4 | Let's break down some of the basics: | |||
| 5 | ||||
| 6 | ## Project Management | |||
| 7 | ||||
| 8 | We make a few assumptions about how you run Rails in development for ease and consistency: | |||
| 9 | ||||
| 10 | * You use a web server that listens on a socket | |||
| 11 | * You use environment variables and something like [dotenv](https://github.com/bkeepers/dotenv) for managing secrets | |||
| 12 | ||||
| 13 | A typical Rails app that uses things like MySQL, Resque, and phantomjs | |||
| 14 | might have a [project definition](../modules/projects/README.md) like so: | |||
| 15 | ||||
| 16 | ``` puppet | |||
| 17 | class projects::rails_app { | |||
| 18 | include phantomjs | |||
| 19 | ||||
| 20 | boxen::project { 'rails_app': | |||
| 21 | ruby => '1.9.3', | |||
| 22 | mysql => true, | |||
| 23 | redis => true, | |||
| 24 | nginx => true, | |||
| 25 | source => 'username/rails_app' | |||
| 26 | } | |||
| 27 | } | |||
| 28 | ``` | |||
| 29 | ||||
| 30 | This does a few things for you: | |||
| 31 | ||||
| 32 | * Clones `https://github.com/username/rails_app.git` to `~/src/rails_app` | |||
| 33 | * Ensures the default 1.9.3 version of Ruby is installed | |||
| 34 | * Creates `~/src/rails_app/.ruby-version` with `1.9.3` in it | |||
| 35 | * Ensures mysql is installed and running | |||
| 36 | * Creates two mysql databases: `rails_app_test` and `rails_app_development` | |||
| 37 | * Ensures redis is installed and running | |||
| 38 | * Ensures nginx is installed and running | |||
| 39 | * Copies the [template nginx config](../modules/projects/templates/shared/nginx.conf.erb) into the nginx config dir | |||
| 40 | ||||
| 41 | It won't necessarily do all of them in that order, but it will guarantee | |||
| 42 | that if they run successfully they're all done in a correct order. | |||
| 43 | ||||
| 44 | See the section below for some handy configuration tips on how to configure | |||
| 45 | your app best to work with Boxen. | |||
| 46 | ||||
| 47 | ## Configuration | |||
| 48 | ||||
| 49 | ### MySQL | |||
| 50 | ||||
| 51 | ``` yaml | |||
| 52 | # config/database.yml | |||
| 53 | ||||
| 54 | <% | |||
| 55 | socket = [ | |||
| 56 | ENV["BOXEN_MYSQL_SOCKET"], | |||
| 57 | "/var/run/mysql5/mysqld.sock", | |||
| 58 | "/tmp/mysql.sock" | |||
| 59 | ].compact.detect { |f| File.exist? f } | |||
| 60 | ||||
| 61 | port = ENV["BOXEN_MYSQL_PORT"] || "3306" | |||
| 62 | %> | |||
| 63 | ||||
| 64 | development: | |||
| 65 | adapter: mysql2 | |||
| 66 | database: rails_app_development | |||
| 67 | username: root | |||
| 68 | password: | |||
| 69 | <% if socket %> | |||
| 70 | host: localhost | |||
| 71 | socket: <%= socket %> | |||
| 72 | <% else %> | |||
| 73 | host: 127.0.0.1 | |||
| 74 | port: <%= port %> | |||
| 75 | <% end %> | |||
| 76 | ||||
| 77 | test: | |||
| 78 | adapter: mysql2 | |||
| 79 | database: rails_app_test | |||
| 80 | username: root | |||
| 81 | password: | |||
| 82 | <% if socket %> | |||
| 83 | host: localhost | |||
| 84 | socket: <%= socket %> | |||
| 85 | <% else %> | |||
| 86 | host: 127.0.0.1 | |||
| 87 | port: <%= port %> | |||
| 88 | <% end %> | |||
| 89 | ``` | |||
| 90 | ||||
| 91 | ### PostgreSQL | |||
| 92 | ||||
| 93 | ``` yaml | |||
| 94 | # config/database.yml | |||
| 95 | ||||
| 96 | development: | |||
| 97 | adapter: postgresql | |||
| 98 | database: rails_app_development | |||
| 99 | encoding: unicode | |||
| 100 | port: <%= ENV["BOXEN_POSTGRESQL_PORT"] || 5432 %> | |||
| 101 | host: localhost | |||
| 102 | ||||
| 103 | test: | |||
| 104 | adapter: postgresql | |||
| 105 | database: rails_app_test | |||
| 106 | encoding: unicode | |||
| 107 | port: <%= ENV["BOXEN_POSTGRESQL_PORT"] || 5432 %> | |||
| 108 | host: localhost | |||
| 109 | ``` | |||
| 110 | ||||
| 111 | ### Redis | |||
| 112 | ||||
| 113 | ``` ruby | |||
| 114 | # config/initializers/redis.rb | |||
| 115 | ||||
| 116 | $redis = Redis.new(ENV['BOXEN_REDIS_URL'] || 'redis://localhost:6379/') | |||
| 117 | ``` | |||
| 118 | ||||
| 119 | ### Elasticsearch | |||
| 120 | ||||
| 121 | ``` ruby | |||
| 122 | # config/initializers/elasticsearch.rb | |||
| 123 | ||||
| 124 | Tire.configure do | |||
| 125 | url (ENV['BOXEN_ELASTICSEARCH_URL'] || 'http://localhost:9200/') | |||
| 126 | end | |||
| 127 | ``` | |||
| 128 | ||||
| 129 | ### MongoDB | |||
| 130 | ||||
| 131 | ``` yaml | |||
| 132 | # config/mongo.yml | |||
| 133 | ||||
| 134 | development: | |||
| 135 | host: 127.0.0.1 | |||
| 136 | port: <%= ENV['BOXEN_MONGODB_PORT'] || 27017 %> | |||
| 137 | database: rails_app_development | |||
| 138 | ||||
| 139 | test: | |||
| 140 | host: 127.0.0.1 |
hiera/common.yaml.example
| File was created | 1 | --- | ||
| 2 | # This is an example of the kinds of things that you can configure via hiera. | |||
| 3 | # If you've left the defaults in `/hiera.yml`, you might want to copy this file | |||
| 4 | # to `hiera/common.yaml`, or feel free to start with a blank slate! | |||
| 5 | ||||
| 6 | # Have a gander at some of these examples to get an idea of some of the things | |||
| 7 | # that you can affect 'out of the box', and then customise to your | |||
| 8 | # heart's content. | |||
| 9 | ||||
| 10 | # See https://github.com/boxen/puppet-ruby for docs | |||
| 11 | ruby::global::version: "2.1.0" | |||
| 12 | ruby::rbenv_plugins: | |||
| 13 | rbenv-vars: | |||
| 14 | ensure: v1.0.0 | |||
| 15 | source: sstephenson/rbenv-vars | |||
| 16 | ruby-build: | |||
| 17 | ensure: v20131225.1 | |||
| 18 | source: sstephenson/ruby-build | |||
| 19 | ruby::version::alias: | |||
| 20 | 2.0.0: 2.0.0-p353 |
hiera/users/hanjianwei.yaml
| File was created | 1 | ruby::global::version: "2.1.2" | ||
| 2 | nodejs::global::version: "v0.10" |
manifests/site.pp
| File was created | 1 | require boxen::environment | ||
| 2 | require homebrew | |||
| 3 | require gcc | |||
| 4 | ||||
| 5 | Exec { | |||
| 6 | group => 'staff', | |||
| 7 | logoutput => on_failure, | |||
| 8 | user => $boxen_user, | |||
| 9 | ||||
| 10 | path => [ | |||
| 11 | "${boxen::config::home}/rbenv/shims", | |||
| 12 | "${boxen::config::home}/rbenv/bin", | |||
| 13 | "${boxen::config::home}/rbenv/plugins/ruby-build/bin", | |||
| 14 | "${boxen::config::home}/homebrew/bin", | |||
| 15 | '/usr/bin', | |||
| 16 | '/bin', | |||
| 17 | '/usr/sbin', | |||
| 18 | '/sbin' | |||
| 19 | ], | |||
| 20 | ||||
| 21 | environment => [ | |||
| 22 | "HOMEBREW_CACHE=${homebrew::config::cachedir}", | |||
| 23 | "HOME=/Users/${::boxen_user}" | |||
| 24 | ] | |||
| 25 | } | |||
| 26 | ||||
| 27 | File { | |||
| 28 | group => 'staff', | |||
| 29 | owner => $boxen_user | |||
| 30 | } | |||
| 31 | ||||
| 32 | Package { | |||
| 33 | provider => homebrew, | |||
| 34 | require => Class['homebrew'] | |||
| 35 | } | |||
| 36 | ||||
| 37 | Repository { | |||
| 38 | provider => git, | |||
| 39 | extra => [ | |||
| 40 | '--recurse-submodules' | |||
| 41 | ], | |||
| 42 | require => File["${boxen::config::bindir}/boxen-git-credential"], | |||
| 43 | config => { | |||
| 44 | 'credential.helper' => "${boxen::config::bindir}/boxen-git-credential" | |||
| 45 | } | |||
| 46 | } | |||
| 47 | ||||
| 48 | Service { | |||
| 49 | provider => ghlaunchd | |||
| 50 | } | |||
| 51 | ||||
| 52 | Homebrew::Formula <| |> -> Package <| |> | |||
| 53 | ||||
| 54 | node default { | |||
| 55 | # core modules, needed for most things | |||
| 56 | include dnsmasq | |||
| 57 | include git | |||
| 58 | include hub | |||
| 59 | include nginx | |||
| 60 | ||||
| 61 | # fail if FDE is not enabled | |||
| 62 | if $::root_encrypted == 'no' { | |||
| 63 | fail('Please enable full disk encryption and try again') | |||
| 64 | } | |||
| 65 | ||||
| 66 | # node versions | |||
| 67 | include nodejs::v0_10 | |||
| 68 | include nodejs::global | |||
| 69 | ||||
| 70 | # default ruby versions | |||
| 71 | ruby::version { '1.9.3': } | |||
| 72 | ruby::version { '2.0.0': } | |||
| 73 | ruby::version { '2.1.2': } | |||
| 74 | include ruby::global | |||
| 75 |
modules/people/README.md
| File was created | 1 | # Personal Manifests | ||
| 2 | ||||
| 3 | Per-user manifests live in `modules/people/manifests/$login.pp`, where | |||
| 4 | `$login` is a GitHub login. A simple user manifest example: | |||
| 5 | ||||
| 6 | ```puppet | |||
| 7 | class people::jbarnette { | |||
| 8 | include emacs # requires emacs module in Puppetfile | |||
| 9 | include sparrow # requires sparrow module in Puppetfile | |||
| 10 | ||||
| 11 | $home = "/Users/${::boxen_user}" | |||
| 12 | $my = "${home}/my" | |||
| 13 | $dotfiles = "${my}/dotfiles" | |||
| 14 | ||||
| 15 | file { $my: | |||
| 16 | ensure => directory | |||
| 17 | } | |||
| 18 | ||||
| 19 | repository { $dotfiles: | |||
| 20 | source => 'jbarnette/dotfiles', | |||
| 21 | require => File[$my] | |||
| 22 | } | |||
| 23 | } | |||
| 24 | ``` | |||
| 25 | ||||
| 26 | Note that if your GitHub username contains dashes, you should replace them by underscores in both the manifest name and the class name. | |||
| 27 |
modules/people/manifests/hanjianwei.pp
| File was created | 1 | class people::hanjianwei { | ||
| 2 | include people::hanjianwei::osx | |||
| 3 | include people::hanjianwei::repositories | |||
| 4 | include people::hanjianwei::applications | |||
| 5 | } |
modules/people/manifests/hanjianwei/applications.pp
| File was created | 1 | class people::hanjianwei::applications inherits people::hanjianwei::config { | ||
| 2 | notify { "${homebrew::config::cachedir}": } | |||
| 3 | ||||
| 4 | # Declare all Homebrew packages | |||
| 5 | $brew_pkgs = [ | |||
| 6 | 'wget', | |||
| 7 | 'qt5', | |||
| 8 | 'tmux', | |||
| 9 | 'vim' | |||
| 10 | ] | |||
| 11 | package { $brew_pkgs: } | |||
| 12 | ||||
| 13 | homebrew::tap { 'homebrew/science': } | |||
| 14 | -> | |||
| 15 | package { 'opencv': } | |||
| 16 | ||||
| 17 | # Declare all Hombrew Cask packages | |||
| 18 | include brewcask | |||
| 19 | ||||
| 20 | $cask_pkgs = [ | |||
| 21 | 'acorn', | |||
| 22 | 'alfred', | |||
| 23 | 'atom', | |||
| 24 | 'bettertouchtool', | |||
| 25 | 'caffeine', | |||
| 26 | 'cleanmymac', | |||
| 27 | 'dropbox', | |||
| 28 | 'evernote', | |||
| 29 | 'fantastical', | |||
| 30 | 'firefox', | |||
| 31 | 'google-chrome', | |||
| 32 | 'hazel', | |||
| 33 | 'iterm2', | |||
| 34 | 'keyboard-maestro', | |||
| 35 | 'keyremap4macbook', | |||
| 36 | 'mactex', | |||
| 37 | 'omnifocus', | |||
| 38 | 'onepassword', | |||
| 39 | 'parallels', | |||
| 40 | 'pycharm-ce', | |||
| 41 | 'scapple', | |||
| 42 | 'screenflow', | |||
| 43 | 'scrivener', | |||
| 44 | 'seil', | |||
| 45 | 'shiori', | |||
| 46 | 'qq', | |||
| 47 | 'qt-creator', | |||
| 48 | 'vagrant', | |||
| 49 | 'virtualbox', | |||
| 50 | 'welly', | |||
| 51 | 'xmind' | |||
| 52 | ] | |||
| 53 | ||||
| 54 | package { $cask_pkgs: | |||
| 55 | provider => 'brewcask' | |||
| 56 | } | |||
| 57 | ||||
| 58 | # Taps | |||
| 59 | homebrew::tap { 'caskroom/fonts': } | |||
| 60 | -> | |||
| 61 | package { 'font-inconsolata-for-powerline': | |||
| 62 | provider => 'brewcask' | |||
| 63 | } | |||
| 64 | ||||
| 65 | homebrew::tap { 'caskroom/versions': } | |||
| 66 | -> | |||
| 67 | package { 'intellij-idea-ultimate12': | |||
| 68 | provider => 'brewcask' | |||
| 69 | } | |||
| 70 | ||||
| 71 | homebrew::tap { 'railwaycat/emacsmacport': } | |||
| 72 | -> | |||
| 73 | package { 'emacs-mac': | |||
| 74 | provider => 'brewcask' | |||
| 75 | } | |||
| 76 | ||||
| 77 | # tmux | |||
| 78 | Package['tmux'] | |||
| 79 | -> | |||
| 80 | file { "${home}/.tmux.conf": | |||
| 81 | ensure => link, | |||
| 82 | target => "${dotfiles}/tmux/tmux.conf", | |||
| 83 | require => Repository["${dotfiles}"] | |||
| 84 | } | |||
| 85 | ||||
| 86 | # Vim | |||
| 87 | Package['vim'] | |||
| 88 | -> | |||
| 89 | file { "${home}/.vimrc": | |||
| 90 | ensure => link, | |||
| 91 | target => "${dotfiles}/Vim/vimrc", | |||
| 92 | require => Repository["${dotfiles}"] | |||
| 93 | } | |||
| 94 | -> | |||
| 95 | file { ["${home}/.vim", "${home}/.vim/bundle"]: | |||
| 96 | ensure => directory | |||
| 97 | } | |||
| 98 | -> | |||
| 99 | repository { "${home}/.vim/bundle/Vundle.vim": | |||
| 100 | source => 'gmarik/Vundle.vim' | |||
| 101 | } | |||
| 102 | -> | |||
| 103 | exec { 'vim +BundleInstall +BundleClean +qall': } | |||
| 104 | ||||
| 105 | ||||
| 106 | # Emacs mac port | |||
| 107 | Package['emacs-mac'] | |||
| 108 | -> | |||
| 109 | file { "${home}/.emacs.d": | |||
| 110 | ensure => directory | |||
| 111 | } | |||
| 112 | -> | |||
| 113 | file { "${home}/.emacs.d/init.el": | |||
| 114 | ensure => link, | |||
| 115 | target => "${dotfiles}/Emacs/init.el", | |||
| 116 | require => Repository["${dotfiles}"] | |||
| 117 | } | |||
| 118 | -> | |||
| 119 | repository { "${home}/.emacs.d/snippets": | |||
| 120 | source => 'hanjianwei/yasnippet-snippets' | |||
| 121 | } | |||
| 122 | ||||
| 123 | # Firefox | |||
| 124 | Package['firefox'] | |||
| 125 | -> | |||
| 126 | file { "${home}/.vimperatorrc": | |||
| 127 | target => "${dotfiles}/Vimperator/vimperatorrc", | |||
| 128 | require => Repository["${dotfiles}"] | |||
| 129 | } | |||
| 130 | ||||
| 131 | # KeyRemap4Macbook | |||
| 132 | # include keyremap4macbook | |||
| 133 | # include keyremap4macbook::login_item | |||
| 134 | # keyremap4macbook::remap { 'private.f19_to_hyper': } |
modules/people/manifests/hanjianwei/config.pp
| File was created | 1 | class people::hanjianwei::config { | ||
| 2 | $home = "/Users/${::boxen_user}" | |||
| 3 | $srcdir = "${boxen_srcdir}" | |||
| 4 | $dotfiles = "${srcdir}/dotfiles" | |||
| 5 | } |
modules/people/manifests/hanjianwei/mirrors.pp
| File was created | 1 | class people::hanjianwei::mirrors inherits people::hanjianwei::config { | ||
| 2 | include boxen::gemrc | |||
| 3 | ||||
| 4 | File <| title == "/Users/${::boxen_user}/.gemrc" |> { | |||
| 5 | source => "${dotfiles}/Gem/gemrc", | |||
| 6 | require => Repository["${dotfiles}"] | |||
| 7 | } |
modules/people/manifests/hanjianwei/osx.pp
| File was created | 1 | class people::hanjianwei::osx inherits people::hanjianwei::config { | ||
| 2 | # Zsh | |||
| 3 | osx_chsh { $boxen_user: | |||
| 4 | shell => '/bin/zsh' | |||
| 5 | } | |||
| 6 | ||||
| 7 | repository { "${home}/.zprezto": | |||
| 8 | source => 'sorin-ionescu/prezto' | |||
| 9 | } | |||
| 10 | -> | |||
| 11 | file { "${home}/.zshrc": | |||
| 12 | ensure => link, | |||
| 13 | target => "${dotfiles}/Zsh/zshrc", | |||
| 14 | require => Repository["${dotfiles}"] | |||
| 15 | } | |||
| 16 | -> | |||
| 17 | file { "${home}/.zshenv": | |||
| 18 | ensure => link, | |||
| 19 | target => "${dotfiles}/Zsh/zshenv", | |||
| 20 | require => Repository["${dotfiles}"] | |||
| 21 | } | |||
| 22 | -> | |||
| 23 | file { "${home}/.zpreztorc": | |||
| 24 | ensure => link, | |||
| 25 | target => "${dotfiles}/Zsh/zpreztorc", | |||
| 26 | require => Repository["${dotfiles}"] | |||
| 27 | } | |||
| 28 | -> | |||
| 29 | file { "${home}/.zlogin": | |||
| 30 | ensure => link, | |||
| 31 | target => "${dotfiles}/Zsh/zlogin", | |||
| 32 | require => Repository["${dotfiles}"] | |||
| 33 | } | |||
| 34 | -> | |||
| 35 | file { "${home}/.zlogout": | |||
| 36 | ensure => link, | |||
| 37 | target => "${dotfiles}/Zsh/zlogout", | |||
| 38 | require => Repository["${dotfiles}"] | |||
| 39 | } | |||
| 40 | file { "${home}/.activate.sh": | |||
| 41 | ensure => link, | |||
| 42 | target => "${dotfiles}/Zsh/activate.sh", | |||
| 43 | require => Repository["${dotfiles}"] | |||
| 44 | } | |||
| 45 | ||||
| 46 | # Setup mirrors | |||
| 47 | include people::hanjianwei::mirrors | |||
| 48 | ||||
| 49 | # OSX settings | |||
| 50 | include 'osx::global::expand_save_dialog' | |||
| 51 | include 'osx::global::tap_to_click' | |||
| 52 | include 'osx::disable_app_quarantine' |
modules/people/manifests/hanjianwei/repositories.pp
| File was created | 1 | class people::hanjianwei::repositories inherits people::hanjianwei::config { | ||
| 2 | # Git | |||
| 3 | file { "${home}/.gitconfig": | |||
| 4 | target => "${dotfiles}/Git/gitconfig", | |||
| 5 | require => Repository["${dotfiles}"] | |||
| 6 | } | |||
| 7 | ||||
| 8 | # Repos | |||
| 9 | repository { "${dotfiles}": | |||
| 10 | source => 'hanjianwei/dotfiles' | |||
| 11 | } |
modules/projects/README.md
| File was created | 1 | # Project Manifests | ||
| 2 | ||||
| 3 | Project manifests live in `modules/projects/manifests/$project.pp`. A | |||
| 4 | simple project manifest example: | |||
| 5 | ||||
| 6 | ```puppet | |||
| 7 | class projects::trollin { | |||
| 8 | include icu4c | |||
| 9 | include phantomjs | |||
| 10 | ||||
| 11 | boxen::project { 'trollin': | |||
| 12 | dotenv => true, | |||
| 13 | elasticsearch => true, | |||
| 14 | mysql => true, | |||
| 15 | nginx => true, | |||
| 16 | redis => true, | |||
| 17 | ruby => '1.9.3', | |||
| 18 | source => 'boxen/trollin' | |||
| 19 | } | |||
| 20 | } | |||
| 21 | ``` | |||
| 22 | ||||
| 23 | With the above, as long as our app is configured to listen on a **socket** at | |||
| 24 | `"#{ENV['BOXEN_SOCKET_DIR']}"/trollin`, you'll now be able to run its local | |||
| 25 | server and visit http://trollin.dev/ to access the app in dev. | |||
| 26 | ||||
| 27 | Provide the full repository URL in the 'source' option when referencing |
modules/projects/manifests/all.pp
| File was created | 1 | class projects::all { | ||
| 2 | include_all_projects() | |||
| 3 | } |
modules/projects/templates/shared/nginx.conf.erb
| File was created | 1 | upstream <%= @server_name %> { | ||
| 2 | server unix:<%= scope.lookupvar "boxen::config::socketdir" %>/<%= @name %>; | |||
| 3 | } | |||
| 4 | ||||
| 5 | server { | |||
| 6 | access_log <%= scope.lookupvar "nginx::config::logdir" %>/<%= @name %>.access.log main; | |||
| 7 | listen 80; | |||
| 8 | root <%= @repo_dir %>/public; | |||
| 9 | server_name <%= @server_name %> *.<%= @server_name %>; | |||
| 10 | ||||
| 11 | client_max_body_size 50M; | |||
| 12 | error_page 500 502 503 504 /50x.html; | |||
| 13 | ||||
| 14 | location = /50x.html { | |||
| 15 | root html; | |||
| 16 | } | |||
| 17 | ||||
| 18 | try_files $uri/index.html $uri @<%= @server_name %>; | |||
| 19 | location @<%= @server_name %> { | |||
| 20 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |||
| 21 | proxy_set_header Host $http_host; |
script/bootstrap
| File was created | 1 | #!/bin/sh | ||
| 2 | # Make sure all our local dependencies are available. | |||
| 3 | ||||
| 4 | set -e | |||
| 5 | ||||
| 6 | # FIX: only sudo if gem home isn't writable | |||
| 7 | ||||
| 8 | (/usr/bin/gem list -i bundler -v '~> 1.5.3' > /dev/null) || { | |||
| 9 | /usr/bin/sudo -E -p "Need to install Bundler for system ruby, password for sudo: " \ | |||
| 10 | /usr/bin/gem install bundler -v '~> 1.5.3' --no-rdoc --no-ri | |||
| 11 | } | |||
| 12 | ||||
| 13 | # We don't want old config hanging around. | |||
| 14 | ||||
| 15 | rm -rf .bundle/config | |||
| 16 | rm -rf .librarian/puppet/config | |||
| 17 | ||||
| 18 | CLT_VERSION=`pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version | cut -f 2 -d ' ' | awk ' { print $1; } '` | |||
| 19 | ||||
| 20 | # Bundle install unless we're already up to date. | |||
| 21 | if [[ $CLT_VERSION =~ ^5\.1\.0\.0\.1\.1396320587 ]]; then |
script/boxen
| File was created | 1 | #!/usr/bin/ruby | ||
| 2 | # Run Boxen. | |||
| 3 | ||||
| 4 | require "pathname" | |||
| 5 | ||||
| 6 | if ENV["USER"] == "root" | |||
| 7 | abort "Run this as a normal user, I'll sudo if I need to." | |||
| 8 | end | |||
| 9 | ||||
| 10 | # Make sure only one boxen process runs at a time. | |||
| 11 | ||||
| 12 | myself = File.new __FILE__ | |||
| 13 | ||||
| 14 | unless myself.flock File::LOCK_EX | File::LOCK_NB | |||
| 15 | abort "You're already running a boxen process! Know a patience." | |||
| 16 | end | |||
| 17 | ||||
| 18 | # Yeah yeah, I like to be explicit. | |||
| 19 | ||||
| 20 | at_exit { myself.flock File::LOCK_UN } | |||
| 21 | ||||
| 22 | # Put us where we belong, in the root dir of our boxen repo. | |||
| 23 | ||||
| 24 | Dir.chdir Pathname.new(__FILE__).realpath + "../.." | |||
| 25 | ||||
| 26 | # Auto-update code. This is done as early as possible so that changes | |||
| 27 | # to boxen support code or dependencies can be grabbed. | |||
| 28 | NO_PULL_ARGS = %w[--no-pull -h -? --help] + [/-service/] | |||
| 29 | unless ENV["BOXEN_NO_PULL"] || | |||
| 30 | ARGV.any? { |arg| NO_PULL_ARGS.any? { |no| arg.match(no) } } | |||
| 31 | quietly = "> /dev/null 2>&1" | |||
| 32 | ||||
| 33 | if system("which git > /dev/null") && File.directory?(".git") \ | |||
| 34 | && system("git fetch -q origin") | |||
| 35 | ||||
| 36 | clean = `git status --porcelain`.empty? | |||
| 37 | current_branch = `git symbolic-ref HEAD`.chomp | |||
| 38 | master = current_branch == "refs/heads/master" | |||
| 39 | ||||
| 40 | upstream_changes = `git rev-list --count master..origin/master`.chomp != '0' | |||
| 41 | fast_forwardable = `git rev-list --count origin/master..master`.chomp == '0' | |||
| 42 | ||||
| 43 | if current_branch.empty? | |||
| 44 | ref = `git log -1 --pretty=format:%h` | |||
| 45 | warn "Boxen not currently on any branch (ref: #{ref}), won't auto-update!" | |||
| 46 | elsif !master | |||
| 47 | local_branch = current_branch.split('/')[2..-1].join('/') | |||
| 48 | warn "Boxen on a non-master branch '#{local_branch}', won't auto-update!" | |||
| 49 | elsif !fast_forwardable | |||
| 50 | warn "Boxen's master branch is out of sync, won't auto-update!" | |||
| 51 | elsif !clean | |||
| 52 | warn "Boxen has a dirty tree, won't auto-update!" | |||
| 53 | elsif !upstream_changes | |||
| 54 | warn "Boxen is up-to-date." | |||
| 55 | end | |||
| 56 | ||||
| 57 | if clean && master && fast_forwardable && upstream_changes | |||
| 58 | reset = "(git reset --hard origin/master #{quietly})" |
script/boxen-bootstrap
| File was created | 1 | #!/usr/bin/env ruby | ||
| 2 | # Make sure a project's deps are up-to-date. | |||
| 3 | ||||
| 4 | if File.executable? "script/bootstrap" | |||
| 5 | exec "script/bootstrap", *ARGV |
script/boxen-git-credential
| File was created | 1 | #!/usr/bin/ruby | ||
| 2 | # Provide git credentials using Boxen's config. | |||
| 3 | ||||
| 4 | unless command = ARGV[0] | |||
| 5 | this = File.basename $0 | |||
| 6 | abort "Usage: #{this} <get|store|erase>" | |||
| 7 | end | |||
| 8 | ||||
| 9 | require "pathname" | |||
| 10 | ||||
| 11 | # It's a UTF-8, UTF-8, UTF-8 world. | |||
| 12 | ||||
| 13 | Encoding.default_external = Encoding::UTF_8 if RUBY_VERSION > "1.9" | |||
| 14 | ||||
| 15 | # Put us where we belong, in the root dir of our boxen repo. | |||
| 16 | ||||
| 17 | Dir.chdir Pathname.new(__FILE__).realpath + "../.." | |||
| 18 | ||||
| 19 | # Because we can be called from inside other Ruby processes, unset any | |||
| 20 | # `BUNDLE_` environment variables. | |||
| 21 | ||||
| 22 | ENV.keys.select { |k| /^BUNDLE_/i }.each { |k| ENV.delete k } | |||
| 23 | ||||
| 24 | # Set up our local configuration, deps, and load path. | |||
| 25 | ||||
| 26 | load "config/basic.rb" | |||
| 27 | require "boxen/config" | |||
| 28 | ||||
| 29 | config = Boxen::Config.load | |||
| 30 | input = $stdin.read | |||
| 31 | attrs = Hash[input.split($/).map { |l| l.split("=") }] | |||
| 32 | # find GitHub or GitHub Enterprise host | |||
| 33 | ghhost = URI(config.ghurl).host | |||
| 34 | ||||
| 35 | host_exp = Regexp.new "(^|\.)" + Regexp.escape(ghhost) | |||
| 36 | if command == "get" && host_exp.match(attrs["host"]) | |||
| 37 | puts "username=#{config.token}" |
script/boxen-my-config
| File was created | 1 | #!/usr/bin/env ruby | ||
| 2 | # Show the path to your manifest in Boxen, creating if necessary. | |||
| 3 | ||||
| 4 | user = ENV["BOXEN_GITHUB_LOGIN"] | |||
| 5 | ||||
| 6 | unless user | |||
| 7 | abort "BOXEN_GITHUB_LOGIN is not defined. Please re-run Boxen." | |||
| 8 | end | |||
| 9 | ||||
| 10 | editor = ENV["VISUAL"] || ENV["EDITOR"] | |||
| 11 | home = ENV["BOXEN_HOME"] + "/repo" | |||
| 12 | user = user.downcase.tr('-', '_') | |||
| 13 | path = "#{home}/modules/people/manifests/#{user}.pp" | |||
| 14 | ||||
| 15 | unless File.exist? path | |||
| 16 | File.open path, "wb" do |f| | |||
| 17 | f.puts "class people::#{user} {" | |||
| 18 | f.puts "}" |
script/nuke
| File was created | 1 | #!/usr/bin/ruby | ||
| 2 | ||||
| 3 | require "optparse" | |||
| 4 | ||||
| 5 | unless ENV["USER"] == "root" | |||
| 6 | exec "sudo", $0, *ARGV | |||
| 7 | end | |||
| 8 | ||||
| 9 | all = false | |||
| 10 | force = false | |||
| 11 | opt = false | |||
| 12 | services = false | |||
| 13 | receipts = false | |||
| 14 | gitconfig = false | |||
| 15 | ||||
| 16 | OptionParser.new do |o| | |||
| 17 | o.banner = "Remove most traces of Boxen from your machine." | |||
| 18 | ||||
| 19 | o.on("--all", "Remove everything possible.") { all = true } | |||
| 20 | o.on("--force", "Actually do it.") { force = true } | |||
| 21 | o.on("--help", "Show this help.") { abort o.to_s } | |||
| 22 | o.on("--opt", "Remove /opt/boxen.") { opt = true } | |||
| 23 | o.on("--services", "Remove and unload services.") { services = true } | |||
| 24 | o.on("--receipts", "Remove package receipts used by Puppet.") { receipts = true } | |||
| 25 | o.on("--gitconfig", "Remove Boxen-provided git credential helper config.") { gitconfig = true } | |||
| 26 | ||||
| 27 | o.parse! | |||
| 28 | ||||
| 29 | abort o.to_s unless all || opt || services || receipts || gitconfig | |||
| 30 | end | |||
| 31 | ||||
| 32 | unless force | |||
| 33 | warn "** I won't actually do anything unless you pass --force." | |||
| 34 | end | |||
| 35 | ||||
| 36 | if all || services | |||
| 37 | boxen_services = [] | |||
| 38 | boxen_services << Dir["/Library/Launch*/dev.*.plist"] | |||
| 39 | ||||
| 40 | boxen_services.flatten.each do |plist| | |||
| 41 | warn "-> Removing #{plist}." | |||
| 42 | ||||
| 43 | if force | |||
| 44 | system "launchctl", "unload", "-w", plist | |||
| 45 | system "rm", "-f", plist | |||
| 46 | end | |||
| 47 | end | |||
| 48 | ||||
| 49 | system "rm", "-f", "/etc/resolver/dev" | |||
| 50 | end | |||
| 51 |
script/sync
| File was created | 1 | #!/usr/bin/ruby | ||
| 2 | # Sync binary snapshots to S3. | |||
| 3 | ||||
| 4 | require "pathname" | |||
| 5 | require "tempfile" | |||
| 6 | ||||
| 7 | # Put us where we belong, in the root dir of our boxen repo. | |||
| 8 | ||||
| 9 | Dir.chdir Pathname.new(__FILE__).realpath + "../.." | |||
| 10 | ||||
| 11 | # Make sure our local dependencies are up to date. | |||
| 12 | ||||
| 13 | abort "Sorry, can't bootstrap." unless system "script/bootstrap" | |||
| 14 | ||||
| 15 | # Set up our local configuration, deps, and load path. | |||
| 16 | ||||
| 17 | load "config/basic.rb" | |||
| 18 | ||||
| 19 | require "aws-sdk" | |||
| 20 | require "boxen/config" | |||
| 21 | ||||
| 22 | access_key = ENV["BOXEN_S3_ACCESS_KEY"] | |||
| 23 | secret_key = ENV["BOXEN_S3_SECRET_KEY"] | |||
| 24 | bucket_name = ENV["BOXEN_S3_BUCKET"] | |||
| 25 | ||||
| 26 | unless access_key && secret_key && bucket_name | |||
| 27 | abort "Please set the BOXEN_S3_{ACCESS_KEY,SECRET_KEY,BUCKET} env vars." | |||
| 28 | end | |||
| 29 | ||||
| 30 | s3 = AWS::S3.new :access_key_id => access_key, :secret_access_key => secret_key | |||
| 31 | os = `sw_vers -productVersion`.strip.split(".")[0..1].join "." | |||
| 32 | ||||
| 33 | bucket = s3.buckets[bucket_name] | |||
| 34 | config = Boxen::Config.load | |||
| 35 | ||||
| 36 | # Sync Homebrew packages. | |||
| 37 | ||||
| 38 | Dir.chdir "#{config.homedir}/homebrew/Cellar" do | |||
| 39 | Dir["*/*"].each do |dir| | |||
| 40 | name, version = File.split dir | |||
| 41 | ||||
| 42 | file = "homebrew/#{os}/#{name}-#{version}.tar.bz2" | |||
| 43 | temp = Tempfile.new "homebrew" | |||
| 44 | obj = bucket.objects[file] | |||
| 45 | ||||
| 46 | next if obj.exists? | |||
| 47 | ||||
| 48 | printf "Snapshotting #{name} #{version}... " | |||
| 49 | $stdout.flush | |||
| 50 | ||||
| 51 | system "tar", "-cjf", temp.path, dir | |||
| 52 | puts "done." | |||
| 53 | ||||
| 54 | printf "Shipping #{name} #{version} to S3... " | |||
| 55 | $stdout.flush | |||
| 56 | ||||
| 57 | obj.write :acl => :public_read, :file => temp.path | |||
| 58 | puts "done." | |||
| 59 | end | |||
| 60 | end | |||
| 61 | ||||
| 62 | # Sync rbenv rubies. | |||
| 63 | ||||
| 64 | Dir.chdir "#{config.homedir}/rbenv/versions" do | |||
| 65 | Dir["*"].each do |dir| | |||
| 66 | next if File.symlink? dir | |||
| 67 | ||||
| 68 | version = File.basename dir | |||
| 69 | file = "rbenv/#{os}/#{version}.tar.bz2" | |||
| 70 | temp = Tempfile.new "rbenv" | |||
| 71 | obj = bucket.objects[file] | |||
| 72 | ||||
| 73 | next if obj.exists? | |||
| 74 | ||||
| 75 | printf "Snapshotting ruby #{version}... " | |||
| 76 | $stdout.flush | |||
| 77 | ||||
| 78 | system "tar -cjf #{temp.path} #{version}" |
shared/README.md
| File was created | 1 | # Shared Puppet Modules | ||
| 2 |