LoginSignup
2
2

More than 5 years have passed since last update.

Chef Soloをインストールしてsshdのポート番号を変更するまでメモ

Last updated at Posted at 2015-04-13

環境

  • CentOS 7 on Win7(VMWare Player)

手順

事前準備
# yum install git
# yum install ruby-devel 
chef-soloインストール
# curl -L https://www.opscode.com/chef/install.sh | bas h
# gem insall chef
# git clone git://github.com/opscode/chef-repo.git
# knife configure
クックブック作成
# knife cookbooks/ create sshdconfig -o cookbooks/
※sshd_configファイルをsshd_config.erbとして「sshdconfig/templates/default」ディレクトリ名に配置。ポート番号を変更(例:12345)
# vim sshd_config.erb
Port 12345
# vim cookbooks/sshdconfig/recipes/default.rb
service "sshd" do
     supports :status => true, :restart => true, :reload => true
     action [ :enable, :start ]
 end

template "sshd_config" do
    path "/etc/ssh/sshd_config"
    source "sshd_config.erb"
    user "root"
    group "root"
    mode "600"
    notifies :reload, "service[sshd]"
end
ChefSoloの実行準備と実行
# vim localhost.json
{
        "run_list" : [
                "recipe[sshdconfig]"
        ]
}
# vim solo.rb
file_cache_pacht "/tmp/chef-solo"
cookbook_path ["/var/chef/cookbooks"]
# chef-solo -c solo.rb -j localhost.json

ポートが変わっていることを確認して終わり。

参考

chefでsshd_configを設定する | はじめるの終わり http://blog.pseudepigrapha.net/vagrant/chef%E3%81%A7sshd_config/

入門Chef Solo - Infrastructure as Code
伊藤直也 (2013-03-11)
売り上げランキング: 3,040
2
2
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
2
2