- From: Torben Knerr <
>
- To:
- Subject: [chef] How to extend node[:apache][:listen_ports] from within another recipe?
- Date: Thu, 25 Oct 2012 22:58:35 +0200
Hi Chefs,
I'm trying to add another port to `node[:apache][:listen_ports]` from within my own recipe, e.g. like this:
```
if not node[:apache][:listen_ports].include? "8080"
node.override[:apache][:listen_ports] = node[:apache][:listen_ports] << "8080"
end
```
This does not work really well as it requires another chef run to take effect. I assume this is because it runs _after_ the /etc/apache2/ports.conf template resource (from the apache2 recipe) has been created with the orginal `node[:apache][:listen_ports]` which did not contain port 8080 at that time yet.
I have also tried to notify the /etc/apache2/ports.conf template resource after adding port 8080 to the apache listen ports, but this didn't work as well:
```
ruby_block "update apache listen port" do
block do
node.override[:apache][:listen_ports] = node[:apache][:listen_ports] << "8080"
end
notifies :create, resources(:template => "#{node[:apache][:dir]}/ports.conf")
not_if { node[:apache][:listen_ports].include? "8080" }
end
```
I suspect the resource gets in fact notified, but still has the "outdated" state as it does not re-evaluate `node[:apache][:listen_ports]` now that port 8080 has been added.
Is there a way to do this in a single Chef run?
Thanks,
Torben
- [chef] How to extend node[:apache][:listen_ports] from within another recipe?, Torben Knerr, 10/25/2012
Archive powered by MHonArc 2.6.16.