foreman_hooks 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +12 -19
- data/lib/foreman_hooks.rb +2 -0
- data/lib/foreman_hooks/engine.rb +5 -0
- data/lib/foreman_hooks/util.rb +2 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89ca0cd0fe9eea695a2ba74c390f3a7366191551
|
4
|
+
data.tar.gz: 9d542ea2ef4121c46249bbc2d1f7c24b4574ad4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
14
|
-
the plugin repos at http://yum.theforeman.org/plugins.
|
13
|
+
Please see the Foreman wiki for appropriate instructions:
|
15
14
|
|
16
|
-
|
15
|
+
* [Foreman: How to Install a Plugin](http://projects.theforeman.org/projects/foreman/wiki/How_to_Install_a_Plugin)
|
17
16
|
|
18
|
-
|
17
|
+
The gem name is "foreman_hooks".
|
19
18
|
|
20
|
-
|
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
|
-
|
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
|
data/lib/foreman_hooks.rb
CHANGED
data/lib/foreman_hooks/engine.rb
CHANGED
@@ -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
|
data/lib/foreman_hooks/util.rb
CHANGED
@@ -11,9 +11,8 @@ module ForemanHooks::Util
|
|
11
11
|
exec_hook_int(self.to_json, *args)
|
12
12
|
end.success?
|
13
13
|
|
14
|
-
|
15
|
-
|
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.
|
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:
|
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/
|
36
|
+
homepage: http://github.com/theforeman/foreman_hooks
|
37
37
|
licenses:
|
38
38
|
- GPL-3
|
39
39
|
metadata: {}
|