ao-log

インフラ系ITエンジニアのメモ帳です。

Amazon linux に Chef で Fluentd をインストールする

ここを参考にした。
https://github.com/treasure-data/chef-td-agent

少しハマったのが、レシピの platform に amazon が書かれていないので、それを追加するところですね。

以下、手順です。

td-agent の cookbook を追加。

$ /opt/chef/embedded/bin/gem install knife-github-cookbooks
$ cd chef-repo
$ knife cookbook github install treasure-data/chef-td-agent

レシピのplatformにamazon追加。これをしないと、リポジトリが追加されず、yum でパッケージがインストールされない。

$ cat cookbooks/td-agent/recipes/default.rb
...(省略)
case node['platform']
when "ubuntu"
...(省略)
when "centos", "redhat", "amazon"
  yum_repository "treasure-data" do
    url "http://packages.treasure-data.com/redhat/$basearch"
    action :add
  end
end
...(省略)

apt と yum の cookbook も必要なので追加。

$ knife cookbook github install opscode-cookbooks/apt
$ knife cookbook github install opscode-cookbooks/yum

JSON ファイルを修正。

$ cat nodes/localhost.json
{
     "run_list":[
          "recipe[td-agent]"
     ]
}

knife solo 実行。

$ knife solo cook localhost