Custom Type/Provider Parameter Issue: Value updating itself each agent run.

asked 2017-05-09 01:52:07 -0500

ross.murray gravatar image

updated 2017-05-09 11:06:52 -0500

smarlow gravatar image

Referenced Module

In my puppet IIS module, I have a custom type called iis_pool, with a parameter called 'enable_32bit'.

newproperty(:enable_32bit) do
  desc 'A Boolean to determine if 32bit mode should enabled. Defaults to false.'
  newvalues(:false, :true)
end

Try as I might to convert the output into various formats, Including ONLY accepting bool values instead of symbols or string, or munging values into symbols, strings or a bool, the output always results in the following 'Notice:'

Notice: /Iis_pool[testpool]/enable_32bit: enable_32bit changed 'false' to 'false'

Now this functions correctly (as in the attribute is correctly updated on my Resource), but it messes with my reporting as every single puppet run returns changes where it is simply enforcing its existing state. So I can't reliably look at my console and see an expected number of changes, because every node is constantly seeing changes.

On the provider side of things, the method is defined as follows:

# hash with various values
def self.poolattrs
{
  ....
  :enable_32bit => 'enable32BitAppOnWin64',
  ....
}
end

and then the actual definition iterates over the hash and creates methods:

Puppet::Type::Iis_pool::ProviderPowershell.poolattrs.each do |property, poolattr|
  define_method "#{property}=" do |value|
    @property_flush['poolattrs'][property.to_sym] = value
    @property_hash[property.to_sym] = value
  end
end

and then finally the attribute is updated as necessary, via the flush (the below is only the relevant part of the flush, again iterating over the hash. Final execution is to trigger the command_array string.):

# Gather all the updated 'poolattrs' and add them to the command_array
@property_flush['poolattrs'].each do |poolattr, value|
  property_name = Puppet::Type::Iis_pool::ProviderPowershell.poolattrs[poolattr]
  # Skip the state poolattr, we'll do it last.
  next if property_name == 'state'
  command_array << "Set-ItemProperty \"IIS:\\\\AppPools\\#{@property_hash[:name]}\" -Name #{property_name} -Value #{value}"
end

I'm confident that this is problem with the logic, or I've referenced the wrong hash or variable someplace. I'd greatly appreciate any assistance.

Cheers,

Ross

edit retag flag offensive close merge delete