LoginSignup
4
4

More than 5 years have passed since last update.

今日作りたくなる簡単cookbook [Kim'sキッチン] jq

Posted at

以下全ても●みち風に書いたメモ

皆さんおはようございます。
ryurock@githubです。

フガすけ(14歳)
jsonの表示を整形するjqを入れたいっす

今日はそんなjqを簡単なcookbookをknife-soloでご紹介したいと思います。

レシピ作成時間

約2分

環境

  • mac-osx(ホストOS)
  • centos6.4-x86-minimal (ゲストOS)

事前準備に必要なもの

参考にしたサイト(書籍)

[その1] レシピ名を決める

今回のレシピ名はjqで行きましょう

cd chef-repo
knife cookbook create jq -o site-cookbooks

[その2] chef-repo/jq/recipes/default.rbを編集

chef-repo/jq/recipes/default.rb
git "/tmp/jq" do
  repository "git://github.com/stedolan/jq.git"
  reference "master"
  action :checkout
  user "root"
  group "root"
  notifies :run, 'execute[jq_make_install]', :immediately
end

# install
execute "jq_make_install" do
  cwd "/tmp/jq"
  command "./configure; make; make install"
  action :nothing
end

[その4]rbenv cookbookをリモート側で実行する設定を追加

vim chef-repo/nodes/{接続名称(任意)}.json

{"run_list":[
        "jq"
]}

run_listをすでに記載している場合は追記でお願いします。
またrbenvのインストールのみで問題ないならrbenvだけでも問題ないです。

[その5] リモート側に実行依頼をする

cd chef-repo
knife solo cook {接続名称(任意)}

今日はこれで決まり「jq」の完成です

resource notificationを使った簡単なサンプルです

使ったChef Resources


4
4
0

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
4
4