Copy file from chef client node to workstation

◇◆丶佛笑我妖孽 提交于 2019-11-29 08:05:28
HRM

I have found solution for this.Thanks to this SO post which is similar to my need and there i found the usage of sshpass instead of expect. So I altered my script like below and now chef is happy and its copying...:)

Modified script using sshpass

#!/bin/bash

#Copy file from client's source path to workstation's dest path
sshpass -p <%= @password%> scp -o StrictHostKeyChecking=no <%= @sourcefile%> <%= @user%>@<%= @ip%>:<%= @destinationpath%>

And in default.rb

template "/tmp/automatecopy" do
  source "automatecopy.erb"
  mode 0777
  variables(
       :user=> "chef-ws",
       :ip=> "10.232.110.113",
       :sourcefile=> "/tmp/outfile",
       :destinationpath => "/home/chef-ws/fileserver",
       :password=> "pass"
  )
end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!