Ask Your Question

unless statement

asked 2017-02-14 06:37:21 -0600

Chamara gravatar image

updated 2017-02-14 23:44:14 -0600

ramindk gravatar image


I'm trying to write a unless statement like below. But it's giving syntax error near '==' during the agent run. I'm using puppet 2.6.

class user_manage { 

  unless $facts['user_stat'] == "enabled" {   
    user { 'test':
      ensure => present,

Please let me know what's wrong in my class or any other alternative way to get this done.

Thank you.

edit retag flag offensive close merge delete


what is this ..... } } } part ?

raja gravatar imageraja ( 2017-02-14 08:46:47 -0600 )edit

Those 3 are to close user resource, unless statement and the class.

Chamara gravatar imageChamara ( 2017-02-14 11:53:16 -0600 )edit

What is the user_stat fact? Is that a custom fact you wrote? What exactly are you trying to accomplish with the unless? It seems you're wanting to conditionally determine whether or not the user should be created or not. Perhaps a Boolean would serve the use case better?

reesek gravatar imagereesek ( 2017-02-14 20:28:52 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2017-02-14 23:48:06 -0600

ramindk gravatar image

Puppet 2.6 is not supported . Unless was introduced in 3.x

edit flag offensive delete link more


also, I don't think 2.6 has the facts hash, only 3.x with future parser enabled does.

DarylW gravatar imageDarylW ( 2017-02-15 07:04:00 -0600 )edit

answered 2017-02-15 07:00:09 -0600

puser gravatar image
edit flag offensive delete link more

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


Asked: 2017-02-14 06:37:21 -0600

Seen: 310 times

Last updated: Feb 15 '17