3
我可以使用Chef和Powershell創建自定義Windows防火牆規則。我遇到了not_if的問題。具有自定義GUID的Windows防火牆的廚師衛士
我已經使用了註冊表項方法從這裏開始: http://docs.opscode.com/resource_registry_key.html
自定義防火牆規則創建一個隨機GUID的註冊表鍵值。我無法使用這些方法,因爲我不知道密鑰名稱。鍵值在每個節點上都是相同的,但不是鍵名。
以下的作品。但是,自定義鍵對鍵名
execute "enableMSDTCFirewall" do
command "netsh advfirewall firewall set rule group=\"Distributed Transaction Coordinator\" new enable=yes"
action :run
not_if { registry_data_exists?("HKLM\\SYSTEM\\CurrentControlSet\\Services\\SharedAccess\\Parameters\\FirewallPolicy\\FirewallRules", {:name => 'MSDTC-In-TCP', :type => :string, :data => "v2.20|Action=Allow|Active=TRUE|Dir=In|Protocol=6|App=%SystemRoot%\\system32\\msdtc.exe|[email protected],-33503|[email protected],-33506|[email protected],-33502|"})}
end
其他然後一個標誌一個GUID,我想不出另一種方式來檢查,如果規則存在,而不是讓每個客戶端運行時的腳本執行。有任何想法嗎?
結束了與該工作
execute "enableFirewallRuleNameOutbound" do
command "powershell.exe New-NetFirewallRule -DisplayName \"RuleName\" -Direction Outbound -LocalPort 20000 -Protocol TCP -Action Allow"
action :run
not_if 'netsh advfirewall firewall show rule name=\"RuleName\" > nul'
末
你應該在'netsh ...'這一行有單引號,而不是花括號。 –