Hi, 

Seems it is not possible, well, I cannot make it work.

Depending on some class parameter, some exported resources should be collected 
or not.

eg. 


class X (
  $collect_tags = ['cond1', 'cond2']
) {

$my_cond = my_magic_function($collect_tags)  # returns the string "tag == 
'cond1' or tag=='cond2'"

My_exp_res <<| $my_cond |>>
}

But the only result I get :  Error 400 on SERVER: Syntax error at '|>>'; 
expected '}'

Whatever i tried, nothing gave me the desired result.  Using single quotes, 
double quotes, escaping quotes ....

And <<| tag == $collect_tags |>> ( <<| tag == ['cond1','cond2'] |>> does not 
give me the desired result, only one exported resource is collected.  But I try 
to ovoid this, because the behavior of this i unpredictable, as documented in 
the docs.

I already I'm a big fan of iteration, but this needs to work on puppet 3.[7|8].x

For now I will change my parameter to a single string and us an if clause like 
...

if  ( $collect_tag =~ /all$/ ) {
  My_exp_res <<|   |>>
} else {
  My_exp_res <<| tag == $collect_tag >>
}

I will loose the ability to collect on multiple nodes this way, but we can live 
with this for the moment.

Peeking to puppetdbquery as an alternative ....

Grts

Johan  


--
Johan De Wit

Open Source Consultant -- Open-Future
 
Red Hat Certified Engineer (805008667232363)
Puppet Certified Professional 2013/2014/2015 (PCP0000006) 
Puppet Certified Instructor
blog : http://johan.koewacht.net/ <http://johan.koewacht.net/>    gsm: +32 474 
42 40 73



-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/zarafa.57025d01.7ea3.4d0266ef7d528365%40zarafa.open-future.be.
For more options, visit https://groups.google.com/d/optout.

Reply via email to