Node Attributes within bash script


#1

Hi there,

Is there any way of using a chef node attribute within a bash script?

In my repo i have an config.sh script to deploy my app and within this script it would be nice to reference like:

#!/bin/sh
MYDIR=node[:file_location][:mydir]

And then in the script "mv /tmp/file.txt /test/$MYDIR

Is it possible?

Cheers,
Simon.


#2

The way I would do this is to leverage a template within your cookbook that would generate the BASH script prior to executing it. This is how I have leveraged attributes within a BASH script. It is either that, or use a ruby block to search and replace text.


#3

Hiya,

Many thanks - this works a treat!

Cheers,
Simon.