【发布时间】:2016-06-05 23:22:43
【问题描述】:
我正在尝试完成某人的食谱,我需要能够让 Chef 从此脚本中提取返回的整数 0(一些细节已被删除)关于 Chef 中可能起作用的任何建议?我已经在 Chef 中添加了 Powershell 模块,特别是我在询问 Chef 解析这些数据的顺序 - 如在 action: item 中将此变量交给...谢谢。
include_recipe "chef_handler
powershell_script do
code <<-EOH
###############
#
# Description:
# Returns 1 if any share or share path allow read/write by the 'Everyone' group (fail)
# Returns 0 if this condition is not found (pass)
Try
{
#get all shares
$shares = e | Select-Object Name,Path
if($shares)
{
Foreach ($share in $shares)
{
#check everyone permissions
$shareAccounts = -Name $share.Name
Foreach ($account in $shareAccounts)
{
If ($account.AName -eq 'Everyone')
{
return 1
}
}
#check
$volumePerm = Get-ACL $share.Path
if ($volume.Access.Where({$Reference -eq 'Everyone'}))
{
return 1
}
}
}
else
return 0
#loop through each share checking for 'Everyone'
# pass the return values send to Chef or something else.
}
{
#build error message
}
Finally
{
#return final message
}
EOH
fail "Instance has failed the OpenShares check" if code == 1
end
【问题讨论】:
-
我们使用的解决方法是将其写入 tmp 文件,从 Chef 读取并删除它。
-
谢谢Wai Yan,有sn-p 可以分享吗?我没有想到这一点。 :-)
标签: powershell chef-infra cookbook