ptierno / puppet-windowspagefile

Puppet type and provider to manage windows pagefiles
Other
1 stars 5 forks source link

Error on some Windows 7 x64 SP1 computers #7

Open jmp242 opened 8 years ago

jmp242 commented 8 years ago

I have a manifest with: pagefile { 'c:\pagefile.sys': maximumsize => 8192, }

and get errors: Could not set 'present' on ensure: undefined method InitialSize=' for nil:NilClass at 64:/mnt/puppet/etc/environments/production/modules/config/manifests/init.pp Wrapped exception: undefined methodInitialSize=' for nil:NilClass

glarizza commented 8 years ago

I'm seeing this too, and I'm wondering two things: first, it's trying to invoke "IntialSize=" on the provider, where it should be looking "initialsize=", but that might be a red herring. The bigger deal is that it's trying to call that method on a nil object, not an instance of the provider. I'm going to try and debug further if I have access to this machine. I'm running on Windows Server 2012 R2

glarizza commented 8 years ago

Yeah, it looks like it might be here: https://github.com/ptierno/puppet-windowspagefile/blob/master/lib/puppet/provider/pagefile/wmi.rb#L118-L122

It looks like the pagefile variable is probably being returned as nil, and it looks like that variable comes from doing a search for instances of the pagefile.

jmp242 commented 8 years ago

So I'm assuming this needs some sort of code fixes.

glarizza commented 8 years ago

I'm working with an organization and haven't been able to spin up a windows node for test independently - I'd like to do that and try to find out what's going on. Basically, I need to set pagefiles at C:\ and D:\ and so was doing something like:

  if $::is_virtual {
    $initial_size = 1024
    $maximum_size = 1024
  } else {
    $initial_size = 4096
    $maximum_size = 4096    
  }

  pagefile { 'c:\\pagefile.sys':   
    initialsize => $initial_size,   
    maximumsize => $maximum_size,
  }

  pagefile { 'D:\\pagefile.sys':   
    initialsize => $initial_size,   
    maximumsize => $maximum_size,
  }

I'm guessing that the search at https://github.com/ptierno/puppet-windowspagefile/blob/master/lib/puppet/provider/pagefile/wmi.rb#L116 isn't returning an instance of the pagefile, but is instead returning nil...then you're trying to call methods on that object at https://github.com/ptierno/puppet-windowspagefile/blob/master/lib/puppet/provider/pagefile/wmi.rb#L119-L120 but it's throwing an error about trying to call InitialSize= on that nil object (again, guessing based on the code). I'd imagine we need a check for the event that the search returns back a nil object, then we can instantiate a new object.

ptierno commented 8 years ago

My apologies. This provider has been unmaintained for quite a while as I have not had the time to maintain it. Any PR's would be accepted (bonus points for some acceptance and unit tests :smile: ).

ptierno commented 8 years ago

I am going to be merging #6 some time next week. I would appreciate if both @glarizza and @jmp242 would be able to re-test it after that with the updated code before a forge release. I'm thinking @glarizza mention of https://github.com/ptierno/puppet-windowspagefile/blob/master/lib/puppet/provider/pagefile/wmi.rb#L116 might be accurate considering the casing of the drive letter issue that #6 should resolve.

glarizza commented 7 years ago

I commented on the other Pull Request. The gist is that I don't have access to that customer's environment anymore, so I can't test for that specific issue, but I am working with another customer this week and the code did work for us. Based on the code I pasted above, I think the case of the drive letter could have played a part.

jmp242 commented 7 years ago

I'm willing to test if there's a zip I can download the new module version from.

James Pulver CLASSE Computer Group Cornell University

On 12/07/2016 01:33 PM, Gary Larizza wrote:

I commented on the Pull Request, but I don't have access to that customer's environment anymore, so I can't test for that specific issue, but I am working with another customer this week and the code did work for us. Based on the code I pasted above, I think the case of the drive letter could have played a part.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ptierno/puppet-windowspagefile/issues/7#issuecomment-265531503, or mute the thread https://github.com/notifications/unsubscribe-auth/ABVyuj1BWNmONJAYbD5GrTZ-x1j9FMv9ks5rFvvzgaJpZM4ISSSA.