Ask Your Question
0

unless statement

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

Chamara gravatar image

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

ramindk gravatar image

Hi,

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

Comments

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

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

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

Chamara gravatar imageChamara ( 2017-02-14 11:53:16 -0500 )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 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

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

puser gravatar image
edit flag offensive delete link more
0

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

ramindk gravatar image

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

https://docs.puppet.com/puppet/2.7/la...

edit flag offensive delete link more

Comments

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 -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

1 follower

Stats

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

Seen: 108 times

Last updated: Feb 15