Feature #1194

Support hooking into host creation/deletion

Added by Benjamin Goldsbury almost 11 years ago. Updated over 9 years ago.

Plugin integration
Target version:
Bugzilla link:
Pull request:
Fixed in Releases:
Found in Releases:


Since the goal of Foreman is to support life-cycle management, it should have support for doing business-specific tasks based.

For example, we generate custom SSL certificates for various services on each host we run. While this could be accomplished in Puppet, it seems that Foreman is the more logical place to control this behavior.

This could be accomplished via a plugin architecture or just an option of "script to run when creating a host" and "script to run when deleting a host".

Related issues

Related to Foreman - Feature #1353: Foreman should be able to handle pre and post hook action.Closed2011-11-24
Related to Foreman - Feature #58: trigger actions when a New sucessful host is addedClosed2009-11-03


#1 Updated by Ohad Levy almost 11 years ago

would a simple script executed by foreman user would suffice?

at the moment, since there are is no background processing in foreman, the request would block the UI (e.g. the UI would wait until the script would finish)

#2 Updated by Benjamin Goldsbury almost 11 years ago

Seems fine to me. Would be nice if Foreman could capture stdout/stderr and/or warn the user on a non-0 exit of the script.

#3 Updated by Ohad Levy almost 11 years ago

would you like to get a notice in the UI / email ?

who should be noticed? the owner of the host? the creator of the host?

#4 Updated by Benjamin Goldsbury almost 11 years ago

I think notification through the UI is a reasonable starting place.

#5 Updated by Ohad Levy over 10 years ago

following a discussion on irc
here is an example

#6 Updated by marcelo veglienzone about 10 years ago

I would like to see something like this to have foreman update freeipa upon host creation

#7 Updated by Joseph Magen over 9 years ago

You can implement hooking into host creation/deletion by writing a Foreman Plugin -

Just follow the example at

module HostExtensions
  extend ActiveSupport::Concern

  included do
    execute standard callbacks
    after_create :do_this
    after_destroy :do_that

    execute custom hooks
    after_ready_for_build :do_something_special_after_build
    def do_something_special_after_build
      p "doing customized callback something special AFTER build" 

#8 Updated by Ohad Levy over 9 years ago

  • Category set to Plugin integration
  • Status changed from New to Resolved
  • Assignee set to Joseph Magen
  • Target version set to 1.1

Also available in: Atom PDF