Ask Your Question
2

Can you chain to a conditional?

asked 2013-01-17 14:40:22 -0500

llowder gravatar image

updated 2013-01-17 15:07:10 -0500

(Updated due to simplifying too much, still very simplified but reflects the actual problem now)

Over simplified mytest.pp:

$myclass = "bar"

class{ foo: } ->
class{ foobar: } ->
class{ barbat: } ->
if $myclass == "bar" {
  class{ bar: }
}

class foo{
  notify { "Foo class": }
}

class bar{
  notify { "Bar class": }
}

class barbar{
  notify { "barBar class": }
}

class foobar{
  notify { "FooBar class": }
}

When I run puppet apply mytest.pp I get the following output:

Error: Could not parse for environment production: Syntax error at 'if' at /XXXX/mytest.pp:6 on node XXXXXXX
Error: Could not parse for environment production: Syntax error at 'if' at /XXXX/mytest.pp:6 on ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2013-01-17 14:49:17 -0500

Andrew Gaffney gravatar image

updated 2013-01-17 15:17:49 -0500

This might work:

class{ foo: } ->
class{ foobar: } ->
class{ barbat: }
if $myclass != "bar" {
  Class['barbat'] -> class{ bar: }
}
edit flag offensive delete link more

Comments

I updated my question, I realized that I had made it too simple at first and it didn't reflect the actual use case.

llowder gravatar imagellowder ( 2013-01-17 15:10:12 -0500 )edit

It worked. Thanks!

llowder gravatar imagellowder ( 2013-01-17 15:29:33 -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

Stats

Asked: 2013-01-17 14:40:22 -0500

Seen: 747 times

Last updated: Jan 17 '13