【Chef Tips 2】SSHサーバの設定(ssh_config)
sshd_configを編集する場合にも、カーネルパラメータのときと同様、ruby_block+FileEditユーティリティが役立つ。
sshd_configでは、デフォルト値がコメントアウトで記述されている。その為、レシピでは、このコメントアウトされている対象のパラメタを探し、設定したい内容に置き換え、最後にリロードする。
ruby_block "Edit /etc/sshd_config" do block do rc = Chef::Util::FileEdit.new("/etc/sshd_config") rc.search_file_replace_line(/^#ChallengeResponseAuthentication.*$/, "ChallengeResponseAuthentication no" rc.write_file end notifies :reload, "service[sshd]" end service "sshd" do supports :reload => true action :nothing end |
■ ポイント