I am currently working on a Chef recipe where I set up an IIS application pool with a specific service account identity. However, I've observed that the periodic_restart_schedule property is being set to an empty array ([]) during each Chef run, even when I don't explicitly declare it in the recipe. Here is a snippet of the relevant part of my recipe:
iis_pool app_pool_name do
action :config
runtime_version '4.0'
pipeline_mode :Integrated
identity_type :SpecificUser
username svc_account_name
password svc_account_password
start_mode :AlwaysRunning
ignore_failure true
end
How to fix this? Basically, the recipe should not touch the recycling property(periodic_restart_schedule).
When Chef compiles resources, it takes user defined values for properties. Any properties not defined, fall back to their defaults. So if you don't explicitly declare a value for periodic_restart_schedule
, it will take the default, which is an empty array.
The iis_pool
resource comes from the iis cookbook. And below is how the property has been defined:
property :periodic_restart_schedule, [Array, String], default: [], coerce: proc { |v| Array(v).sort }
So unless you specify the property in your cookbook, it will be default: []
.
Basically, the recipe should not touch the recycling property
I'd recommend using Chef as Configuration as Code tool (which it is), and "manage" the complete IIS pool with iis_pool
resource, including periodic_restart_schedule
and other settings, rather than running Chef to do partial configuration.