Ask Your Question
0

I am constantly getting syntax error in site.pp while trying to use parametrized class for passing values.

asked 2017-09-18 08:04:14 -0600

shajics gravatar image

updated 2017-09-18 08:09:04 -0600

DarylW gravatar image

.

root@master:/etc/puppet/manifests# cat site.pp
class base {
  include ssh
}

node 'agent.thomsonreuters.com' {
  class { 'phase60':
    $mode => 'standalone',
    $release => 'v4',
  }
}

node 'agent2.thomsonreuters.com' {
  include base
}

node 'agent3.thomsonreuters.com' {
  include phase60
}

root@master:/etc/puppet/manifests#

Iam running the "puppet agent -t" in the agent.thomsonreuters.com and i get below error

root@agent:/# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not parse for environment production: Syntax error at 'mode'; expected '}' at /etc/puppet/manifests/site.pp:7 on node agent.thomsonreuters.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
root@agent:/#

The below is my init.pp file

root@master:/etc/puppet/modules/phase60/manifests# cat init.pp
class phase60 ($mode,$release)
{
  if ! ($mode in ['standalone', 'rac']) {
    fail('lion mode parameter must be standalone or rac')
  }

  if ! ($release in ['v1', 'v2', 'v3', 'v4']) {
    fail('lion release parameter must be v1, v2, v3, or v4')
  }


  include phase60::os_package
  include phase60::swap_memory
  include phase60::users
}
root@master:/etc/puppet/modules/phase60/manifests#

Any help would be much appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-09-18 08:11:28 -0600

DarylW gravatar image

The correct syntax for calling a parameter is to not have the leading $ symbol. That is what you use inside your class to declare it as a parameter value, but when you are passing it in, it is a hash syntax, so you need it to be the following:

class base {
  include ssh
}

node 'agent.thomsonreuters.com' {
  class { 'phase60':
    mode => 'standalone',
    release => 'v4',
  }
}

node 'agent2.thomsonreuters.com' {
  include base
}

node 'agent3.thomsonreuters.com' {
  include phase60
}
edit flag offensive delete link more

Comments

Thank you....that fixed the issue...!!!

shajics gravatar imageshajics ( 2017-09-18 08:15:23 -0600 )edit

Glad I could help! Since this solved your issue, can you 'accept' my answer as solving your problem by clicking the check to the left of my post, to help people in the future searching for issues?

DarylW gravatar imageDarylW ( 2017-09-19 07:01:08 -0600 )edit
1

Done....!!

shajics gravatar imageshajics ( 2017-09-19 07:03:48 -0600 )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

1 follower

Stats

Asked: 2017-09-18 08:04:14 -0600

Seen: 38 times

Last updated: Sep 18