Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Foreman plugin that just executes a given command.


Just download the gem file or build it from source:

gem build foreman_plugin_exec_cmd.gemspec

Then install the plugin by adding it to foreman

gem install foreman_plugin_exec_cmd

and add it to the bundle environment: echo 'gem "foreman_plugin_exec_cmd"' > bundle.d/foreman_plugin_exec_cmd.rb

Then bundle update.

bundle update


Now enable the plugin in the foreman settings.yaml file and specify a command to be called e.g.:

cat >>config/settings.yaml << EOF 
  :enabled: true
  :cmd: 'cat &gt; /tmp/#{}.out'
  :aspipe: '{:host => self, :host_params => self.host_params, :partitioninclude => self.diskLayout, :networkinclude => self.renderTemplate, :owner => self.owner, :interfaces => self.interfaces}.to_json'

The aspipe parameter specifies a valid ruby command that will pipe the standard output to the command specified as cmd.

The self attribute referres to the Host::Managed class of the host being passed to the callback.

In this example the given parameters of the host are used to construct as hash that is afterwards converted to the JSON format. This could then be used by any other command understanding the JSON input. In this case the JSON is just written to the file /tmp/#{}.out.

Source Code

UML Documentation

Use Case

This image describes the current use case how foreman calls this plugin. Also see: Foreman Template Writing ![Call foreman_plugin_exec_cmd](doc/Call foreman_plugin_exec_cmd.jpg "Usecase how foreman_plugin_exec_cmd is called")

Class Diagram

Class diagram foreman_plugin_exec_cmd

Basically the plugin consists of one class that corresponds to two files:

app/models/foreman_plugin_exec_cmd/host_extension.rb and lib/foreman_plugin_exec_cmd/util.rb.

In host_extension.rb the callbacks are defined that are being called for the following events:

  • after_create
  • after_build
  • before_provision

These themselves call the class method exec_cmd_object.


This file defines the methods for executing external commands. First the plugin is checked for being enabled.

The method exec_cmd_object method.


Copyright (c) 2012-2013 ATIX AG.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see


Foreman Plugin for executing a given command on specific hooks.




No releases published


No packages published
You can’t perform that action at this time.