33
33

More than 5 years have passed since last update.

ぼっちでBoxenを使って環境構築してみた

Last updated at Posted at 2013-11-06

新しくMacbookを買ったので、良い機会なのでやってみました。

だいたいこの通りにやっていく

やること

  • xcode + command line toolをインストールする
  • boxen用ディレクトリを作る(デフォルトは/opt/boxen)
  • our-boxenをcloneする
  • Puppetfileにインストールしたいもの一覧を定義する
  • site.ppに全体に適用する(インストールする)ものをincludeなどで書く
  • {自分のgithub account名}.pp に個人用設定を書く
  • インストール

our-boxenのclone

mkdir -p ~/src/my-boxen 
cd ~/src/my-boxen
git init
git remote add upstream https://github.com/boxen/our-boxen
git pull upstream master

Puppetfile

ここにインストールするものを定義していきます。
Puppetfileは定義、 *.ppは実際のインストールで使うもの、という感じです。

外部からインストールするものがある場合、まずPuppetfileそれを書いていきます。

とりあえずデフォルトでinstallされるのは

  • Homebrew
  • Git
  • Hub
  • dnsmasq w/ .dev resolver for localhost
  • rbenv
  • Full Disk Encryption requirement
  • Node.js 0.4
  • Node.js 0.6
  • Node.js 0.8
  • Ruby 1.8.7
  • Ruby 1.9.2
  • Ruby 1.9.3
  • Ruby 2.0.0
  • ack
  • Findutils
  • GNU tar

だそうです

Puppetfileに書いてあるのがこれ↓

この下に自分のインストールしたいものを書いていく。

# Includes many of our custom types and providers, as well as global
# config. Required.

github "boxen", "3.3.4"

# 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.0"
github "foreman",    "1.0.0"
github "gcc",        "2.0.1"
github "git",        "1.2.5"
github "go",         "1.0.0"
github "homebrew",   "1.5.1"
github "hub",        "1.0.3"
github "inifile",    "1.0.0", :repo => "puppetlabs/puppetlabs-inifile"
github "nginx",      "1.4.2"
github "nodejs",     "3.3.0"
github "openssl",    "1.0.0"
github "phantomjs",  "2.0.2"
github "pkgconfig",  "1.0.0"
github "repository", "2.2.0"
github "ruby",       "6.7.2"
github "stdlib",     "4.1.0", :repo => "puppetlabs/puppetlabs-stdlib"
github "sudo",       "1.0.0"
github "xquartz",    "1.1.0"

# Optional/custom modules. There are tons available at
# https://github.com/boxen.

インストールに使えるのは、githubのboxen organizationにあるpuppet-*という名前のリポジトリか、個人で作っている人もいるのでそれを使うこともできるっぽいです。

こんなふうに書きました。
* ちなみに、横のversion指定はgithub repoのtagです。(わからなかった)

# Optional/custom modules. There are tons available at
# https://github.com/boxen.
github "mysql",       "1.1.5"
github "chrome",      "1.1.2"
github "redis",       "1.1.0"
github "imagemagick", "1.2.1"
github "alfred",      "1.1.6"
github "sequel_pro",  "1.0.0"

もっといるかも

*.pp

Puppetファイルは外部リソースの定義をするだけなので、次にインストールのための設定を書いていく。

site.ppにdefaultでnodeとrubyが入るように設定が書かれているが、古いものはいらないのでコメントアウト

manifests/site.pp

node default {
  # core modules, needed for most things
  include dnsmasq
  include git
  include hub
  include nginx

  # fail if FDE is not enabled
  if $::root_encrypted == 'no' {
    fail('Please enable full disk encryption and try again')
  }
  # 古いものをコメントアウト
  # node versions
  # include nodejs::v0_4
  # include nodejs::v0_6
  # include nodejs::v0_8
  include nodejs::v0_10

  # default ruby versions
  # include ruby::1_8_7
  # include ruby::1_9_2
  # include ruby::1_9_3
  include ruby::2_0_0

  # common, useful packages
  package {
    [
      'ack',
      'findutils',
      'gnu-tar'
    ]:
  }

  file { "${boxen::config::srcdir}/our-boxen":
    ensure => link,
    target => $boxen::config::repodir
  }
}

で、ここから個人設定。
自分のgithubアカウント名.ppファイルをmanifests/以下に作成するとそれが読み込まれる。

ボクの場合はtak0303.pp
置き場所はsite.ppとは違い, modules/manifests/people(間違えた)

modules/people/tak0303.pp
# Class: people::tak0303
#
#
class people::tak0303 {
  # ここに、Puppetfileで定義したものの中から必要なものをincludeする
  # include your files...
  include chrome::canary
  include mysql
  include redis
  include imagemagick
  include alfred
  include sequel_pro

  # macアプリとかインストールできる
  # けど今回やってない
  # package {
  #  'Kobito':
  #    source   => "http://kobito.qiita.com/download/Kobito_v1.8.2.zip",
  #    provider => compressed_app;
  #}
}

こんな感じに書いていく。

インストール

実行は簡単で

script/boxen --no-fde

これを自分のboxen ディレクトリで実行するだけ
--no-fdeを使うと暗号化をしません、macはデフォルトでは暗号化を行ってないので、これでいいですが、グループで使うときや会社用には暗号化がいると思います。

その後、zshrcなりbashrcに

[ -f /opt/boxen/env.sh ] && source /opt/boxen/env.sh

これを書けば終わり。

すごくシンプルというか、全然設定を書いていません(書けていません)

githubに公開してしまったので、もしおすすめの設定とかあればPRお願いします!!全然設定はしていませんがこのままpullしてもらっても使えます!!!!!!!よろしくお願いします!!!!!!

https://github.com/tak0303/my-boxen

追記

  • インストール後に追加でインストールするものを追記したとき
boxen --no-fde # --no-fdeいらない人はとる

で更新できます。

  • アンインストールしたいとき
 /opt/boxen/repo/script/nuke --all --force
33
33
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
33
33