Well I realized that set_unless is exactly the thing I need. If anyone reads
this, my problem was that tried to use attributes in existing :network section
which is defined (I believe) every “chef-client run” by ohai. So my attributes
were redefined somehow…
Dne úterý 26 Leden 2010 08:13:36 Ares napsal(a):
I installed chef recently and now I’m trying to learn best practices for
using it. I realized that using set and set_unless for attributes
definition is not so easy as I thought after reading documentation.
I’m trying to create cookbook for arno-iptables-firewall. I want to have
port 22 opened by default and on some nodes to be able to change these
ports. The thing is that when I use set_unless(some_attribute) = [“22”] in
attributes definition in my cookbook and I later change these values in
web ui, these changes are overwritten during next chef-client run.
I found this explanation http://tickets.opscode.com/browse/CHEF-838 so I
know that default is not really default.
So my question is, is there any “best practise” to do what I need? Could I
for example use something like
set(…) if node[:network][:firewall].nil?
Thanks for any reply and for very promising server management tool