How to move/copy files locally with Chef

前端 未结 8 1489
感情败类
感情败类 2020-12-02 12:07

I haven\'t yet come across a Chef resource that will copy/move files locally. For example, I want to download jetty hightide and unzip it. Once done, copy all the files into

8条回答
  •  北海茫月
    2020-12-02 12:57

    If your recipe is already tied to Windows, you can use embedded PowerShell scripts, like this:

    # Copy files from "C:/foo/lib" to "C:/foo"
    powershell_script "copy_lib" do
      code <<-EOH
        $ErrorActionPreference = "Stop"
          Get-ChildItem -Path "C:/foo/lib" -File | Foreach-Object {
            Copy-Item -Path $_.Fullname -Destination "C:/foo" -Force
          }
      EOH
    end
    
    # Delete "C:/foo/lib" folder
    powershell_script "delete_lib" do
      code <<-EOH
        $ErrorActionPreference = "Stop"
        Remove-Item -Path "C:/foo/lib" -Recurse
      EOH
    end
    

提交回复
热议问题