naginata 0.1.5 → 0.1.6
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/CHANGELOG.md +16 -0
- data/lib/naginata/cli.rb +4 -0
- data/lib/naginata/cli/remote_abstract.rb +9 -0
- data/lib/naginata/loader.rb +11 -14
- data/lib/naginata/shared_helpers.rb +16 -0
- data/lib/naginata/templates/Naginatafile +1 -3
- data/lib/naginata/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 296d63cea8244f8e1ef896897968fd395333b3b9
|
4
|
+
data.tar.gz: 3ab61aaceb73e324c45d9fcfbf2f296ff6b4964e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9041cf3dfa2fc4662319611d9eb574004c0926f112a582fe3956762fdc9b80d1ea319aa8d80ee8f906fff15b6b824ea71f9cafddddbd9cd54f4d0f23df94d0b4
|
7
|
+
data.tar.gz: 878b29c91d420a0e2cd2b121622b14f8d17435d0d2c0966e6ee52e645c1c971af4cf46a2686be8632fe817b9a205579bb592fb4c0e6c7d9fc67319a7c7d423e8
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
### 0.1.6 - 2015/08/05
|
2
|
+
|
3
|
+
CLI:
|
4
|
+
|
5
|
+
* Support any Naginatafile location other than cwd
|
6
|
+
* Add --naginatafile CLI option and NAGINATAFILE environment variable
|
7
|
+
* Naginatafile can be located at ~/.naginata/Naginatafile or /etc/Naginatafile
|
8
|
+
|
9
|
+
Fixes:
|
10
|
+
|
11
|
+
* Remove the params examples of nagios_server dsl from the template
|
12
|
+
|
1
13
|
### 0.1.5 - 2015/06/09
|
2
14
|
|
3
15
|
CLI:
|
@@ -16,6 +28,10 @@ CLI:
|
|
16
28
|
* Add shorter aliases -N for --nagios option
|
17
29
|
* Add -w option wide output for hosts and services view
|
18
30
|
|
31
|
+
Fixes:
|
32
|
+
|
33
|
+
* Filter nagios servers before loading cached status file
|
34
|
+
|
19
35
|
### 0.1.3 - 2015/04/06
|
20
36
|
|
21
37
|
Fixes:
|
data/lib/naginata/cli.rb
CHANGED
@@ -29,6 +29,7 @@ module Naginata
|
|
29
29
|
method_option :disable, aliases: "-d", desc: "Disable notification", type: :boolean
|
30
30
|
method_option :dry_run, aliases: "-n", type: :boolean
|
31
31
|
method_option :force, aliases: "-f", desc: "Run without prompting for confirmation", type: :boolean
|
32
|
+
method_option :naginatafile, desc: "The location of Naginatafile. This defaults to a Naginatafile on the current working directory."
|
32
33
|
method_option :nagios, aliases: "-N", desc: "Filter targeted nagios servers by their hostname", type: :array
|
33
34
|
method_option :services, aliases: "-s", desc: "Services to be enabled|disabled", type: :array
|
34
35
|
method_option :all_hosts, aliases: "-a", desc: "Target all hosts", type: :boolean
|
@@ -46,6 +47,7 @@ module Naginata
|
|
46
47
|
method_option :disable, aliases: "-d", desc: "Disable active checks", type: :boolean
|
47
48
|
method_option :dry_run, aliases: "-n", type: :boolean
|
48
49
|
method_option :force, aliases: "-f", desc: "Run without prompting for confirmation", type: :boolean
|
50
|
+
method_option :naginatafile, desc: "The location of Naginatafile. This defaults to a Naginatafile on the current working directory."
|
49
51
|
method_option :nagios, aliases: "-N", desc: "Filter targeted nagios servers by their hostname", type: :array
|
50
52
|
method_option :services, aliases: "-s", desc: "Services to be enabled|disabled", type: :array
|
51
53
|
method_option :all_hosts, aliases: "-a", desc: "Target all hosts", type: :boolean
|
@@ -66,6 +68,7 @@ module Naginata
|
|
66
68
|
end
|
67
69
|
|
68
70
|
desc 'hosts [hostpattern ..]', 'View host status'
|
71
|
+
method_option :naginatafile, desc: "The location of Naginatafile. This defaults to a Naginatafile on the current working directory."
|
69
72
|
method_option :nagios, aliases: "-N", desc: "Filter targeted nagios servers by their hostname", type: :array
|
70
73
|
method_option :all_hosts, aliases: "-a", desc: "Target all hosts", type: :boolean
|
71
74
|
method_option :wide, aliases: "-w", desc: "Wide output", type: :boolean
|
@@ -79,6 +82,7 @@ module Naginata
|
|
79
82
|
end
|
80
83
|
|
81
84
|
desc 'services [hostpattern ..]', 'View service status'
|
85
|
+
method_option :naginatafile, desc: "The location of Naginatafile. This defaults to a Naginatafile on the current working directory."
|
82
86
|
method_option :nagios, aliases: "-N", desc: "Filter targeted nagios servers by their hostname", type: :array
|
83
87
|
method_option :services, aliases: "-s", desc: "Filter by service description", type: :array
|
84
88
|
method_option :all_hosts, aliases: "-a", desc: "Target all hosts", type: :boolean
|
@@ -9,6 +9,7 @@ module Naginata
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def execute
|
12
|
+
set_custom_naginatafile
|
12
13
|
load_configuration
|
13
14
|
set_log_level
|
14
15
|
set_nagios_filter
|
@@ -17,6 +18,14 @@ module Naginata
|
|
17
18
|
run
|
18
19
|
end
|
19
20
|
|
21
|
+
def set_custom_naginatafile
|
22
|
+
if custom_path = @options[:naginatafile] || ENV['NAGINATAFILE']
|
23
|
+
custom_path = File.expand_path(custom_path)
|
24
|
+
raise NaginatafileNotFound, "Could not locate Naginatafile" unless File.file?(custom_path)
|
25
|
+
::Naginata::Configuration.env.set(:naginatafile, custom_path)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
20
29
|
def set_log_level
|
21
30
|
if @options[:debug]
|
22
31
|
::Naginata::Configuration.env.set(:log_level, :debug)
|
data/lib/naginata/loader.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'naginata/dsl'
|
2
|
+
require 'naginata/configuration'
|
3
|
+
require 'naginata/shared_helpers'
|
2
4
|
|
3
5
|
module Naginata
|
4
6
|
class Loader
|
@@ -6,11 +8,18 @@ module Naginata
|
|
6
8
|
|
7
9
|
class << self
|
8
10
|
include Naginata::DSL
|
11
|
+
include SharedHelpers
|
9
12
|
|
10
13
|
def load_configuration
|
14
|
+
# Load defaults.rb
|
11
15
|
instance_eval File.read(File.join(File.dirname(__FILE__), 'defaults.rb'))
|
12
|
-
|
13
|
-
|
16
|
+
# Load Naginatafile
|
17
|
+
naginatafile_path = ::Naginata::Configuration.env.fetch(:naginatafile) || find_naginatafile
|
18
|
+
if naginatafile_path.nil? or !File.file?(naginatafile_path)
|
19
|
+
raise NaginatafileNotFound, 'Could not locate Naginatafile'
|
20
|
+
else
|
21
|
+
instance_eval File.read naginatafile_path
|
22
|
+
end
|
14
23
|
end
|
15
24
|
|
16
25
|
def load_remote_objects(fetch_options = {})
|
@@ -26,18 +35,6 @@ module Naginata
|
|
26
35
|
Configuration.env.host(host, services: services, on: nagios_server.hostname)
|
27
36
|
end
|
28
37
|
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def find_naginatafile
|
35
|
-
naginatafile_path = File.expand_path('Naginatafile')
|
36
|
-
if File.file?(naginatafile_path)
|
37
|
-
return naginatafile_path
|
38
|
-
else
|
39
|
-
raise NaginatafileNotFound, 'Could not locate Naginatafile'
|
40
|
-
end
|
41
38
|
end
|
42
39
|
|
43
40
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Naginata
|
2
|
+
module SharedHelpers
|
3
|
+
|
4
|
+
def find_naginatafile
|
5
|
+
file = %w(
|
6
|
+
Naginatafile
|
7
|
+
~/.naginata/Naginatafile
|
8
|
+
/etc/naginata/Naginatafile
|
9
|
+
).map{ |path| File.expand_path(path) }.find { |path| File.file?(path) }
|
10
|
+
raise NaginatafileNotFound, "Could not locate Gemfile" unless file
|
11
|
+
return file
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -2,11 +2,9 @@
|
|
2
2
|
# ========================
|
3
3
|
# Defines nagios servers with multiple properties.
|
4
4
|
|
5
|
-
# nagios_server 'nagios.tokyo.example.com'
|
6
|
-
# nagios_server 'nagios.ny.example.com', user: 'nagios', port: '10022'
|
5
|
+
# nagios_server 'nagios.tokyo.example.com'
|
7
6
|
# nagios_server 'admin@nagios.sf.example.com'
|
8
7
|
# nagios_server 'admin@nagios.sha.example.com:10022'
|
9
|
-
# nagios_server 'nagios.uk.example.com', keys: %w(/path/to/private_key)
|
10
8
|
|
11
9
|
# Global Nagios Server Options
|
12
10
|
# ============================
|
data/lib/naginata/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: naginata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nobuhiro Nikushi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sshkit
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- lib/naginata/dsl.rb
|
134
134
|
- lib/naginata/loader.rb
|
135
135
|
- lib/naginata/runner.rb
|
136
|
+
- lib/naginata/shared_helpers.rb
|
136
137
|
- lib/naginata/status.rb
|
137
138
|
- lib/naginata/status_decorator.rb
|
138
139
|
- lib/naginata/templates/Naginatafile
|