From 3a47d364c85d04b6e6bf7e5917b879c154dafa5b Mon Sep 17 00:00:00 2001 From: Jianwei Han Date: Mon, 7 Jul 2014 12:20:09 +0800 Subject: [PATCH] Remove caches for fast download --- .gitignore | 12 + .ruby-version | 1 + Gemfile | 18 ++ Gemfile.lock | 100 +++++++ LICENSE | 20 ++ Puppetfile | 61 ++++ Puppetfile.lock | 122 ++++++++ README.md | 318 +++++++++++++++++++++ config/basic.rb | 28 ++ config/boxen.rb | 25 ++ config/hiera.yaml | 24 ++ docs/faq.md | 69 +++++ docs/modules.md | 111 +++++++ docs/personal-configuration.md | 65 +++++ docs/puppet.md | 144 ++++++++++ docs/rails.md | 186 ++++++++++++ hiera/common.yaml.example | 23 ++ hiera/users/hanjianwei.yaml | 2 + lib/.gitkeep | 0 manifests/site.pp | 89 ++++++ modules/people/README.md | 36 +++ modules/people/manifests/.gitkeep | 0 modules/people/manifests/hanjianwei.pp | 5 + .../people/manifests/hanjianwei/applications.pp | 150 ++++++++++ modules/people/manifests/hanjianwei/config.pp | 5 + modules/people/manifests/hanjianwei/mirrors.pp | 8 + modules/people/manifests/hanjianwei/osx.pp | 55 ++++ .../people/manifests/hanjianwei/repositories.pp | 12 + modules/projects/README.md | 33 +++ modules/projects/manifests/.gitkeep | 0 modules/projects/manifests/all.pp | 3 + modules/projects/templates/shared/nginx.conf.erb | 25 ++ script/bootstrap | 30 ++ script/boxen | 80 ++++++ script/boxen-bootstrap | 6 + script/boxen-git-credential | 53 ++++ script/boxen-my-config | 24 ++ script/nuke | 66 +++++ script/sync | 114 ++++++++ shared/README.md | 3 + 40 files changed, 2126 insertions(+) create mode 100644 .gitignore create mode 100644 .ruby-version create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 LICENSE create mode 100644 Puppetfile create mode 100644 Puppetfile.lock create mode 100644 README.md create mode 100644 config/basic.rb create mode 100644 config/boxen.rb create mode 100644 config/hiera.yaml create mode 100644 docs/faq.md create mode 100644 docs/modules.md create mode 100644 docs/personal-configuration.md create mode 100644 docs/puppet.md create mode 100644 docs/rails.md create mode 100644 hiera/common.yaml.example create mode 100644 hiera/users/hanjianwei.yaml create mode 100644 lib/.gitkeep create mode 100644 manifests/site.pp create mode 100644 modules/people/README.md create mode 100644 modules/people/manifests/.gitkeep create mode 100644 modules/people/manifests/hanjianwei.pp create mode 100644 modules/people/manifests/hanjianwei/applications.pp create mode 100644 modules/people/manifests/hanjianwei/config.pp create mode 100644 modules/people/manifests/hanjianwei/mirrors.pp create mode 100644 modules/people/manifests/hanjianwei/osx.pp create mode 100644 modules/people/manifests/hanjianwei/repositories.pp create mode 100644 modules/projects/README.md create mode 100644 modules/projects/manifests/.gitkeep create mode 100644 modules/projects/manifests/all.pp create mode 100644 modules/projects/templates/shared/nginx.conf.erb create mode 100755 script/bootstrap create mode 100755 script/boxen create mode 100755 script/boxen-bootstrap create mode 100755 script/boxen-git-credential create mode 100755 script/boxen-my-config create mode 100755 script/nuke create mode 100755 script/sync create mode 100644 shared/README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..25d26b4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +/.bundle +/.librarian +/.projects +/.snapshot +/.tmp +/bin +/config/local.rb +/log +/tmp +/shared/* +!/shared/README.md +/vendor/ diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..bec3a35 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +system diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..0a21964 --- /dev/null +++ b/Gemfile @@ -0,0 +1,18 @@ +source "http://mirrors.aliyun.com/rubygems/" + +gem "boxen", "~> 2.6" +gem "hiera", "~> 1.3.3" +gem "librarian-puppet", "~> 1.0.2" +gem "puppet", "3.6.1" +gem "puppet-lint", "0.3.2" +gem "puppetlabs_spec_helper", "0.4.1" +gem "open4", "~> 1.3.4" +gem "rake", "10.3.2" +gem "rspec-puppet", "1.0.1" +gem "deep_merge", "~> 1.0" + +group :development do + gem "aws-sdk", "~> 1.42" + gem "net-ssh" + gem "rbvmomi" +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..673ee8f --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,100 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (2.2.8) + addressable (2.3.6) + ansi (1.4.3) + aws-sdk (1.42.0) + json (~> 1.4) + nokogiri (>= 1.4.4) + boxen (2.6.0) + ansi (~> 1.4) + hiera (~> 1.0) + highline (~> 1.6) + json_pure (>= 1.7.7, < 2.0) + librarian-puppet (~> 1.0.0) + octokit (~> 2.7, >= 2.7.1) + puppet (~> 3.0) + builder (3.2.2) + deep_merge (1.0.1) + diff-lcs (1.2.5) + facter (2.0.1) + CFPropertyList (~> 2.2.6) + faraday (0.9.0) + multipart-post (>= 1.2, < 3) + hiera (1.3.3) + json_pure + highline (1.6.21) + json (1.8.1) + json_pure (1.8.1) + librarian (0.1.2) + highline + thor (~> 0.15) + librarian-puppet (1.0.2) + json + librarian (>= 0.1.2) + metaclass (0.0.4) + mini_portile (0.6.0) + mocha (1.1.0) + metaclass (~> 0.0.1) + multipart-post (2.0.0) + net-ssh (2.9.1) + nokogiri (1.6.2.1) + mini_portile (= 0.6.0) + octokit (2.7.2) + sawyer (~> 0.5.2) + open4 (1.3.4) + puppet (3.6.1) + facter (> 1.6, < 3) + hiera (~> 1.0) + json_pure + rgen (~> 0.6.5) + puppet-lint (0.3.2) + puppetlabs_spec_helper (0.4.1) + mocha (>= 0.10.5) + rake + rspec (>= 2.9.0) + rspec-puppet (>= 0.1.1) + rake (10.3.2) + rbvmomi (1.8.1) + builder + nokogiri (>= 1.4.1) + trollop + rgen (0.6.6) + rspec (3.0.0) + rspec-core (~> 3.0.0) + rspec-expectations (~> 3.0.0) + rspec-mocks (~> 3.0.0) + rspec-core (3.0.0) + rspec-support (~> 3.0.0) + rspec-expectations (3.0.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.0.0) + rspec-mocks (3.0.0) + rspec-support (~> 3.0.0) + rspec-puppet (1.0.1) + rspec + rspec-support (3.0.0) + sawyer (0.5.4) + addressable (~> 2.3.5) + faraday (~> 0.8, < 0.10) + thor (0.19.1) + trollop (2.0) + +PLATFORMS + ruby + +DEPENDENCIES + aws-sdk (~> 1.42) + boxen (~> 2.6) + deep_merge (~> 1.0) + hiera (~> 1.3.3) + librarian-puppet (~> 1.0.2) + net-ssh + open4 (~> 1.3.4) + puppet (= 3.6.1) + puppet-lint (= 0.3.2) + puppetlabs_spec_helper (= 0.4.1) + rake (= 10.3.2) + rbvmomi + rspec-puppet (= 1.0.1) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0d87659 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2012 GitHub, Inc. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Puppetfile b/Puppetfile new file mode 100644 index 0000000..ac27b76 --- /dev/null +++ b/Puppetfile @@ -0,0 +1,61 @@ +# This file manages Puppet module dependencies. +# +# It works a lot like Bundler. We provide some core modules by +# default. This ensures at least the ability to construct a basic +# environment. + +# Shortcut for a module from GitHub's boxen organization +def github(name, *args) + options ||= if args.last.is_a? Hash + args.last + else + {} + end + + if path = options.delete(:path) + mod name, :path => path + else + version = args.first + options[:repo] ||= "boxen/puppet-#{name}" + mod name, version, :github_tarball => options[:repo] + end +end + +# Shortcut for a module under development +def dev(name, *args) + mod name, :path => "#{ENV['HOME']}/src/boxen/puppet-#{name}" +end + +# Includes many of our custom types and providers, as well as global +# config. Required. + +github "boxen", "3.6.1" + +# Support for default hiera data in modules + +github "module-data", "0.0.3", :repo => "ripienaar/puppet-module-data" + +# Core modules for a basic development environment. You can replace +# some/most of these if you want, but it's not recommended. + +github "dnsmasq", "1.0.1" +github "gcc", "2.0.101" +github "git", "2.4.0" +github "homebrew", "1.9.4.rc", :repo => "hanjianwei/puppet-homebrew" +github "hub", "1.3.0" +github "inifile", "1.0.3", :repo => "puppetlabs/puppetlabs-inifile" +github "nginx", "1.4.3" +github "nodejs", "3.7.0" +github "openssl", "1.0.0" +github "pkgconfig", "1.0.0" +github "repository", "2.3.0" +github "ruby", "8.0.4" +github "stdlib", "4.2.1", :repo => "puppetlabs/puppetlabs-stdlib" +github "sudo", "1.0.0" +github "xquartz", "1.1.1" + +# Optional/custom modules. There are tons available at +# https://github.com/boxen. +github "osx", "2.7.0" +github "property_list_key", "0.2.1", :repo => "glarizza/puppet-property_list_key" +github "brewcask", "0.0.4.rc2", :repo => "hanjianwei/puppet-brewcask" diff --git a/Puppetfile.lock b/Puppetfile.lock new file mode 100644 index 0000000..12b3fff --- /dev/null +++ b/Puppetfile.lock @@ -0,0 +1,122 @@ +GITHUBTARBALL + remote: boxen/puppet-boxen + specs: + boxen (3.6.1) + +GITHUBTARBALL + remote: boxen/puppet-dnsmasq + specs: + dnsmasq (1.0.1) + +GITHUBTARBALL + remote: boxen/puppet-gcc + specs: + gcc (2.0.101) + +GITHUBTARBALL + remote: boxen/puppet-git + specs: + git (2.4.0) + +GITHUBTARBALL + remote: boxen/puppet-hub + specs: + hub (1.3.0) + +GITHUBTARBALL + remote: boxen/puppet-nginx + specs: + nginx (1.4.3) + +GITHUBTARBALL + remote: boxen/puppet-nodejs + specs: + nodejs (3.7.0) + +GITHUBTARBALL + remote: boxen/puppet-openssl + specs: + openssl (1.0.0) + +GITHUBTARBALL + remote: boxen/puppet-osx + specs: + osx (2.7.0) + +GITHUBTARBALL + remote: boxen/puppet-pkgconfig + specs: + pkgconfig (1.0.0) + +GITHUBTARBALL + remote: boxen/puppet-repository + specs: + repository (2.3.0) + +GITHUBTARBALL + remote: boxen/puppet-ruby + specs: + ruby (8.0.4) + +GITHUBTARBALL + remote: boxen/puppet-sudo + specs: + sudo (1.0.0) + +GITHUBTARBALL + remote: boxen/puppet-xquartz + specs: + xquartz (1.1.1) + +GITHUBTARBALL + remote: glarizza/puppet-property_list_key + specs: + property_list_key (0.2.1) + +GITHUBTARBALL + remote: hanjianwei/puppet-brewcask + specs: + brewcask (0.0.4.rc2) + +GITHUBTARBALL + remote: hanjianwei/puppet-homebrew + specs: + homebrew (1.9.4.rc) + +GITHUBTARBALL + remote: puppetlabs/puppetlabs-inifile + specs: + inifile (1.0.3) + +GITHUBTARBALL + remote: puppetlabs/puppetlabs-stdlib + specs: + stdlib (4.2.1) + +GITHUBTARBALL + remote: ripienaar/puppet-module-data + specs: + module-data (0.0.3) + +DEPENDENCIES + boxen (= 3.6.1) + brewcask (= 0.0.4.rc2) + dnsmasq (= 1.0.1) + gcc (= 2.0.101) + git (= 2.4.0) + homebrew (= 1.9.4.rc) + hub (= 1.3.0) + inifile (= 1.0.3) + module-data (= 0.0.3) + nginx (= 1.4.3) + nodejs (= 3.7.0) + openssl (= 1.0.0) + osx (= 2.7.0) + pkgconfig (= 1.0.0) + property_list_key (= 0.2.1) + repository (= 2.3.0) + ruby (= 8.0.4) + stdlib (= 4.2.1) + sudo (= 1.0.0) + xquartz (= 1.1.1) + diff --git a/README.md b/README.md new file mode 100644 index 0000000..5d6f4e0 --- /dev/null +++ b/README.md @@ -0,0 +1,318 @@ +# Our Boxen + +This is a template Boxen project designed for your organization to fork and +modify appropriately. +The Boxen rubygem and the Boxen puppet modules are only a framework for getting +things done. +This repository template is just a basic example of _how_ to do things with them. + +## Getting Started + +To give you a brief overview, we're going to: + +* Install dependencies (basically Xcode) +* Bootstrap a boxen for your self/team/org/company +* Then convert your local copy of that boxen to the post-bootstrapped version + +There are a few potential conflicts to keep in mind. +Boxen does its best not to get in the way of a dirty system, +but you should check into the following before attempting to install your +boxen on any machine (we do some checks before every Boxen run to try +and detect most of these and tell you anyway): + +* Boxen __requires__ at least the Xcode Command Line Tools installed. +* Boxen __will not__ work with an existing rvm install. +* Boxen __may not__ play nice with a GitHub username that includes dash(-) +* Boxen __may not__ play nice with an existing rbenv install. +* Boxen __may not__ play nice with an existing chruby install. +* Boxen __may not__ play nice with an existing homebrew install. +* Boxen __may not__ play nice with an existing nvm install. +* Boxen __recommends__ installing the full Xcode. + +### Dependencies + +**Install the Xcode Command Lines Tools and/or full Xcode.** +This will grant you the most predictable behavior in building apps like +MacVim. + +How do you do it? + +#### OS X 10.9 (Mavericks) + +If you are using [`b26abd0` of boxen-web](https://github.com/boxen/boxen-web/commit/b26abd0d681129eba0b5f46ed43110d873d8fdc2) +or newer, it will be automatically installed as part of Boxen. +Otherwise, follow instructions below. + +#### OS X < 10.9 + +1. Install Xcode from the Mac App Store. +1. Open Xcode. +1. Open the Preferences window (`Cmd-,`). +1. Go to the Downloads tab. +1. Install the Command Line Tools. + +### Bootstrapping + +Create a **new** git repository somewhere on the internet. +It can be private or public -- it really doesn't matter. +If you're making a repository on GitHub, you _may not_ want to fork this repo +to get started. +The reason for that is that you can't really make private forks of public +repositories easily. + +Once you've done that, you can run the following to bootstrap +your boxen: + +``` +sudo mkdir -p /opt/boxen +sudo chown ${USER}:staff /opt/boxen +git clone https://github.com/boxen/our-boxen /opt/boxen/repo +cd /opt/boxen/repo +git remote rm origin +git remote add origin +git push -u origin master +``` + +Now that your boxen is bootstrapped, you can run the following to +install the default configuration from this repo: + +``` +cd /opt/boxen/repo +./script/boxen +``` + +### Distributing + +That's enough to get your boxen into a usable state on other machines, +usually. +From there, we recommend setting up +[boxen-web](https://github.com/boxen/boxen-web) +as an easy way to automate letting other folks install your boxen. + +If you _don't_ want to use boxen-web, folks can get using your boxen like so: + +``` +sudo mkdir -p /opt/boxen +sudo chown ${USER}:staff /opt/boxen +git clone /opt/boxen/repo +cd /opt/boxen/repo +./script/boxen +``` + +Keep in mind this requires you to encrypt your hard drive by default. +If you do not want to do encrypt your hard drive, you can use the `--no-fde`. + +``` +./script/boxen --no-fde +``` + +It should run successfully, and should tell you to source a shell script +in your environment. +For users without a bash or zsh config or a `~/.profile` file, +Boxen will create a shim for you that will work correctly. +If you do have a `~/.bashrc` or `~/.zshrc`, your shell will not use +`~/.profile` so you'll need to add a line like so at _the end of your config_: + +``` sh +[ -f /opt/boxen/env.sh ] && source /opt/boxen/env.sh +``` + +Once your shell is ready, open a new tab/window in your Terminal +and you should be able to successfully run `boxen --env`. +If that runs cleanly, you're in good shape. + +## What You Get + +This template project provides the following by default: + +* Homebrew +* Git +* Hub +* dnsmasq w/ .dev resolver for localhost +* rbenv +* Full Disk Encryption requirement +* Node.js 0.6 +* Node.js 0.8 +* Node.js 0.10 +* Ruby 1.9.3 +* Ruby 2.0.0 +* Ruby 2.1.0 +* Ruby 2.1.1 +* ack +* Findutils +* GNU tar + +## Customizing + +You can always check out the number of existing modules we already +provide as optional installs under the +[boxen organization](https://github.com/boxen). These modules are all +tested to be compatible with Boxen. Use the `Puppetfile` to pull them +in dependencies automatically whenever `boxen` is run. + +### Including boxen modules from github (boxen/puppet-) + +You must add the github information for your added Puppet module into your Puppetfile at the root of your +boxen repo (ex. /path/to/your-boxen/Puppetfile): + + # Core modules for a basic development environment. You can replace + # some/most of these if you want, but it's not recommended. + + github "repository", "2.0.2" + github "dnsmasq", "1.0.0" + github "gcc", "1.0.0" + github "git", "1.2.2" + github "homebrew", "1.1.2" + github "hub", "1.0.0" + github "inifile", "0.9.0", :repo => "cprice404/puppetlabs-inifile" + github "nginx", "1.4.0" + github "nodejs", "2.2.0" + github "ruby", "4.1.0" + github "stdlib", "4.0.2", :repo => "puppetlabs/puppetlabs-stdlib" + github "sudo", "1.0.0" + + # Optional/custom modules. There are tons available at + # https://github.com/boxen. + + github "java", "1.1.0" + +In the above snippet of a customized Puppetfile, the bottom line +includes the Java module from Github using the tag "1.1.0" from the github repository +"boxen/puppet-java". The function "github" is defined at the top of the Puppetfile +and takes the name of the module, the version, and optional repo location: + + def github(name, version, options = nil) + options ||= {} + options[:repo] ||= "boxen/puppet-#{name}" + mod name, version, :github_tarball => options[:repo] + end + +Now Puppet knows where to download the module from when you include it in your site.pp or mypersonal.pp file: + + # include the java module referenced in my Puppetfile with the line + # github "java", "1.1.0" + include java + +### Hiera + +Hiera is preferred mechanism to make changes to module defaults (e.g. default +global ruby version, service ports, etc). This repository supplies a +starting point for your Hiera configuration at `config/hiera.yml`, and an +example data file at `hiera/common.yaml`. See those files for more details. + +The default `config/hiera.yml` is configured with a hierarchy that allows +individuals to have their own hiera data file in +`hiera/users/{github_login}.yaml` which augments and overrides +site-wide values in `hiera/common.yaml`. This default is, as with most of the +configuration in the example repo, a great starting point for many +organisations, but is totally up to you. You might want to, for +example, have a set of values that can't be overridden by adding a file to +the top of the hierarchy, or to have values set on specific OS +versions: + +```yaml +# ... +:hierarchy: + - "global-overrides.yaml" + - "users/%{::github_login}" + - "osx-%{::macosx_productversion_major}" + - common +``` + +### Node definitions + +Puppet has the concept of a +['node'](http://docs.puppetlabs.com/references/glossary.html#agent), +which is essentially the machine on which Puppet is running. Puppet looks for +[node definitions](http://docs.puppetlabs.com/learning/agent_master_basic.html#node-definitions) +in the `manifests/site.pp` file in the Boxen repo. You'll see a default node +declaration that looks like the following: + +``` puppet +node default { + # core modules, needed for most things + include dnsmasq + + # more... +} +``` + +### How Boxen interacts with Puppet + +Boxen runs everything declared in `manifests/site.pp` by default. +But just like any other source code, throwing all your work into one massive +file is going to be difficult to work with. Instead, we recommend you +use modules in the `Puppetfile` when you can and make new modules +in the `modules/` directory when you can't. Then add `include $modulename` +for each new module in `manifests/site.pp` to include them. +One pattern that's very common is to create a module for your organization +(e.g., `modules/github`) and put an environment class in that module +to include all of the modules your organization wants to install for +everyone by default. An example of this might look like so: + +``` puppet +# modules/github/manifests/environment.pp + + class github::environment { + include github::apps::mac + + include ruby::1-8-7 + + include projects::super-top-secret-project + } +``` + + If you'd like to read more about how Puppet works, we recommend + checking out [the official documentation](http://docs.puppetlabs.com/) + for: + + * [Modules](http://docs.puppetlabs.com/learning/modules1.html#modules) + * [Classes](http://docs.puppetlabs.com/learning/modules1.html#classes) + * [Defined Types](http://docs.puppetlabs.com/learning/definedtypes.html) + * [Facts](http://docs.puppetlabs.com/guides/custom_facts.html) + +### Creating a personal module + +See [the documentation in the +`modules/people`](modules/people/README.md) +directory for creating per-user modules that don't need to be applied +globally to everyone. + +### Creating a project module + +See [the documentation in the +`modules/projects`](modules/projects/README.md) +directory for creating organization projects (i.e., repositories that people +will be working in). + +## Binary packages + +We support binary packaging for everything in Homebrew, rbenv, and nvm. +See `config/boxen.rb` for the environment variables to define. + +## Sharing Boxen Modules + +If you've got a Boxen module you'd like to be grouped under the Boxen org, +(so it can easily be found by others), please file an issue on this +repository with a link to your module. +We'll review the code briefly, and if things look pretty all right, +we'll fork it under the Boxen org and give you read+write access to our +fork. +You'll still be the maintainer, you'll still