Ask Your Question
0

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

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

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":
        cwd=>"C:\\${prodequ_jboss_server_loc}/server/default\conf",
        command=>'C:\Windows\System32\cmd.exe /c "copy ConstructHTMLTags.properties 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
1

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

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 https://docs.puppet.com/puppet/latest... 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

Stats

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

Seen: 187 times

Last updated: Apr 07 '16