Finding out which hosts are in a hostgroup from within a puppet class

Hello,

I'm trying to use foreman/puppet to setup a pacemaker cluster.

The command to configure a cluster looks like this:

pcs cluster setup --name mycluster node1 node2 node3 …

This command you have to perform on each node.

Now what I would like to do is somehow make this easy by creating class,
and assigning this class to a host group. Now I would like to somehow find
out what the members of a hostgroup are from within this class, so I can
use that to build the command that needs to be executed.

Is there a straightforward way to do this?

Krist

> Hello,
>
> I'm trying to use foreman/puppet to setup a pacemaker cluster.
>
> The command to configure a cluster looks like this:
>
> pcs cluster setup --name mycluster node1 node2 node3 …
>
> This command you have to perform on each node.
>
> Now what I would like to do is somehow make this easy by creating class, and
> assigning this class to a host group. Now I would like to somehow find out
> what the members of a hostgroup are from within this class, so I can use
> that to build the command that needs to be executed.
>
> Is there a straightforward way to do this?

Sure,I think a step in the right direction would be

Ohad

··· On Wed, Nov 27, 2013 at 3:23 PM, Krist van Besien wrote: > > Krist > > > -- > You received this message because you are subscribed to the Google Groups > "Foreman users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to foreman-users+unsubscribe@googlegroups.com. > To post to this group, send email to foreman-users@googlegroups.com. > Visit this group at http://groups.google.com/group/foreman-users. > For more options, visit https://groups.google.com/groups/opt_out.

I tried this:

$clustermembers = foreman('hosts',"hostgroup = ${hostgroup}")
$mysql_clu_member_addrs = join($clustermembers, " ")

And I got this:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER:
Unknown function foreman

So obviously I'm missing something. But what?

Krist

··· On Wednesday, November 27, 2013 2:41:59 PM UTC+1, ohad wrote: > > > > Sure,I think a step in the right direction would be > http://blog.theforeman.org/2012/01/getting-foreman-search-results-into.html >

I think you forgot to create the function.

Either that or Ohad has changed something as this gets installed when you
install foreman via the installer. But as the error cant find the function
my money is on the first one.

··· On Wednesday, November 27, 2013 4:39:22 PM UTC+1, Krist van Besien wrote: > > > > On Wednesday, November 27, 2013 2:41:59 PM UTC+1, ohad wrote: >> >> >> >> Sure,I think a step in the right direction would be >> >> http://blog.theforeman.org/2012/01/getting-foreman-search-results-into.html >> > > I tried this: > > $clustermembers = foreman('hosts',"hostgroup = ${hostgroup}") > $mysql_clu_member_addrs = join($clustermembers, " ") > > And I got this: > Error: Could not retrieve catalog from remote server: Error 400 on SERVER: > Unknown function foreman > > So obviously I'm missing something. But what? > > Krist > > > > >

> I think you forgot to create the function.
>
> https://github.com/ohadlevy/puppet-foreman/blob/master/foreman/lib/puppet/parser/functions/foreman.rb
>
> Either that or Ohad has changed something as this gets installed when you
> install foreman via the installer. But as the error cant find the function
> my money is on the first one.
>
indeed the installer distribute this function by default, however, the
one you refered to is pretty old, please use
https://github.com/theforeman/puppet-foreman/blob/master/lib/puppet/parser/functions/foreman.rb

Ohad

··· On Thu, Nov 28, 2013 at 8:52 AM, Jelle B wrote: > > On Wednesday, November 27, 2013 4:39:22 PM UTC+1, Krist van Besien wrote: >> >> >> >> On Wednesday, November 27, 2013 2:41:59 PM UTC+1, ohad wrote: >>> >>> >>> >>> Sure,I think a step in the right direction would be >>> >>> http://blog.theforeman.org/2012/01/getting-foreman-search-results-into.html >> >> >> I tried this: >> >> $clustermembers = foreman('hosts',"hostgroup = ${hostgroup}") >> $mysql_clu_member_addrs = join($clustermembers, " ") >> >> And I got this: >> Error: Could not retrieve catalog from remote server: Error 400 on SERVER: >> Unknown function foreman >> >> So obviously I'm missing something. But what? >> >> Krist >> >> >> >> > > -- > You received this message because you are subscribed to the Google Groups > "Foreman users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to foreman-users+unsubscribe@googlegroups.com. > To post to this group, send email to foreman-users@googlegroups.com. > Visit this group at http://groups.google.com/group/foreman-users. > For more options, visit https://groups.google.com/groups/opt_out.