Ask Your Question

Simple Syntax Error

asked 2018-01-07 04:43:17 -0600

PeteCarter gravatar image

updated 2018-01-09 13:09:22 -0600

DarylW gravatar image

I am brand new to puppet. Trying some simple tutorials to get up to speed, but struggling. Trying to run the following from Powershell:

puppet resource service w32time service { 'w32time': ensure => 'stopped', enable => 'manual' }

But getting the following error:

PS C:\Users\Administrator> puppet resource service w32time
service { 'w32time':
    ensure => 'stopped',
    enable => 'manual'
At line:2 char:20
+ service { 'w32time':
+                    ~
Unexpected token ':' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

What am I doing wrong?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2018-01-09 13:12:25 -0600

DarylW gravatar image

updated 2018-01-09 13:14:38 -0600

If you wish to literally execute puppet code from the command line as opposed to using the 'resource' statements, you can do something like the following:

puppet apply -e "service { 'w32time': ensure => 'stopped', enable => 'manual' }"

Provided that is syntactically correct puppet code, it should work. the -e stands for 'expression'. Make sure to be carefull of shell based expansions, so it may be safer to use ' around the expression and " inside of it, like the following (to potentially prevent any puppet variables from being interpolated on the shell before being passed into puppet.... but in those cases it may be better to put it in a file and call it directly anyway'

puppet apply -e 'service { "w32time": ensure => "stopped", enable => "manual" }'
edit flag offensive delete link more

answered 2018-01-07 11:32:56 -0600

Hi Pete,


puppet resource service w32time ensure=stopped enable=manual

from the cli the syntax is slightly different than when in a manifest file.

hope that helps

Kind Regards


edit flag offensive delete link more


I'm not sure if he would also want to do the same, but with a puppet apply -e step

DarylW gravatar imageDarylW ( 2018-01-09 13:10:32 -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


Asked: 2018-01-07 04:39:49 -0600

Seen: 47 times

Last updated: Jan 09