Foreman Plugin: Do action after successful puppet run

Hi,

I'm still really new to foreman but I am trying to develop a plugin to send
REST queries to another web service after a puppet agent checks in. I have
some questions:

  1. Is this best done as a puppet module or a foreman plugin?
  2. Is there a specific action? I looked at the hubot_notify foreman plugin.
    Seemed to be looking at provision, built, and finish actions. Right now we
    aren't using puppet to actually install OSes or build from images. We are
    using puppet to check into agents and make sure they have the necessary
    applications/packages. Does that still use provision, built, or finish?
    What is the difference between provision, built, and finish?
  3. I see in the Hosts::Managed model, there are hooks written. Not sure how
    I go about using these or if they are even relevant to what I want to
    do.(See question defining provision)

Thanks,
Anthony

Looking at hubot notify, it only does provision events. Hooks should be
able to do what you need to do:
https://github.com/theforeman/foreman_hooks

I would try to hook onto report create. Your hook script would get the
puppet report (or at least, Foreman's representation of it) as a JSON
object on STDIN.

··· On Tue, Nov 04, 2014 at 05:19:52PM -0800, Anthony Scudese wrote: > Hi, > > I'm still really new to foreman but I am trying to develop a plugin to send > REST queries to another web service after a puppet agent checks in. I have > some questions: > > 1. Is this best done as a puppet module or a foreman plugin? > 2. Is there a specific action? I looked at the hubot_notify foreman plugin. > Seemed to be looking at provision, built, and finish actions. Right now we > aren't using puppet to actually install OSes or build from images. We are > using puppet to check into agents and make sure they have the necessary > applications/packages. Does that still use provision, built, or finish? > What is the difference between provision, built, and finish? > 3. I see in the Hosts::Managed model, there are hooks written. Not sure how > I go about using these or if they are even relevant to what I want to > do.(See question defining provision)


Stephen Benjamin


Red Hat GmbH | http://de.redhat.com/ | Sitz: Grasbrunn
Handelsregister: Amtsgericht München, HRB 153243
Geschäftsführer: Charles Cachera, Michael Cunningham,
Michael O’Neill, Charles Peters

Thanks Stephen. Does foreman hooks only work with executables like bash and
shell scripts? I have this service already setup in Ruby(not using Rails)
and was hoping to stay in ruby. It also looks like I wouldn't have access
to a host's facts? I would have the FQDN which I then would have to contact
the api to get? Seems a round about way where as if I was plugged into the
application I would already have access to managed host model and then thus
its facts. My service gathers facts and sends them another web service.

··· On Wednesday, November 5, 2014 2:45:27 AM UTC-5, Stephen Benjamin wrote: > > On Tue, Nov 04, 2014 at 05:19:52PM -0800, Anthony Scudese wrote: > > Hi, > > > > I'm still really new to foreman but I am trying to develop a plugin to > send > > REST queries to another web service after a puppet agent checks in. I > have > > some questions: > > > > 1. Is this best done as a puppet module or a foreman plugin? > > 2. Is there a specific action? I looked at the hubot_notify foreman > plugin. > > Seemed to be looking at provision, built, and finish actions. Right now > we > > aren't using puppet to actually install OSes or build from images. We > are > > using puppet to check into agents and make sure they have the necessary > > applications/packages. Does that still use provision, built, or finish? > > What is the difference between provision, built, and finish? > > 3. I see in the Hosts::Managed model, there are hooks written. Not sure > how > > I go about using these or if they are even relevant to what I want to > > do.(See question defining provision) > > Looking at hubot notify, it only does provision events. Hooks should be > able to do what you need to do: > https://github.com/theforeman/foreman_hooks > > I would try to hook onto report create. Your hook script would get the > puppet report (or at least, Foreman's representation of it) as a JSON > object on STDIN. > > > > > -- > Stephen Benjamin > > ______________________________________________________ > Red Hat GmbH | http://de.redhat.com/ | Sitz: Grasbrunn > Handelsregister: Amtsgericht München, HRB 153243 > Geschäftsführer: Charles Cachera, Michael Cunningham, > Michael O'Neill, Charles Peters > > >

> Thanks Stephen. Does foreman hooks only work with executables like bash and
> shell scripts? I have this service already setup in Ruby(not using Rails)
> and was hoping to stay in ruby. It also looks like I wouldn't have access
> to a host's facts? I would have the FQDN which I then would have to contact
> the api to get? Seems a round about way where as if I was plugged into the
> application I would already have access to managed host model and then thus
> its facts. My service gathers facts and sends them another web service.

Right, it won't send the facts, you'd have to call the API. Foreman
hooks can use any execuable, including a ruby script, but if a plugin
to Foreman works better you can certainly do it that way.

··· On Tue, Nov 11, 2014 at 12:50:03PM -0800, Anthony Scudese wrote:

On Wednesday, November 5, 2014 2:45:27 AM UTC-5, Stephen Benjamin wrote:

On Tue, Nov 04, 2014 at 05:19:52PM -0800, Anthony Scudese wrote:

Hi,

I’m still really new to foreman but I am trying to develop a plugin to
send
REST queries to another web service after a puppet agent checks in. I
have
some questions:

  1. Is this best done as a puppet module or a foreman plugin?
  2. Is there a specific action? I looked at the hubot_notify foreman
    plugin.
    Seemed to be looking at provision, built, and finish actions. Right now
    we
    aren’t using puppet to actually install OSes or build from images. We
    are
    using puppet to check into agents and make sure they have the necessary
    applications/packages. Does that still use provision, built, or finish?
    What is the difference between provision, built, and finish?
  3. I see in the Hosts::Managed model, there are hooks written. Not sure
    how
    I go about using these or if they are even relevant to what I want to
    do.(See question defining provision)

Looking at hubot notify, it only does provision events. Hooks should be
able to do what you need to do:
https://github.com/theforeman/foreman_hooks

I would try to hook onto report create. Your hook script would get the
puppet report (or at least, Foreman’s representation of it) as a JSON
object on STDIN.


Stephen Benjamin


Red Hat GmbH | http://de.redhat.com/ | Sitz: Grasbrunn
Handelsregister: Amtsgericht München, HRB 153243
Geschäftsführer: Charles Cachera, Michael Cunningham,
Michael O’Neill, Charles Peters