Chef で multiverse リポジトリを有効にする方法
Chef
でUbuntu
の multiverse リポジトリを有効にするために以下のレシピを書きました。これで無効状態から有効に変えることはできたのですが、二度目以降がエラーになってしまいます。
execute "enable multiverse" do
command %Q{ grep -q '^# deb.*multiverse' /etc/apt/sources.list && sed -i '/^# deb.*multiverse/ s/^# //' /etc/apt/sources.list && apt-get update }
ignore_failure true
end
以下が該当部分のエラーメッセージです。
Recipe: base::default
* execute[enable multiverse] action run[2015-01-19T16:53:39+00:00] ERROR: execute[enable multiverse] (base::default line 10) had an error: Expected process to exit with [0], but received '1'
---- Begin output of grep -q '^# deb.*multiverse' /etc/apt/sources.list && sed -i '/^# deb.*multiverse/ s/^# //' /etc/apt/sources.list && apt-get update ----
STDOUT:
STDERR:
---- End output of grep -q '^# deb.*multiverse' /etc/apt/sources.list && sed -i '/^# deb.*multiverse/ s/^# //' /etc/apt/sources.list && apt-get update ----
Ran grep -q '^# deb.*multiverse' /etc/apt/sources.list && sed -i '/^# deb.*multiverse/ s/^# //' /etc/apt/sources.list && apt-get update returned 1; ignore_failure is set, continuing
================================================================================
Error executing action `run` on resource 'execute[enable multiverse]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of grep -q '^# deb.*multiverse' /etc/apt/sources.list && sed -i '/^# deb.*multiverse/ s/^# //' /etc/apt/sources.list && apt-get update ----
STDOUT:
STDERR:
---- End output of grep -q '^# deb.*multiverse' /etc/apt/sources.list && sed -i '/^# deb.*multiverse/ s/^# //' /etc/apt/sources.list && apt-get update ----
Ran grep -q '^# deb.*multiverse' /etc/apt/sources.list && sed -i '/^# deb.*multiverse/ s/^# //' /etc/apt/sources.list && apt-get update returned 1
Resource Declaration:
---------------------
# In /home/vagrant/chef-solo/cookbooks-2/base/recipes/default.rb
10: execute "enable multiverse" do
11: command %Q{ grep -q '^# deb.*multiverse' /etc/apt/sources.list && sed -i '/^# deb.*multiverse/ s/^# //' /etc/apt/sources.list && apt-get update }
12: ignore_failure true
13: end
14:
Compiled Resource:
------------------
# Declared in /home/vagrant/chef-solo/cookbooks-2/base/recipes/default.rb:10:in `from_file'
execute("enable multiverse") do
action "run"
ignore_failure true
retries 0
retry_delay 2
command " grep -q '^# deb.*multiverse' /etc/apt/sources.list && sed -i '/^# deb.*multiverse/ s/^# //' /etc/apt/sources.list && apt-get update "
backup 5
returns 0
cookbook_name :base
recipe_name "default"
end
ignore_failure true
を設定してるのでgrep
が失敗を返してもレシピ自体は正常終了すると思ったのですが、そうではないのでしょうか?