Closed ranamalo closed 6 years ago
So what should be the new name variable be?
username?
Don't see how that gets around the problem?
You are right. Sorry misread your question. Could we just have the title be the name variable and have something like this:
httpauth { 'user_realm1': username => 'user' file => '/etc/httpd/htpasswd/.realm1', password => 'blah', realm => 'realm1', mechanism => basic, ensure => present, }
httpauth { 'user_realm2': username => 'user' file => '/etc/httpd/htpasswd/.realm2', password => 'blah', realm => 'realm2', mechanism => basic, ensure => present, }
I agree with this sentiment. I ran into this issue testing out the same username using basic and digest authentication, and it won't let me because the resources have the same name.
I tried adding a new parameter ':user' which defaulted to ':name' if not specified, but that just got me multiple entries with the literal string 'name' as the username, and the appropriate realm and password. Other variations (value(:name), self[:name], @?resource[:name]) give me errors including saying 'Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Cannot alias Httpauth[user-basic] to ["user"] at /tmp/vagrant-puppet/manifests/default.pp:31; resource ["Httpauth", "user"] already declared at /tmp/vagrant-puppet/manifests/default.pp:22 at /tmp/vagrant-puppet/manifests/default.pp:31 on node localhost.localdomain'
Unfortunately I don't know ruby all that well, and the puppet documentation doesn't give any way that I can see for a parameter default to another given parameter, aside from isnamevar. I think that the Then the provider would have to use the 'user' value, as opposed to the 'name' value.
Fixed by #6
Right now the user has to be the resource name. However if you want use that user name in two different realms and two different htpasswd files you can't. If it was a parameter you could.