iptablesのrestartに失敗する
Chefで下記のような一般的なiptablesのtemplateを用意し、設定を反映するためrestartをかけたところエラーが。
# iptables *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] :RH-Firewall-1-INPUT - [0:0] (中略) COMMIT
Chefの命令はこんな感じ。
template 'iptables' do path '/etc/sysconfig/iptables' owner 'root' group 'root' notifies :restart, 'service[iptables]' end
エラーメッセージは下記の通り。
$ service iptables restart iptables: Flushing firewall rules: [ OK ] iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Unloading modules: [ OK ] iptables: Applying firewall rules: iptables-restore v1.4.18: no command specified Error occurred at line: 29 Try `iptables-restore -h' or 'iptables-restore --help' for more information. [FAILED]
表示されたエラーメッセージで検索してみたところ、無駄な改行とかスペースが入ってると出るよ、とのこと。
可能な限り改行とスペースを排除して再度実行してみるも、エラー変わらず。
ふと思い立ってCOMMITの後に改行を入れてみる。
# iptables *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] :RH-Firewall-1-INPUT - [0:0] (中略) COMMIT # ここに改行!
何故かSuccess!!
よく分からない上に無茶苦茶時間取られてイライラがどんっすとっみーなーう。