27
26

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Chefでディレクトリを作成する時に action :create してはいけない?

Last updated at Posted at 2013-06-06

詳細調査中ーーー

下記は /var/run/hoge にディレクトリを作成するレシピである。


directory "/var/run/hoge" do
  owner "fuga"
  group "fuga"
  recursive true
  mode 0755
  action :create
end

ただし稼働中のシステムで該当のディレクトリの配下にファイルが存在していても、新規作成を試みる。
actionに条件付きアクションを使うとこの問題に対処できる。


directory "/var/run/hoge" do
  owner "fuga"
  group "fuga"
  recursive true
  mode 0755
  action :create
  not_if { File.exists "/var/run/hoge" }
end

:create_if_missing というドキュメントされていないアクションもあるが、使わないほうが無難。
https://tickets.opscode.com/browse/CHEF-1959


directory "/var/run/hoge" do
  owner "fuga"
  group "fuga"
  recursive true
  mode 0755
  action :create_if_missing
end
27
26
2

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
27
26

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?