On Sat, Jan 8, 2011 at 3:52 AM, Adam Nielsen <a.niel...@shikadi.net> wrote:

> Hi all,
>
> I'm using the class below to set the timezone on a Debian system, however
> there are two things I'm unhappy with.
>
> 1) Why do I have to specify a trailing colon after the exec command and
> when calling timezone::set?  If I leave it off I get the very helpful error
> "Syntax error at '}'; expected '}'"
>


It's the minimum required syntax for declaring a resource. The : is required
to seperate the resource title and the list of attributes:

resource_type {
  title :
    attribute => value, (trailing comma optional for last attribute, can
omit all default value)
  ; (trailing semicolon optional for single resource)
}

So removing optional parts:
resource_type { title : }


> 2) Because of the exec command, /etc/timezone gets overwritten without a
> backup being made like with other functions.  Is there a way to get the file
> included in the file bucket?  I imagine I'd have to add an "onlyif"
> directive to make sure this only happened if the file contents changed.
>

You can use puppet filebucket command to backup the files before the exec,
but in this case why not use the file resource?

file { "/etc/timezone":
  content => $name,
}

I'm using this function-call "design" in a few places so if it can be
> rewritten in a nicer way I'd like to know as I can then tidy up a few other
> classes too.  This is all I have been able to decipher from the examples
> I've stumbled across.
>
> Many thanks,
> Adam.
>
> -------
>
> class timezone {
>
>  define set($ensure = present) {
>
>    file {
>      "/etc/localtime":
>        ensure  => symlink,
>        target  => "/usr/share/zoneinfo/$name",
>      ;
>    }
>
>    exec { "/bin/echo '${name}' > /etc/timezone": }
>
>  }
>
> }
>
> -------
>
> include timezone
> timezone::set { "Australia/Brisbane": }
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To post to this group, send email to puppet-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users+unsubscr...@googlegroups.com<puppet-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>
>

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

Reply via email to