virtual resources & spaceship syntax

117 views
Skip to first unread message

Brett Maton

unread,
Jun 29, 2012, 10:36:35 AM6/29/12
to puppet...@googlegroups.com
I'm probably missing something really simple here, but I can't get the following to work:

  include users::accounts
  User <| title="account" |>
}

Any suggestions welcomed :)

Modules:

modules/users/manifests/virtual.pp 

class users::virtual {
  define account ( $uid, 
                   $gid = '', 
                   $home = '',
                   $groups = '',
                   $realName = '',
                   $pass = '',
                   $shell = '/bin/bash',
                   $sshkey = '') {

    $userGroup = $gid ? {
                   ''      => $uid,
                   default => $gid,
                 }

    $homeDir = $home ? {
                 ''      => "/home/${title}",
                 default => $home,
               }
    $comment = $realName ? {
                 ''      => $title,
                 default => $realName,
               }

  #  Create User Group
    group { $title:
      ensure => 'present',
      gid    => $userGroup,
    }

  #  Create User Account
    user { $title:
      ensure     => 'present',
      uid        => $uid,
      gid        => $userGroup,
      shell      => $shell,
      home       => $homeDir,
      comment    => $comment,
      password   => $pass,
      groups     => $groups,
      managehome => 'true',
    }
    #  Add SSH Key if defined.
    if ( $sshkey != '' ) {
      ssh_authorized_key { $title:
        ensure  => 'present',
        type    => 'ssh-rsa',
        key     => "${sshkey}",
        user    => "${title}",
        require => User[ "${title}" ],
        name    => "${title}",
      }
    }
  }
}

modules/users/manifests/accounts.pp 

class users::accounts {
  include users::virtual

  # Brett Maton
  @users::virtual::account { 
    'account':
      uid      => '1001',
      realName => 'account',
      groups   => 'wheel',
      sshkey   => [ Key Data ];

    'account2':
      uid      => '1002',
      realName => 'Second Account',
      groups   => 'wheel',
      sshkey   => [ Key Data ]
  }
}

puppet...@henk.geekmail.org

unread,
Jun 29, 2012, 11:07:55 AM6/29/12
to puppet...@googlegroups.com
Hi,

On Fri, 29 Jun 2012 15:36:35 +0100
Brett Maton <brett...@googlemail.com> wrote:

> I'm probably missing something really simple here, but I can't get
> the following to work:
>
> node 'puppet-slave.test.net' {
> include users::accounts
> User <| title="account" |>
> }

It’s supposed to be a comparison, not an assignment, so
title == 'account'

Best regards

Hendrik Jäger
signature.asc

matonb

unread,
Jun 29, 2012, 11:14:55 AM6/29/12
to puppet...@googlegroups.com
Thanks for looking Henk,

  I think my email client replaced == with =, it is using the comparison op in the actual code....

Kristof Willaert

unread,
Jun 29, 2012, 11:54:00 AM6/29/12
to puppet...@googlegroups.com
Hi,

[snip]

> node 'puppet-slave.test.net' {
>   include users::accounts
>   User <| title="account" |>
> }

Your virtual resource is not a "user", but a define called "users::virtual::account".
So you need to realize it using:

Users::Virtual::Account <| title == "account" |>

Kind regards,

kristof

Brett Maton

unread,
Jun 29, 2012, 12:02:20 PM6/29/12
to puppet...@googlegroups.com
:D

  I knew it would be something simple,  thanks Kristof that's working now.

Brett

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Reply all
Reply to author
Forward
0 new messages