DhcpServerOptionValue requires UserClass property; DhcpServerOptionDefintion does use UserClass
Details of the scenario you tried and the problem that is occurring
Trying to setup DHCP options for Skype VoIP. Using chef with dsc resources.
dsc_resource 'OptionDef120' do
resource :xDhcpServerOptionDefinition
module_name 'xDhcpServer'
property :Ensure, 'Present'
property :Name, 'UCSipServer'
property :OptionID, 120
property :Type, 'BinaryData'
property :Description, 'Sip Server Fqdn'
property :VendorClass, ''
property :AddressFamily, 'IPv4'
end
dsc_resource 'OptionValue120' do
resource :DhcpServerOptionValue
module_name 'xDhcpServer'
property :Ensure, 'Present'
property :OptionID, 120
property :Value, ['000963696F2D7563706C31056F73756164036F73750365647500']
property :VendorClass, ''
property :AddressFamily, 'IPv4'
end
Verbose logs showing the problem
First run:
================================================================================
Error executing action run on resource 'dsc_resource[OptionValue120]'
================================================================================
Chef::Exceptions::PowershellCmdletException
-------------------------------------------
PowerShell Cmdlet failed: Could not find mandatory property UserClass. Add this property and try again.
+ CategoryInfo : ObjectNotFound: (root/Microsoft/...gurationManager:String) [], CimException
+ FullyQualifiedErrorId : MI RESULT 6
+ PSComputerName : localhost
Resource Declaration:
---------------------
# In c:/chef/cache/cookbooks/fisher-role-dhcp-windows/recipes/default.rb
170: dsc_resource 'OptionValue120' do
171: resource :DhcpServerOptionValue
172: module_name 'xDhcpServer'
173: property :Ensure, 'Present'
174: property :OptionID, 120
175: property :Value, ['000963696F2D7563706C31056F73756164036F73750365647500']
176: property :VendorClass, ''
177: property :AddressFamily, 'IPv4'
178: end
179:
Compiled Resource:
------------------
# Declared in c:/chef/cache/cookbooks/fisher-role-dhcp-windows/recipes/default.rb:170:in `from_file'
dsc_resource("OptionValue120") do
action [:run]
default_guard_interpreter :default
properties {Ensure=>"Present", OptionID=>120, Value=>["000963696F2D7563706C31056F73756164036F73750365647500"], VendorClass=>"", AddressFamily=>"IPv4"}
resource :DhcpServerOptionValue
declared_type :dsc_resource
cookbook_name "fisher-role-dhcp-windows"
recipe_name "default"
module_name "xDhcpServer"
end
System Info:
------------
chef_version=14.13.11
platform=windows
platform_version=10.0.17763
ruby=ruby 2.5.5p157 (2019-03-15 revision 67260) [x64-mingw32]
program_name=C:/opscode/chef/bin/chef-client
executable=C:/opscode/chef/bin/chef-client
After adding UserClass property:
================================================================================
Error executing action run on resource 'dsc_resource[OptionValue120]'
================================================================================
Chef::Exceptions::PowershellCmdletException
-------------------------------------------
PowerShell Cmdlet failed: Parameters for option value to be set for option ID 120 do not match with option definition on DHCP server DHCPSEC.
+ CategoryInfo : InvalidArgument: (120:) [], CimException
+ FullyQualifiedErrorId : WIN32 87,Set-DhcpServerv4OptionValue
+ PSComputerName : localhost
The PowerShell DSC resource '[DhcpServerOptionValue]DirectResourceAccess' with SourceInfo '' threw one or more non-terminating errors while running the Set-TargetResource functionality. These errors are logged to the ETW channel called
Microsoft-Windows-DSC/Operational. Refer to this channel for more details.
+ CategoryInfo : InvalidOperation: (root/Microsoft/...gurationManager:String) [], CimException
+ FullyQualifiedErrorId : NonTerminatingErrorFromProvider
+ PSComputerName : localhost
Resource Declaration:
---------------------
# In c:/chef/cache/cookbooks/fisher-role-dhcp-windows/recipes/default.rb
170: dsc_resource 'OptionValue120' do
171: resource :DhcpServerOptionValue
172: module_name 'xDhcpServer'
173: property :Ensure, 'Present'
174: property :OptionID, 120
175: property :Value, ['000963696F2D7563706C31056F73756164036F73750365647500']
176: property :VendorClass, ''
177: property :UserClass, ''
178: property :AddressFamily, 'IPv4'
179: end
180:
Compiled Resource:
------------------
# Declared in c:/chef/cache/cookbooks/fisher-role-dhcp-windows/recipes/default.rb:170:in `from_file'
dsc_resource("OptionValue120") do
action [:run]
default_guard_interpreter :default
properties {Ensure=>"Present", OptionID=>120, Value=>["000963696F2D7563706C31056F73756164036F73750365647500"], VendorClass=>"", UserClass=>"", AddressFamily=>"IPv4"}
resource :DhcpServerOptionValue
declared_type :dsc_resource
cookbook_name "fisher-role-dhcp-windows"
recipe_name "default"
module_name "xDhcpServer"
end
System Info:
------------
chef_version=14.13.11
platform=windows
platform_version=10.0.17763
ruby=ruby 2.5.5p157 (2019-03-15 revision 67260) [x64-mingw32]
program_name=C:/opscode/chef/bin/chef-client
executable=C:/opscode/chef/bin/chef-client
Suggested solution to the issue
UserClass does not need to be mandatory. It is not required in the cmdlet.
The DSC configuration that is used to reproduce the issue (as detailed as possible)
dsc_resource 'OptionDef120' do
resource :xDhcpServerOptionDefinition
module_name 'xDhcpServer'
property :Ensure, 'Present'
property :Name, 'UCSipServer'
property :OptionID, 120
property :Type, 'BinaryData'
property :Description, 'Sip Server Fqdn'
property :VendorClass, ''
property :AddressFamily, 'IPv4'
end
dsc_resource 'OptionValue120' do
resource :DhcpServerOptionValue
module_name 'xDhcpServer'
property :Ensure, 'Present'
property :OptionID, 120
property :Value, ['000963696F2D7563706C31056F73756164036F73750365647500']
property :VendorClass, ''
property :AddressFamily, 'IPv4'
end
Followed by:
dsc_resource 'OptionValue120' do
resource :DhcpServerOptionValue
module_name 'xDhcpServer'
property :Ensure, 'Present'
property :OptionID, 120
property :Value, ['000963696F2D7563706C31056F73756164036F73750365647500']
property :VendorClass, ''
property :UserClass, ''
property :AddressFamily, 'IPv4'
end
The operating system the target node is running
OsName : Microsoft Windows Server 2019 Standard OsOperatingSystemSKU : StandardServerEdition OsArchitecture : 64-bit WindowsVersion : 1809 WindowsBuildLabEx : 17763.1.amd64fre.rs5_release.180914-1434 OsLanguage : en-US OsMuiLanguages : {en-US}
Version and build of PowerShell the target node is running
Name Value
PSVersion 5.1.17763.592
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.592
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Version of the DSC module that was used ('dev' if using current dev branch)
2.0.0.0
I think you need to have UserClass = '' in the configuration because the parameter is a Key so that you are not able to add the configuration twice. 🤔
Let me know if that does not work.