You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm unsure whether this is a 'bug' or my misunderstanding of how littlechef works.
I'm using the 'ufw' cookbook to manage firewall rules on a machine I'm provisioning with littlechef.
The cookbook's recipe contains this stanza:
old_state=node['firewall']['state']new_state=node['firewall']['rules'].to_sChef::Log.debug"Old firewall state:#{old_state}"Chef::Log.debug"New firewall state:#{new_state}"#check to see if the firewall rules changed.#the rules are always changed the first runifold_state == new_stateChef::Log.info"Firewall rules unchanged."elseChef::Log.info"Firewall rules updated."node['firewall']['state']=new_state#drop rules and re-enableexecute"ufw --force reset"# ... rest of recipe to add rules again ...
The problem I have is the firewall 'state' is never saved to the my node's .json, and therefore the firewall is reset every time this recipe is run.
Should the state be saved? If so, when/where in littlechef does this happen?
I'm assuming this cookbook works as advertised when run with knife/chef server.
The text was updated successfully, but these errors were encountered:
You assumption is correct, though this cookbook's case is a bit confusing.
There are a couple of cookbooks that use node.save, at which point the current node attributes (well, everything) is saved. That only works with a Chef Server. For obvious reasons, Chef Solo cannot save the new info anywhere, so LittleChef by design cannot support that. It could be argued that it is a Chef anti-patern...
What I don't quite understand is why it is a problem in the ufw cookbook, because they don't call node.save in any of the recipes. Reassigning attribute values mid-cookbook should only affect the current run as long as they are not saved.
In any case I marked this issue as "enhancement". We can add a list of cookbooks that use node.save to the documentation so that users are aware of which cookbooks can break when using Chef Solo. A preliminary one:
I'm unsure whether this is a 'bug' or my misunderstanding of how littlechef works.
I'm using the 'ufw' cookbook to manage firewall rules on a machine I'm provisioning with littlechef.
The cookbook's recipe contains this stanza:
The problem I have is the firewall 'state' is never saved to the my node's .json, and therefore the firewall is reset every time this recipe is run.
Should the state be saved? If so, when/where in littlechef does this happen?
I'm assuming this cookbook works as advertised when run with knife/chef server.
The text was updated successfully, but these errors were encountered: