There’s also a fundamental misunderstanding about how to use Chef going on
A Chef resource is a test-and-repair datastructure. It lives in a compiled
resource_collection and is meant to describe some policy point about the
This example is trying to use one Chef resource to harvest information from
the system, use the node objetc as global state tracking mechanism, then
use another resource one to ensure its contents of a file.
The best thing to do would be to restate the problem. Start every system
with “I declare”.
"I declare that the file /tmp/file-1 should have the output of
ls /tmp as
There are a couple different ways to solve this, but the easiest would be
to stash the contents of your ls in a compile phase variable and pass it as
a parameters to your file resources.
this is not a resource. It will be discarded after the compile phase
lsdir shell_out!(“ls /tmp”, :env => nil)
file “/tmp/file1” do
file “/tmp/file2” do
On Wed, Dec 18, 2013 at 1:17 PM, Dan Razzell firstname.lastname@example.org wrote:
Isn’t the issue only that %x[ls /tmp] is being evaluated at compile time?
Avoid that notation and you’ll be able to do what you intend. Use "system"
instead and it will be evaluated as part of the ruby block.
On Tue, Dec 17, 2013 at 10:03 AM, John Alberts email@example.com:
On Tue, Dec 17, 2013 at 9:37 AM, Rilindo Foster <
Slightly off-topic, but where are you modifying It may be a style or
philosophy thing, but I personally wouldn’t try to modify an attribute once
I declare it. I rather that I set my conditions up front in attributes file
and maybe override them as necessary within the environment role. Changing
them within the recipe strikes me as adding a significant amount of
complexity to the code maintenance, as you now have to look at the recipes
AND attributes when you modify the cookbook.
Yes, I agree. Here’s the actual scenario that I’m dealing with. I’m
creating some new EBS volumes, once they are created, I store those new
device entries in an attribute. Later in the code, I need to use those new
devices to either format, create a raid, etc. So, I need to save those
device values somewhere during the Chef run and be able to use them later
in the code.