Created
June 22, 2017 09:37
-
-
Save grdnrio/7d90f141f7584a9c25ebeca1f28059e9 to your computer and use it in GitHub Desktop.
Secedit.exe custom resource example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| resource_name :security_policy | |
| default_action :configure | |
| property :policy_template, String, required: false, default: 'C:\Windows\security\templates\chefNewPolicy.inf' | |
| property :database, String, required: false, default: 'C:\Windows\security\database\chef.sdb' | |
| property :log_location, String, default: 'C:\Windows\security\logs\chef-secedit.log' | |
| action :configure do | |
| if node['platform'] == 'windows' | |
| template "#{policy_template}" do | |
| source 'policy.inf.erb' | |
| cookbook 'windows-security-policy' | |
| action :create | |
| end | |
| execute 'Configure security database' do | |
| command "Secedit /configure /db #{database} /cfg #{policy_template} /log #{log_location}" | |
| live_stream true | |
| action :run | |
| end | |
| else | |
| Chef::Log.info "#{@current_resource} is only for a Windows platform" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment