我想运行ssh-copy-id如果用户在服务器上没有他们的密钥,那么我在execute块中有一个not_if指令。我已经验证了not_if命令返回0,但执行块仍然运行。厨师:not_if不工作
execute "add ssh key to #{shortname}" do
not_if cmd # proceed only if server doesn't have this key
command "echo 'If prompted for password it is already in your clipboard and you can just paste it in and hit enter'; ssh-copy-id [email protected]#{hostname}"
cmd = "ssh -o 'BatchMode yes' [email protected]#{hostname} echo 'test'"
puts cmd
end
drostie:chef-ops (ssh_copy_id)$ ssh -o 'BatchMode yes' [email protected] echo 'test'
test
drostie:chef-ops (ssh_copy_id)$ echo $?
0
任何想法?
为什么不管理目标节点上的用户ssh密钥,您试图复制它? – jtimberman