Ask Your Question
0

Syntax error at '}'; expected '}'

asked 2016-09-26 09:27:28 -0500

erichymowitz gravatar image

updated 2016-09-26 09:29:01 -0500

So the error message

Syntax error at '}'; expected '}'

is not helping me find my problem.

I'm trying to do something tricky, where I have this (shortened and anonymized) and the $cron variable set to mon:12:0,wed:9:30

class symantec
(
  $version,
  $style = "unmanaged",
  $cron = '',
)
{
  define createCronJob {
    $lines = split ($name,',')
    $lines[0] = split ($lines[0],':')
    $lines[1] = split ($lines[1],':')
    file { 'symantec.cron' :
          ensure => file,
          path => "/etc/cron.d/symantec.liveupdate.cron",
          content =>
"#
# this file is managed by puppet.
#
${lines[0][2]} ${lines[0][1]} * * ${lines[0][0]} root /usr/local/bin/system_patch.pl
${lines[1][2]} ${lines[1][1]} * * ${lines[1][0]} root /usr/local/bin/system_patch.pl
"
        }
  }
  if $style == "unmanaged"
  {
    createCronJob { [ $cron ] }   /* <= <= <= line with the error */
  }
}

It's supposed to create a file that looks like this:

#
# this file is managed by puppet.
#
0 12 * * mon root /usr/local/bin/system_patch.pl
30 9 * * wed root /usr/local/bin/system_patch.pl

I can take out the offending line and the catalog compiles and runs fine. I tested it separately with puppet apply and it was working and created the file. But I must be doing something different and I don't know what.

So I guess I have two questions.

Why does the error message seem to make no sense?

How can I properly call my defined function to create the file?

edit retag flag offensive close merge delete

Comments

Please outsource the defined type definition into a separate manifest. Does the `cron` native resource type really not suit your problem?

Kai Burghardt gravatar imageKai Burghardt ( 2016-09-26 10:35:40 -0500 )edit

@KaiBurghardt Actually, the underlying problem was "How to iterate over an array in a language that doesn't support iterating over arrays." But iirc, the cron native resource works in the user's crontab file, and we prefer the jobs to be in /etc/cron.d/

erichymowitz gravatar imageerichymowitz ( 2016-09-26 10:56:04 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-09-26 10:36:26 -0500

You're missing a colon: createCronJob { [ $cron ]: }

edit flag offensive delete link more

Comments

Thank you!!!

erichymowitz gravatar imageerichymowitz ( 2016-09-26 10:56:30 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2016-09-26 09:27:28 -0500

Seen: 41 times

Last updated: Sep 26 '16