概要
自作CookbookをGitHubに公開し、berkshelfで再利用する
詳細
自作CookbookをGitHubに公開し、berkshelfで再利用します。
下記記事で作成したbash_profileを設定するためのクックブックをGitHubに登録しました。
cookbook_fileでファイルを配置
http://d.hatena.ne.jp/tbpg/20131031/1383231038
手順
$ mkdir self_made_cookbook $ cd self_made_cookbook $ vagrant init $ knife solo init . $ cat <<EOF> Berksfile >site :opscode > >cookbook 'bash_profile', git: 'https://github.com/tbpgr/bash_profile.git' >EOF $ vi Vagrantfile # 詳細は後述 # data_bagsにユーザー情報を設定。詳細は後述 $ berks install --path cookbooks $ vagrant up $ vagrant ssh vagrant@precise64:~$ cat .bash_profile export LANG="ja_JP.UTF-8" alias ll='ls -l' alias ls='ls -F --color=auto --show-control-char' alias vi='vim'
data_bags
{ "id" : "vagrant", "name" : "vagrant", "group" : "vagrant", "password" : "vagrant" }
Vagrantfile
# -*- mode: ruby -*- # vi: set ft=ruby : # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "ubuntu-12.04-x64" config.vm.network :private_network, ip: "192.168.33.18" config.omnibus.chef_version = "11.6.0" config.ssh.username = "vagrant" config.berkshelf.enabled = false config.vm.provision :chef_solo do |chef| chef.cookbooks_path = ["./cookbooks", "./site-cookbooks"] chef.data_bags_path = "data_bags" chef.run_list = [ "bash_profile" ] end end