foreman_hooks 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc10f54a3ede56411fb9702eacd35b19a340a49f
4
- data.tar.gz: 33853d25749e467ae70a156c1ef59980874f6c93
3
+ metadata.gz: 89ca0cd0fe9eea695a2ba74c390f3a7366191551
4
+ data.tar.gz: 9d542ea2ef4121c46249bbc2d1f7c24b4574ad4d
5
5
  SHA512:
6
- metadata.gz: 498e8466d6626c622351b7f0047f36e9ce8836caf9bdd04af6428c2b0e47782ffab6507bf44f66338310179565fd5c349d34ae8359fb7eb70860a5ba0a5fbe8c
7
- data.tar.gz: 96e4a89cf183390aefe482250a29c9cf604f7ea26c57aa86d1496878e6a28dbee8733e5c1d19a41f7d84d3ec4a36dc1b47347bdd19a2b276964ddda467143574
6
+ metadata.gz: 5c62797e52f6965700536068d6c782fcc65b835c36f5108d965459aa6195ac6167f3687c9feb7751649df2c055074eb1f47180189bae51dd6a42d2cfa8968568
7
+ data.tar.gz: 4650f6a9156b8ef5d8d4628bfa52f2e44fd148155f26fe0bd7b00a01ebd440706e7d5d8a5c7a0968c58efd230b021fe0426b83a7c3b93a9c57b0233a79c07738
data/README.md CHANGED
@@ -10,20 +10,14 @@ Foreman object, all with shell scripts.
10
10
 
11
11
  # Installation:
12
12
 
13
- If you're using an RPM based installation, please use the packages provided in
14
- the plugin repos at http://yum.theforeman.org/plugins.
13
+ Please see the Foreman wiki for appropriate instructions:
15
14
 
16
- For other setups, include in your `~foreman/bundler.d/foreman_hooks.rb`
15
+ * [Foreman: How to Install a Plugin](http://projects.theforeman.org/projects/foreman/wiki/How_to_Install_a_Plugin)
17
16
 
18
- gem 'foreman_hooks'
17
+ The gem name is "foreman_hooks".
19
18
 
20
- Or from git:
21
-
22
- gem 'foreman_hooks', :git => "https://github.com/domcleal/foreman_hooks.git"
23
-
24
- Regenerate Gemfile.lock or upgrade to the latest version of the plugin:
25
-
26
- cd ~foreman && sudo -u foreman bundle update foreman_hooks
19
+ RPM users can install the "ruby193-rubygem-foreman_hooks" or
20
+ "rubygem-foreman_hooks" packages.
27
21
 
28
22
  # Usage
29
23
 
@@ -34,12 +28,11 @@ with a subdirectory for the object, then a subdirectory for the event name.
34
28
 
35
29
  Examples:
36
30
 
37
- ~foreman/config/hooks/host/create/50_register_system.sh
38
- ~foreman/config/hooks/host/destroy/15_cleanup_database.sh
31
+ ~foreman/config/hooks/host/managed/create/50_register_system.sh
32
+ ~foreman/config/hooks/host/managed/destroy/15_cleanup_database.sh
39
33
  ~foreman/config/hooks/smart_proxy/after_create/01_email_operations.sh
40
34
 
41
- In Foreman 1.1, all hosts are `host` but in Foreman 1.2, managed hosts will
42
- become `host/managed` instead.
35
+ (`host/managed` is for Foreman 1.2+, change to just `host` for Foreman 1.1)
43
36
 
44
37
  ## Objects / Models
45
38
 
@@ -78,8 +71,8 @@ documentation.
78
71
 
79
72
  The host object has two additional callbacks that you can use:
80
73
 
81
- * `host/after_build` triggers when a host is put into build mode
82
- * `host/before_provision` triggers when a host completes the OS install
74
+ * `host/managed/after_build` triggers when a host is put into build mode
75
+ * `host/managed/before_provision` triggers when a host completes the OS install
83
76
 
84
77
  ## Execution of hooks
85
78
 
@@ -90,7 +83,7 @@ The first argument is always the event name, enabling scripts to be symlinked
90
83
  into multiple event directories. The second argument is the string
91
84
  representation of the object that was hooked, e.g. the hostname for a host.
92
85
 
93
- ~foreman/config/hooks/host/create/50_register_system.sh create foo.example.com
86
+ ~foreman/config/hooks/host/managed/create/50_register_system.sh create foo.example.com
94
87
 
95
88
  A JSON representation of the hook object will be passed in on stdin. A utility
96
89
  to read this with jgrep is provided in `examples/hook_functions.sh` and
@@ -98,7 +91,7 @@ sourcing this utility script will be enough for most users. Otherwise, you
98
91
  may want to ensure stdin is closed.
99
92
 
100
93
  echo '{"host":{"name":"foo.example.com"}}' \
101
- | ~foreman/config/hooks/host/create/50_register_system.sh \
94
+ | ~foreman/config/hooks/host/managed/create/50_register_system.sh \
102
95
  create foo.example.com
103
96
 
104
97
  Every hook within the event directory is executed in alphabetical order. For
@@ -4,6 +4,8 @@ module ForemanHooks
4
4
  require 'foreman_hooks/callback_hooks'
5
5
  require 'foreman_hooks/orchestration_hook'
6
6
 
7
+ class Error < RuntimeError; end
8
+
7
9
  class << self
8
10
  def hooks_root
9
11
  File.join(Rails.application.root, 'config', 'hooks')
@@ -5,5 +5,10 @@ module ForemanHooks
5
5
  config.to_prepare do
6
6
  ForemanHooks.hooks.each { |klass,events| ForemanHooks.attach_hook(klass.constantize, events) }
7
7
  end
8
+
9
+ initializer 'foreman_hooks.register_plugin', :after=> :finisher_hook do |app|
10
+ Foreman::Plugin.register :foreman_hooks do
11
+ end if defined? Foreman::Plugin
12
+ end
8
13
  end
9
14
  end
@@ -11,9 +11,8 @@ module ForemanHooks::Util
11
11
  exec_hook_int(self.to_json, *args)
12
12
  end.success?
13
13
 
14
- unless success
15
- logger.warn "Hook failure running `#{args.join(' ')}`: #{$?}"
16
- end
14
+ # Raising here causes Foreman Orchestration to correctly show error bubble in GUI
15
+ raise ForemanHooks::Error.new "Hook failure running `#{args.join(' ')}`: #{$?}" unless success
17
16
  success
18
17
  end
19
18
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_hooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominic Cleal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-29 00:00:00.000000000 Z
11
+ date: 2014-01-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Plugin engine for Foreman that enables running custom hook scripts on
14
14
  Foreman events
@@ -33,7 +33,7 @@ files:
33
33
  - lib/foreman_hooks/util.rb
34
34
  - test/test_helper.rb
35
35
  - test/unit/host_observer_test.rb
36
- homepage: http://github.com/domcleal/foreman_hooks
36
+ homepage: http://github.com/theforeman/foreman_hooks
37
37
  licenses:
38
38
  - GPL-3
39
39
  metadata: {}