{"id":12881,"date":"2013-04-09T08:00:14","date_gmt":"2013-04-08T23:00:14","guid":{"rendered":"http:\/\/www.sssg.org\/blogs\/hiro345\/?p=12881"},"modified":"2013-04-09T15:50:28","modified_gmt":"2013-04-09T06:50:28","slug":"chef-solo-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6-ntpd-%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab","status":"publish","type":"post","link":"https:\/\/www.hiro345.net\/blogs\/hiro345\/archives\/12881.html","title":{"rendered":"chef-solo \u3092\u4f7f\u3063\u3066 ntpd \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb"},"content":{"rendered":"<p>CentOS6.4 \u3067 Ruby1.9.3, RubyGems \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3042\u308b\u74b0\u5883\u3067\u3001chef-solo \u3092\u4f7f\u3063\u3066 ntpd \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n<!--more--><br \/>\n\u3053\u3053\u3067\u306f\u3001chef, knife-solo \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3068\u3053\u308d\u304b\u3089\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u542b\u3081\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\n#! \/bin\/sh\r\nruby=ruby-1.9.3-p392\r\nrubygems=rubygems-2.0.3\r\n\r\n\/usr\/local\/ruby\/${ruby}\/bin\/gem install chef knife-solo\r\n\r\nmkdir -p $HOME\/chef-solo\/cookbooks\r\n\r\ncat &gt; $HOME\/chef-solo\/solo.rb  &lt;&lt;EOF\r\nfile_cache_path &quot;\/tmp\/chef-solo&quot;\r\ncookbook_path   &quot;\/root\/chef-solo\/cookbooks&quot;\r\nEOF\r\n\r\ncat &gt; $HOME\/chef-solo\/chef.json &lt;&lt;EOF\r\n{\r\n  &quot;run_list&quot;: [ &quot;recipe[ntp]&quot; ]\r\n}\r\nEOF\r\n\r\n\/usr\/local\/ruby\/${ruby}\/bin\/knife cookbook create ntp -o $HOME\/chef-solo\/cookbooks\r\n\r\ncat &gt; $HOME\/chef-solo\/cookbooks\/ntp\/recipes\/default.rb &lt;&lt;EOF\r\n# Cookbook Name:: ntp\r\n# Recipe:: default\r\npackage &quot;ntp&quot; do\r\n  action :install\r\nend\r\n \r\nservice &quot;ntpd&quot; do\r\n  supports :status =&gt; true, :restart =&gt; true\r\n  action [ :enable, :start ]\r\nend\r\n \r\ntemplate &quot;\/etc\/ntp.conf&quot; do\r\n  source &quot;ntp.conf&quot;\r\n  group &quot;root&quot;\r\n  owner &quot;root&quot;\r\n  mode &quot;400&quot;\r\n  notifies :restart, &quot;service[ntpd]&quot;\r\nend\r\nEOF\r\n\r\ncat &gt; $HOME\/chef-solo\/cookbooks\/ntp\/templates\/default\/ntp.conf &lt;&lt;EOF\r\ndriftfile \/var\/lib\/ntp\/drift\r\nrestrict default kod nomodify notrap nopeer noquery\r\nrestrict -6 default kod nomodify notrap nopeer noquery\r\nrestrict 127.0.0.1 \r\nrestrict -6 ::1\r\nserver -4 ntp.nict.jp iburst\r\nserver -4 ntp.nict.jp iburst\r\nserver -4 ntp.nict.jp iburst\r\nincludefile \/etc\/ntp\/crypto\/pw\r\nkeys \/etc\/ntp\/keys\r\nEOF\r\n\r\n\/usr\/local\/ruby\/${ruby}\/bin\/chef-solo -c $HOME\/chef-solo\/solo.rb -j $HOME\/chef-solo\/chef.json\r\n<\/pre>\n<p>\u6700\u5f8c\u306e\u884c\u3067\u3001chef-solo\u3092\u5b9f\u884c\u3057\u3066\u30ec\u30b7\u30d4\u3092\u9069\u7528\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b\u3001\u4f5c\u6210\u3057\u305f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u69cb\u6210\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\n\/root\/chef-solo\/\r\n|-- chef.json\r\n|-- cookbooks\r\n|   `-- ntp\r\n|       |-- CHANGELOG.md\r\n|       |-- README.md\r\n|       |-- attributes\r\n|       |-- definitions\r\n|       |-- files\r\n|       |   `-- default\r\n|       |-- libraries\r\n|       |-- metadata.rb\r\n|       |-- providers\r\n|       |-- recipes\r\n|       |   `-- default.rb\r\n|       |-- resources\r\n|       `-- templates\r\n|           `-- default\r\n|               `-- ntp.conf\r\n`-- solo.rb\r\n<\/pre>\n<p>$HOME\/chef-solo\/cookbooks \u306b\u30ec\u30b7\u30d4\u3092\u8ffd\u52a0\u3057\u3066\u3044\u3063\u3066\u3001$HOME\/chef-solo\/chef.json \u306b\u5b9f\u884c\u3059\u308b\u30ec\u30b7\u30d4\u3092\u8a18\u8f09\u3057\u3066\u3001\u300cchef-solo -c .\/solo.rb -j .\/chef.json\u300d\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u540c\u3058\u74b0\u5883\u304c\u3069\u3053\u3067\u3082\u7528\u610f\u3067\u304d\u308b\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CentOS6.4 \u3067 Ruby1.9.3, RubyGems \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3042\u308b\u74b0\u5883\u3067\u3001chef-solo \u3092\u4f7f\u3063\u3066 ntpd \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[26,653,837,839,1209],"class_list":["post-12881","post","type-post","status-publish","format-standard","hentry","category-linux","tag-centos","tag-centos6","tag-centos6-4","tag-chef-solo","tag-linux"],"_links":{"self":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/12881","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/comments?post=12881"}],"version-history":[{"count":3,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/12881\/revisions"}],"predecessor-version":[{"id":12902,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/12881\/revisions\/12902"}],"wp:attachment":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/media?parent=12881"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/categories?post=12881"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/tags?post=12881"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}