Re: [Puppet Users] Puppet 3.2 and Hiera: problem of order and tagged function

2013-07-07 Thread francois . lafont . 1978
Hi,

I'm sorry but I haven't solved my problem yet. I haven't understood the 
answer of David Schmitt. I use Puppet 3.2 and Hierra with yaml files for 
the "classes" assignment. I would like something like that :

class monitoring {

  if tagged(http) {
$http = "OK"
  } else { 
  $http = "NO "
  }
  
  if tagged(mysql) {
$mysql = "OK"
  } else { 
  $mysql = "NO "
  }

  # etc.
  # etc.
}

But, as I have been explained, tagged is parse-order dependent. Is it 
possible to have the same thing but witout parse-order dependency? Is there 
a function like tagged but no parse-order dependency?

--
François Lafont


-- 
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 post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Puppet Users] Puppet 3.2 and Hiera: problem of order and tagged function

2013-07-05 Thread francois . lafont . 1978


Le vendredi 5 juillet 2013 17:43:47 UTC+2, David Schmitt a écrit :

> 2) I would like to have $var == "YES" whatever the order of classes in 
> > the yaml file. Is it possible ? 
>
> tagged() (and all other functions) are parse-order dependent. The stage 
> definition only establishes an application order. 


Ok, thank you for the distinction between "parse-order" and "application 
order", I keep that in mnd. In these conditions, I think the "tagged()" 
function loosing interest.

 

> The recommended way 
> forward is to express the configuration dependency explicitly like so: 
>
>class meta($one = true) { 
>  if $one {
>include one 
>  }  
> or to directly integrate this into the class two. This depends on your 
> actual use case. 
>

Sorry, but I tried to understand your example but I didn't. Do I have to 
put the "meta" class in the yaml file of my host? If yes, I don't see why 
it solves the problem. Sorry. I'm a puppet beginner.

In fact, I'll explain the purpose of my post. I have choose a simplied 
example.
I have a class named "monitoring" (but in my example it's the "two" class) 
in which I want to define some variables according to some other classes 
are used or not by the host. I show you :

class monitoring {

   # if the host uses the http class $http = "http" else $http = "NONE"

   # if the host uses the mysql class $mysql = "mysql" else $mysql = "NONE"

   # etc.
}

I thought tagged() function will make the job but, as you explain me, it's 
order-dependent. I'll try to think about your example...


--
François Lafont

-- 
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 post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.




[Puppet Users] Puppet 3.2 and Hiera: problem of order and tagged function

2013-07-05 Thread francois . lafont . 1978
Hello everybody,

I'm testing Puppet 3.2 and Hiera (installed with http://apt.puppetlabs.com) 
on Debian Wheezy. Here is my "/etc/puppet/manifests/site.pp" file :

---
stage { "one": }
stage { "two": }
Stage['one'] -> Stage['two']
hiera_include('classes')
---

Here is the "init.pp" file of my "one" module :

---
class one  ($stage = "one") {

notify {"Class one is done":
message => "Class one is loaded."
}

}
---

And here is the "init.pp" file of my "two" module :

---
class two ($stage = "two") {

if tagged("one") {
$var = "YES"
}
else {
$var = "NO"
}

notify {"Class two is done":
message => "The value of var is $var."
}

}
---

If I use this yaml file for my host :


---
---
classes:
  - one
  - two
---

then everything is ok ($var == "YES") :

---
# puppet agent --test
Info: Retrieving plugin
Info: Caching catalog for shinken.domaine.priv
Info: Applying configuration version '1373027591'
Notice: Class one is loaded.
Notice: /Stage[one]/One/Notify[Class one is done]/message: defined 
'message' as 'Class one is loaded.'
Notice: The value of var is YES.
Notice: /Stage[two]/Two/Notify[Class two is done]/message: defined 
'message' as 'The value of var is YES.'
Notice: Finished catalog run in 0.16 seconds
---

*But* if I use this yaml file for my host (change the order):

---
---
classes:
  - two
  - one
---

then $var == "NO" :

---
# puppet agent --test
Info: Retrieving plugin
Info: Caching catalog for shinken.domaine.priv
Info: Applying configuration version '1373027591'
Notice: Class one is loaded.
Notice: /Stage[one]/One/Notify[Class one is done]/message: defined 
'message' as 'Class one is loaded.'
Notice: The value of var is NO.
Notice: /Stage[two]/Two/Notify[Class two is done]/message: defined 
'message' as 'The value of var is NO.'
Notice: Finished catalog run in 0.12 seconds
---

Yet, with "Stage['one'] -> Stage['two']", the classed are loaded in the 
good order.

1) Is it normal ?

2) I would like to have $var == "YES" whatever the order of classes in the 
yaml file. Is it possible ?

Thanks in advance.


--
François Lafont





-- 
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 post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.