I have two possible values of a variable, the default attribute and one
overridden in a role.
In my recipe I would like to test the value of the variable
Code is of the format
cookbook_file “/dir/file” do
action :create
source "default file"
owner "root"
group "root"
mode 0644
only_if "test [:filetype]=“default”"
end
cookbook_file “/dir/file” do
action :create
source "other file"
owner "root"
group "root"
mode 0644
only_if "test [:filetype]=“other”"
end
The only_if test is not working (syntax error).
Is there a way to do this kind of check?
only_if node[:your_attribute] == "ur_overridden_value"
On Fri, Jun 24, 2011 at 2:34 PM, ItsMikeE chef@ernstoff.net wrote:
I have two possible values of a variable, the default attribute and one
overridden in a role.
In my recipe I would like to test the value of the variable
Code is of the format
cookbook_file "/dir/file" do
action :create
source "default file"
owner "root"
group "root"
mode 0644
only_if "test [:filetype]="default""
end
cookbook_file "/dir/file" do
action :create
source "other file"
owner "root"
group "root"
mode 0644
only_if "test [:filetype]="other""
end
The only_if test is not working (syntax error).
Is there a way to do this kind of check?
You're using assignment '=' instead of equivalence '==' in your
only_if statements.
Thanks,
Matt Ray
Senior Technical Evangelist | Opscode Inc.
matt@opscode.com | (512) 731-2218
Twitter, IRC, GitHub: mattray
On Fri, Jun 24, 2011 at 4:04 AM, ItsMikeE chef@ernstoff.net wrote:
I have two possible values of a variable, the default attribute and one
overridden in a role.
In my recipe I would like to test the value of the variable
Code is of the format
cookbook_file "/dir/file" do
action :create
source "default file"
owner "root"
group "root"
mode 0644
only_if "test [:filetype]="default""
end
cookbook_file "/dir/file" do
action :create
source "other file"
owner "root"
group "root"
mode 0644
only_if "test [:filetype]="other""
end
The only_if test is not working (syntax error).
Is there a way to do this kind of check?