Using compute resource information from foreman in puppet

Hello,

We manage VMs (KVM on RHEL) via Foreman. That means that I foreman knows
which VM runs on which Bare Metal host. I can see that by looking at the
compute resources screen on the web interface.

What I'd like to know is if I can als use this information in puppet
itself. I would like to use the name of the bare metal host a VM runs on in
a puppet manifest I run on a virtual machine. Is there a way?

Thanks in advance,

> Hello,
>
> We manage VMs (KVM on RHEL) via Foreman. That means that I foreman knows
> which VM runs on which Bare Metal host. I can see that by looking at the
> compute resources screen on the web interface.
>
> What I'd like to know is if I can als use this information in puppet
> itself. I would like to use the name of the bare metal host a VM runs on in
> a puppet manifest I run on a virtual machine. Is there a way?
>
> Thanks in advance,
>

goto global parameters and add a new parameter e.g. compute, its value
would be :

<%= @host.compute_resource.try(:to_label) || 'Bare Metal' %>

as an example, you can use this motd erb template:

This host belongs to the <%= organization rescue 'None' %> organization,
its role is <%= hostgroup rescue 'unknown' %>, its located at <%=
location rescue 'unknown' %> and owned by <%= owner_name %> (<%=
owner_email %>)
<% if compute -%>
Running on <%= compute %>
<% end -%>

You might need to turn off safe mode rendering.

hope this helps,
Ohad

··· On Wed, Sep 10, 2014 at 7:39 AM, Krist van Besien wrote:


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/d/optout.

When I do this everything breaks…

I get a "Error: Could not retrieve catalog from remote server: Error 400 on
SERVER:". In order to find out why I ran node.rb by hand and got:

Error retrieving node <nodename>: Net::HTTPPreconditionFailed

This looked promissing, but didn't work…

Krist

··· On Wednesday, September 10, 2014 9:53:36 AM UTC+2, ohad wrote: > > > > On Wed, Sep 10, 2014 at 7:39 AM, Krist van Besien > wrote: > >> Hello, >> >> We manage VMs (KVM on RHEL) via Foreman. That means that I foreman knows >> which VM runs on which Bare Metal host. I can see that by looking at the >> compute resources screen on the web interface. >> >> What I'd like to know is if I can als use this information in puppet >> itself. I would like to use the name of the bare metal host a VM runs on in >> a puppet manifest I run on a virtual machine. Is there a way? >> >> Thanks in advance, >> > > goto global parameters and add a new parameter e.g. compute, its value > would be : > > <%= @host.compute_resource.try(:to_label) || 'Bare Metal' %> >

>
>
>
>>
>>
>>
>>>
>>> Hello,
>>>
>>> We manage VMs (KVM on RHEL) via Foreman. That means that I foreman
knows which VM runs on which Bare Metal host. I can see that by looking at
the compute resources screen on the web interface.
>>>
>>> What I'd like to know is if I can als use this information in puppet
itself. I would like to use the name of the bare metal host a VM runs on in
a puppet manifest I run on a virtual machine. Is there a way?
>>>
>>> Thanks in advance,
>>
>>
>> goto global parameters and add a new parameter e.g. compute, its value
would be :
>>
>> <%= @host.compute_resource.try(:to_label) || 'Bare Metal' %>
>
>
> When I do this everything breaks…
>
> I get a "Error: Could not retrieve catalog from remote server: Error 400
on SERVER:". In order to find out why I ran node.rb by hand and got:
>
> Error retrieving node <nodename>: Net::HTTPPreconditionFailed
>
> This looked promissing, but didn't work…
>

What's the error in foreman logs, IMHO you need to turn off safe mode
rendering in settings.

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

··· On Sep 18, 2014 12:14 PM, "Krist van Besien" wrote: > On Wednesday, September 10, 2014 9:53:36 AM UTC+2, ohad wrote: >> On Wed, Sep 10, 2014 at 7:39 AM, Krist van Besien wrote: > 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/d/optout.

There is no error in the log file, and AFAIK turning off safe mode hasn't
been necessary for the last few release…

Krist

··· On Thursday, September 18, 2014 11:55:33 AM UTC+2, ohad wrote: > > > On Sep 18, 2014 12:14 PM, "Krist van Besien" > wrote: > > > > > > > > On Wednesday, September 10, 2014 9:53:36 AM UTC+2, ohad wrote: > >> > >> > >> > >> On Wed, Sep 10, 2014 at 7:39 AM, Krist van Besien > wrote: > >>> > >>> Hello, > >>> > >>> We manage VMs (KVM on RHEL) via Foreman. That means that I foreman > knows which VM runs on which Bare Metal host. I can see that by looking at > the compute resources screen on the web interface. > >>> > >>> What I'd like to know is if I can als use this information in puppet > itself. I would like to use the name of the bare metal host a VM runs on in > a puppet manifest I run on a virtual machine. Is there a way? > >>> > >>> Thanks in advance, > >> > >> > >> goto global parameters and add a new parameter e.g. compute, its value > would be : > >> > >> <%= @host.compute_resource.try(:to_label) || 'Bare Metal' %> > > > > > > When I do this everything breaks... > > > > I get a "Error: Could not retrieve catalog from remote server: Error 400 > on SERVER:". In order to find out why I ran node.rb by hand and got: > > > > Error retrieving node : Net::HTTPPreconditionFailed > > > > This looked promissing, but didn't work... > > > > What's the error in foreman logs, IMHO you need to turn off safe mode > rendering in settings. >

>
>
>>
>>
>> >
>> >
>> >
>> >>
>> >>
>> >>
>> >>>
>> >>> Hello,
>> >>>
>> >>> We manage VMs (KVM on RHEL) via Foreman. That means that I foreman
>> knows which VM runs on which Bare Metal host. I can see that by looking at
>> the compute resources screen on the web interface.
>> >>>
>> >>> What I'd like to know is if I can als use this information in puppet
>> itself. I would like to use the name of the bare metal host a VM runs on in
>> a puppet manifest I run on a virtual machine. Is there a way?
>> >>>
>> >>> Thanks in advance,
>> >>
>> >>
>> >> goto global parameters and add a new parameter e.g. compute, its value
>> would be :
>> >>
>> >> <%= @host.compute_resource.try(:to_label) || 'Bare Metal' %>
>> >
>> >
>> > When I do this everything breaks…
>> >
>> > I get a "Error: Could not retrieve catalog from remote server: Error
>> 400 on SERVER:". In order to find out why I ran node.rb by hand and got:
>> >
>> > Error retrieving node <nodename>: Net::HTTPPreconditionFailed
>> >
>> > This looked promissing, but didn't work…
>> >
>>
>> What's the error in foreman logs, IMHO you need to turn off safe mode
>> rendering in settings.
>>
>
> There is no error in the log file, and AFAIK turning off safe mode hasn't
> been necessary for the last few release…
>

for this snippet to work you need to turn off safe rendering.
Ohad

··· On Mon, Sep 22, 2014 at 12:43 PM, Krist van Besien < krist.vanbesien@gmail.com> wrote: > On Thursday, September 18, 2014 11:55:33 AM UTC+2, ohad wrote: >> On Sep 18, 2014 12:14 PM, "Krist van Besien" >> wrote: >> > On Wednesday, September 10, 2014 9:53:36 AM UTC+2, ohad wrote: >> >> On Wed, Sep 10, 2014 at 7:39 AM, Krist van Besien < >> krist.v...@gmail.com> 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/d/optout.