Friday, October 4, 2013

Puppet "exec" always requires a path

I needed to run a simple "mv" command in Puppet, with an "exec" type (I know, exec should be used only in desperate cases):


  exec { "mv OracleDomainScript-${version}":
    command => "mv OracleDomainScript-${version}/* .",
    cwd     => "$destination_folder",
  }



and I got a weird error message:
'mv OracleDomainScript-2.5/* .' is not qualified and no path was specified. Please qualify the command or specify a path

The workaround is to specify explicitly a path:

  exec { "mv OracleDomainScript-${version}":
    command => "mv OracleDomainScript-${version}/* .",
    path => "/bin",
    cwd     => "$destination_folder",
  }

the "default" path of the current user is not used by Puppet:
echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
and the "mv" command is in /bin

I bet EVERY Puppet beginner has made this mistake.



No comments: