jamtur01 / jamtur01-httpauth

Puppet type and provider for managing HTTP Basic and Digest Authentication
15 stars 12 forks source link

apply only works if file is not present #1

Closed jkur closed 12 years ago

jkur commented 12 years ago

the httpauth provider works only if you add one user to a not existing password file.

Example on my machine test.pp:

httpauth { 'user1':
  file     => 'test.passwd',
  password => 'hallo',
  realm => 'basis-auth',
  mechanism => 'basic',
  ensure => present,
}

httpauth { 'user2':
  file     => 'test.passwd',
  password => 'hallo',
  realm => 'basis-auth',
  mechanism => 'basic',
  ensure => present,
}

Doing puppet apply test.pp

i get the following error: notice: /Stage[main]//Httpauth[user2]/ensure: created err: /Stage[main]//Httpauth[user1]: Could not evaluate: undefined method `[]' for nil:NilClass

If i run again (then the htpasswd file already exists):

err: /Stage[main]//Httpauth[user1]: Could not evaluate: undefined method `[]' for nil:NilClass

After i delete the file: notice: /Stage[main]//Httpauth[user1]/ensure: created err: /Stage[main]//Httpauth[user2]: Could not evaluate: undefined method `[]' for nil:NilClass

This seems wrong and unusable. Of course i want more than one user in my passwd file.

Regards, Jörg

jamtur01 commented 12 years ago

Hi

It's been quite a while since this provider was updated - this previously worked fine so I suspect something has changed - I will need a lot more information to debug the issue.

Please tell me:

  1. Ruby version
  2. Puppet version
  3. Please provide output on the master and client of a run with --verbose --debug --trace options specified.

Thanks

jkur commented 12 years ago

I think i fixed the issue

Have a look here: https://github.com/jkur/puppet-httpauth

The problem is, when the provider checks if the value exists, it runs into an error, if the passwd file exists, but the certain user is not. Then the cp variable is nil and a later call to the check_password function fails.

Best regards, Jörg

jamtur01 commented 12 years ago

That seems reasonable. If you submit a pull request I'll get it merged and release a new version.

Many thanks!

jamtur01 commented 12 years ago

Cherry-picked and merged. New release pushed.