- 更新日: 2014年7月16日
- Vagrant & Chef
Chefでサービス(デーモン)の稼働と停止をchkconfigで設定
今日の Chef のお題はこちら。必要なサービス(デーモン)の可動と不要なサービスの停止を、chkconfig コマンドを用いて設定します。
不要なパッケージのアンインストール・不要なサービスの停止 〜 CentOS6 | EasyRamble
このエントリーは、CentOS サーバー設定用 Chef Cookbook/Recipe の目次 の一部です。
chkconfig を使ってサービスの稼働と停止を設定する Recipe
site-cookbooks/base_cookbook/recipes/chkconfig_services.rb
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | # -------------------------------------------------- # install necessary services # chkconfig service on # -------------------------------------------------- # other services that might be needed # abrt # ... install_services = %w[   irqbalance   portreserve   sysstat ] install_services.each do |pkg|   package pkg do     action :install   end end on_services = %w[   restorecond   saslauthd ] (install_services + on_services).each do |service|   bash "start_#{service}_service" do     only_if "chkconfig --list | grep #{service} | grep 3:off"     code <<-EOC       chkconfig #{service} on     EOC   end end # -------------------------------------------------- # chkconfig service off # -------------------------------------------------- off_services = %w[   blk-availability   bluetooth   certmonger   cpuspeed   cups   haldaemon   ip6tables   iscsi   iscsid   lvm2-monitor   mdmonitor   messagebus   netfs   nfslock   postfix   rpcbind   rpcgssd   rpcidmapd   udev-post ] off_services.each do |service|   bash "stop_#{service}_service" do     only_if "chkconfig --list | grep #{service} | grep 3:on"     code <<-EOC       chkconfig #{service} off     EOC   end end | 
前半で必要なサービスで入ってなかったものをインストールし、chkconfig on の設定を行っています。後半は、不要なサービスの停止。
インストールしたパッケージを chkconfig on にする際の注意点として、サービス名が「パッケージ名 + d」(abrt → abrtd など)になるものもあるのでそこは注意しないといけません。
段々と Chef で本格運用できそうな環境が整ってきました。Recipe 書いて provisioning が一発で決まると、めっちゃ気持ちいいですね。
今のところ基本的にサードパーティの Cookbook は使わずに、自力で全部 Cookbook/Recipe を書いています。サードパーティ Cookbook はプラットフォーム差異吸収のための抽象化でコードの見通しが悪いのと、サーバーの運用という側面上ブラックボックス化されている部分をできるだけ少なくしたいですので。
各々サービス(デーモン)の詳細は、以下の参考リンクのページを参考にさせて頂きました。
- – 参考リンク –
- 不要なデーモンを停止させる (CentOS 6.5) – Qiita
- CentOSの不要なサービスを停止する – あんみのの備忘録
- CentOSの不要なデーモンを停止してみる – yk5656 diary
- [object HTMLImageElement]
- RHEL6.3のサービスについて | Cyberblack Laboratory
- Vagrant & Chef の関連記事
- Vagrantで使うVirtualBoxのVM(仮想マシン)を外付けHDDに移動
- Chefで/etc/sysctl.confのkernel.panicを設定
- Chefでtelnetをインストール
- Chefでyumリポジトリを追加する設定
- Chef で iptables の設定
- ChefでSSH接続用の公開鍵をサーバーに設置
- nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
- Chef Recipe でユーザー・グループを作成
- Chef Recipe で CentOS のネットワーク・ホストを設定
- NetworkManager 他不要なパッケージを削除する Chef Recipe

 画像付き英語辞書 Imagict | 英単語をイメージで暗記
画像付き英語辞書 Imagict | 英単語をイメージで暗記









Leave Your Message!