3

I'm just getting started with Puppet and I have the following code in my test site.pp file:

class { 'account': {
  'danny':
     home_dir => '/home/danny',
     groups   => [ 'sudo', 'users' ],
     password => 'password'
  }
}

I'm trying to use the account module from Puppet Forge. I have checked that the module is installed correctly.

The error given when using the above code is:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not parse for environment production: Syntax error at '{'; expected '}' at /etc/puppet/manifests/site.pp:12 on node testpuppet.domain.io Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run

Line 12 of site.pp is:

class { 'account': {

The documentation gives the following example:

account { 
  'sysadmin':
    home_dir => '/opt/sysadmin',
    groups   => [ 'sudo', 'users' ],
    ssh_key  => 'AAAAB3NzaC1yc2EAAAABIwAAAQEArfQmMkvtWRnwas3DIti9qAuSFQXKcE0kdp5f42PP8l2kTytJPPWp5T/q8PXDQ2d2X5KplMCMDiUQkchqhmDp840jsqBQ9iZPejAjv3w2kITgScFNymAcErtzX52iw4lnUyjZzomCW8G3YthQMaRm2NkI4wcVcjzq+SKyTfzrBoH21RgZlfcx+/50AFRrarpYqel9W5DuLmmShHxD8clPS532Z/1X+1jCW2KikUhdo98lxYTIgFno05lwFOS9Ry89UyBarn1Ecp1zXpIBE7dMQif3UyLUTU9zCVIoZiJj4iO5lemSSV0v8GL97qclBUVJpaCpc4ebR7bhi0nQ28RcxQ==',
    comment   => 'SysAdmin user',
}

all the other modules that I'm using are within a class, such as the NTP module:

class { 
  '::ntp': 
  servers => [ 
    '0.uk.pool.ntp.org', 
    '1.uk.pool.ntp.org', 
    '2.uk.pool.ntp.org', 
    '3.uk.pool.ntp.org' 
  ], 
}

What would the correct syntax be to use the account module?

10

You can name your classes as you want, but you need to use the right name for resources. In this case, the resource you want to use is user.

There is a very simple way to know how a resource should look:

$ puppet resource user dawud
user { 'dawud':
  ensure  => 'present',
  comment => 'David Sastre Medina,,,',
  gid     => '1001',
  groups  => ['sudo', 'audio', 'src', 'video', 'libvirt'],
  home    => '/home/dawud',
  shell   => '/bin/bash',
  uid     => '1001',
}

That code, inside a class would look:

class foo {
   user { 'dawud':
      ensure  => 'present',
      comment => 'David Sastre Medina,,,',
      gid     => '1001',
      groups  => ['sudo', 'audio', 'src', 'video', 'libvirt'],
      home    => '/home/dawud',
      shell   => '/bin/bash',
      uid     => '1001',
    }
}

Puppetlabs have a very good documentation on the resource abstraction layer, RAL for short.

  • That looks to be exactly what I needed to know, how did you know that the resource was called user? Is this even using the account module at all? – dannymcc Jul 20 '13 at 12:09
  • Read the documentation I linked in my answer. – dawud Jul 20 '13 at 12:11
  • Ahh sorry didn't see the link on the last line - thank you! – dannymcc Jul 20 '13 at 12:13
2

I'm no puppet whiz, but you have an unmatched { in your sample. You have one open brace for class and another for account, but you only ever close the account brace.

  • Well spotted, adding another close brace didn't fix the problem or alter the error. Good spot though! – dannymcc Jul 20 '13 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.