2

I am very new to puppet and trying to execute my puppet script but its failing all the time.

I want to store the output of below bash command and want to store in a variable which I can use later:

/usr/bin/head -1 /tmp/testfile.out | cut -d',' -f2'3

Which I am passing to my puppet script to read a file from another location

variable => generate('/usr/bin/head -1 /tmp/testfile.out | cut -d',' -f2'),
command => "/bin/cp /${variable}/application/myscript.sh /var/tmp/myscript.sh",
creates => "/var/tmp/myscript.sh",

But when I execute this puppet script it fails. I am not sure even if above one is correct too. Any help would be appreciated.

Thanks

EDITED

testfile.out contains a cron data which is generated using my custom php script in that I have application name on the first line of the file. Sample entry of the file :

cat testfile.out
server.amazon.com,zimbra,1080,3000

I have a script which sits on a nfs share which starts with the application name $variable and I need to copy on that server which will run check for all zimbra related files and folders. Even I am not sure about this script what it does exactly as its a binary file..

8
  • 1
    First of all you have syntax errors. You need to escape the "'"s before and after the comma. Aug 26, 2014 at 12:44
  • 1
    The single quotes at cut -d ',' need to be escaped.
    – faker
    Aug 26, 2014 at 13:21
  • 1
    Try replacing the $variable with actual syntax
    – Pratap
    Aug 26, 2014 at 13:30
  • 2
    You can probably work around this by deploying a shell script which executes this command. But: can you please explain better what you are trying to do? You know that generate runs on the master server, not the node, right?
    – faker
    Aug 26, 2014 at 13:41
  • 1
    Add facts, that is extend facter.
    – Zoredache
    Aug 26, 2014 at 14:00

1 Answer 1

0

Use this

command => "/bin/cp \"`/usr/bin/head -1 /tmp/testfile.out | cut -d\",\" -f2`\"/application/myscript.sh /var/tmp/myscript.sh",
creates => "/var/tmp/myscript.sh"

It works for me ..

You must log in to answer this question.