Ask Your Question

how to use variable in copy command using puppet exec resource command ? (windows)

asked 2016-04-07 05:47:46 -0600

yoga gravatar image

I want to copy file from 1 folder to another, That file_path is stored in variable.How do i use that variable in puppet code using exec command resource.?

My code is

 class currentgen::backup::app::conf::constructhtmltags
  ($prodequ_backup_loc        = $prodequ_backup_loc,
   $prodequ_jboss_server_loc  = $prodequ_jboss_server_loc,
    $time = $::windows_time)
    inherits currentgen{
        exec{"constructhtmltags backup":
        command=>'C:\Windows\System32\cmd.exe /c "copy C:\\${prodequ_backup_loc} /-y"',

it will copy that file in the name of "${prodequbackuploc}" in C:\ .

how do i give variable in exec command for windows?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-04-07 08:14:12 -0600

binford2k gravatar image

You should actually not do that. An execis a tool of last resource. Instead, you should use the built in resource types, such as and point to a local source. For example, this will idempotently copy /tmp/bar to /tmp/foo.

file { '/tmp/foo':
    ensure => file,
    source => '/tmp/bar',
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-04-07 05:47:46 -0600

Seen: 382 times

Last updated: Apr 07 '16