Hey Dan,

  The error you're getting is just saying that you've declared the
Base::Systemusers class twice and a class can only be declared once. I
suspect that your code looks something like this:

  $systemusers   = lookup({ name => 'base::systemusers' })
  $systemusers.each |$username, $userinfo| {
    class { 'base::systemusers':
      username => $username,
    }
  }

  If that is the case then you should be able to fix the problem by
changing Base::Systemusers from a class to a define. Defined types can be
declared multiple times as long as each one has a unique title. You can
find more information about defined types here:
https://puppet.com/docs/puppet/6.4/lang_defined_types.html

  The syntax to declare the defined type would change slightly. It should
look like this:
  base::systemusers { $username: }

  Let me know if you have any questions (or if I guess incorrectly about
what your code looks like).

  - Steve

On Fri, May 3, 2019 at 12:21 PM Daniel Kinon <[email protected]> wrote:

> Hello Everyone,
>     So I'm trying to create templates for system users.  Here is my
> systemusers class:
> ~~~
> class base::systemusers (
>   $username = $title,
>   $home     = "/var/lib/$username",
> ) {
>   $systemusers   = lookup({ name => 'base::systemusers' })
>   user { $username:
>     ensure     => present,
>     system     => true,
>     uid        => $systemusers[$username]['uid'],
>     home       => $home,
>     managehome => true,
>     shell      => '/bin/bash',
>   }
>
>   file { "$home/.ssh":
>     ensure  => directory,
>     owner   => $username,
>     group   => $username,
>     mode    => '0700',
>   }
>
>   file { "/var/run/$username":
>     ensure  => directory,
>     owner   => $username,
>     group   => $username,
>     mode    => '0755',
>   }
>
>   file { "/var/log/$username":
>     ensure  => directory,
>     owner   => $username,
>     group   => $username,
>     mode    => '0755',
>   }
> ~~~
>
> This works great when I only have 1 system user but the minute I have more
> than 1 I get a *Duplicate declaration: Class[Base::Systemusers] *error.
> I've looked at the docs for virtual resources (tbh, it breaks my brain a
> little) but all the examples seem to be for general resources and not
> classes.  I've tried a bunch of different iterations to solve this and I
> haven't gotten any of them to work.  If someone could point me in the right
> direction, I'd appreciate it.
>
> Thanks,
> -Dan
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/CAMGSraH5Sn31xPt8Z4DN8Xj74g20TZZ4z%3DPgD5TwgP%3DtWRT%3DxQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/puppet-users/CAMGSraH5Sn31xPt8Z4DN8Xj74g20TZZ4z%3DPgD5TwgP%3DtWRT%3DxQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CALGSqj%2BXChwjKqFqB%2B07uyNuK0ojNMV593pF9rbZ2_aRABZKUw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to