specinfra 2.11.6 → 2.11.7

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: 259795e097ab5ac71cb0826033e37caad658888e
4
- data.tar.gz: 74d200fb1e48e79423b8c39eff4a2dc5dedef884
3
+ metadata.gz: 1cb5ba6a49ece8dcff20b124919abab9eb1bcfec
4
+ data.tar.gz: f8903251a7c3aa89a28730ce17cc038309f8f09b
5
5
  SHA512:
6
- metadata.gz: 54fdcded6fbcf3ae2b2b53aa04d013ab59956143d3976c3e2bec9ed37d83b5ff85023dea318d40b8174f5b912c75e553b9231502b2f7d8dce41de180dc26cff4
7
- data.tar.gz: dc1d729be92a09ff58f1087bd6801e0b33ee006ad14efb4b47090743a9bb21cb6cd567c75a7d4029bfc10fcb15e3f6150c02ce26d22a99f30750f497809397f9
6
+ metadata.gz: 160811348b2046e4cfc115bfa18257dda619f58468d0f88b0e3e417595ebfe2133f0de4f515ebc67f3eb13687e551f0d26a52000de07343268c95a38032555c1
7
+ data.tar.gz: adab7833724a34ec064d0fdd58288ed17af762c4587025b00e0360c9423043031fe47a0828808490cf7423972df742dd6d477401c8d69a8237ca56cc35ee614e
@@ -1,7 +1,12 @@
1
1
  class Specinfra::Command::Opensuse::Base::Service < Specinfra::Command::Suse::Base::Service
2
2
  class << self
3
+ include Specinfra::Command::Module::Systemd
3
4
  def check_is_running(service)
4
5
  "service #{escape(service)} status"
5
6
  end
7
+
8
+ def check_is_enabled(service, level=nil)
9
+ "systemctl is-enabled #{escape(service)}"
10
+ end
6
11
  end
7
12
  end
@@ -48,7 +48,9 @@ class Specinfra::CommandFactory
48
48
  end
49
49
 
50
50
  def breakdown(meth)
51
- types = resource_types.map {|t| t.to_snake_case }.join('|')
51
+ # Somtimes `selinux_module' type matches `selinux' and error occurs.
52
+ # Reverse sorting is needed to avoid this problem.
53
+ types = resource_types.map {|t| t.to_snake_case }.sort.reverse.join('|')
52
54
  md = meth.to_s.match(/^([^_]+)_(#{types})_?(.+)?$/)
53
55
  if md.nil?
54
56
  message = "Could not break down `#{meth}' to appropriate type and method.\n"
@@ -9,6 +9,7 @@ module Specinfra
9
9
  :pre_command,
10
10
  :stdout,
11
11
  :stderr,
12
+ :exit_status,
12
13
  :sudo_path,
13
14
  :disable_sudo,
14
15
  :sudo_options,
@@ -1,3 +1,9 @@
1
+ require 'specinfra/host_inventory/memory'
2
+ require 'specinfra/host_inventory/ec2'
3
+ require 'specinfra/host_inventory/hostname'
4
+ require 'specinfra/host_inventory/domain'
5
+ require 'specinfra/host_inventory/fqdn'
6
+
1
7
  module Specinfra
2
8
  class HostInventory
3
9
  include Singleton
@@ -10,7 +16,8 @@ module Specinfra
10
16
  def [](key)
11
17
  @inventory[key.to_sym] ||= {}
12
18
  if @inventory[key.to_sym].empty?
13
- @inventory[key.to_sym] = Specinfra::Runner.send("get_inventory_#{key}")
19
+ inventory_class = Specinfra::HostInventory.const_get(key.to_s.to_camel_case)
20
+ @inventory[key.to_sym] = inventory_class.get
14
21
  end
15
22
  @inventory[key.to_sym]
16
23
  end
@@ -0,0 +1,10 @@
1
+ module Specinfra
2
+ class HostInventory
3
+ class Domain
4
+ def self.get
5
+ cmd = Specinfra.command.get(:get_inventory_domain)
6
+ Specinfra.backend.run_command(cmd).stdout.strip
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ module Specinfra
2
+ class HostInventory
3
+ class Ec2
4
+ def self.get
5
+ Specinfra::Ec2Metadata.new.get
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ module Specinfra
2
+ class HostInventory
3
+ class Fqdn
4
+ def self.get
5
+ cmd = Specinfra.command.get(:get_inventory_fqdn)
6
+ Specinfra.backend.run_command(cmd).stdout.strip
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Specinfra
2
+ class HostInventory
3
+ class Hostname
4
+ def self.get
5
+ cmd = Specinfra.command.get(:get_inventory_hostname)
6
+ Specinfra.backend.run_command(cmd).stdout.strip
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,18 @@
1
+ module Specinfra
2
+ class HostInventory
3
+ class Memory
4
+ def self.get
5
+ cmd = Specinfra.command.get(:get_inventory_memory)
6
+ ret = Specinfra.backend.run_command(cmd).stdout
7
+ memory = {}
8
+ ret.each_line do |line|
9
+ case line
10
+ when /^MemTotal:\s+(\d+) (.+)$/
11
+ memory['total'] = "#{$1}#{$2}"
12
+ end
13
+ end
14
+ memory
15
+ end
16
+ end
17
+ end
18
+ end
@@ -127,11 +127,11 @@ module Specinfra
127
127
 
128
128
  if os[:family] == 'openbsd'
129
129
  match = ret.stdout.match(/^(\S+)\s+(\S+).*?(\S+[0-9]+)(\s*)$/)
130
- actual_attr = {
131
- :destination => $1,
132
- :gateway => $2,
133
- :interface => expected_attr[:interface] ? $3 : nil
134
- }
130
+ actual_attr = {
131
+ :destination => $1,
132
+ :gateway => $2,
133
+ :interface => expected_attr[:interface] ? $3 : nil
134
+ }
135
135
  else
136
136
  matches = ret.stdout.scan(/^(\S+)(?: via (\S+))? dev (\S+).+\n|^(\S+).+\n|\s+nexthop via (\S+)\s+dev (\S+).+/)
137
137
  if matches.length > 1
@@ -192,37 +192,5 @@ module Specinfra
192
192
  end
193
193
  end
194
194
  end
195
-
196
- def self.get_inventory_memory
197
- cmd = Specinfra.command.get(:get_inventory_memory)
198
- ret = Specinfra.backend.run_command(cmd).stdout
199
- memory = {}
200
- ret.each_line do |line|
201
- case line
202
- when /^MemTotal:\s+(\d+) (.+)$/
203
- memory['total'] = "#{$1}#{$2}"
204
- end
205
- end
206
- memory
207
- end
208
-
209
- def self.get_inventory_ec2
210
- Specinfra::Ec2Metadata.new.get
211
- end
212
-
213
- def self.get_inventory_hostname
214
- cmd = Specinfra.command.get(:get_inventory_hostname)
215
- Specinfra.backend.run_command(cmd).stdout.strip
216
- end
217
-
218
- def self.get_inventory_domain
219
- cmd = Specinfra.command.get(:get_inventory_domain)
220
- Specinfra.backend.run_command(cmd).stdout.strip
221
- end
222
-
223
- def self.get_inventory_fqdn
224
- cmd = Specinfra.command.get(:get_inventory_fqdn)
225
- Specinfra.backend.run_command(cmd).stdout.strip
226
- end
227
195
  end
228
196
  end
@@ -1,3 +1,3 @@
1
1
  module Specinfra
2
- VERSION = "2.11.6"
2
+ VERSION = "2.11.7"
3
3
  end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ property[:os] = nil
4
+ set :os, :family => 'linux'
5
+
6
+ describe get_command(:check_selinux_module_is_installed, 'dnsmasq') do
7
+ it { should eq "semodule -l | grep $'^dnsmasq\\t'" }
8
+ end
9
+
10
+ describe get_command(:check_selinux_module_is_enabled, 'dnsmasq') do
11
+ it { should eq "semodule -l | grep $'^dnsmasq\\t' | grep -v $'^dnsmasq\\t.*\\tDisabled$'" }
12
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ property[:os] = nil
4
+ set :os, :family => 'linux'
5
+
6
+ describe get_command(:check_selinux_has_mode, 'disabled') do
7
+ it { should eq 'test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)' }
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specinfra
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.6
4
+ version: 2.11.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
@@ -334,6 +334,11 @@ files:
334
334
  - lib/specinfra/helper/properties.rb
335
335
  - lib/specinfra/helper/set.rb
336
336
  - lib/specinfra/host_inventory.rb
337
+ - lib/specinfra/host_inventory/domain.rb
338
+ - lib/specinfra/host_inventory/ec2.rb
339
+ - lib/specinfra/host_inventory/fqdn.rb
340
+ - lib/specinfra/host_inventory/hostname.rb
341
+ - lib/specinfra/host_inventory/memory.rb
337
342
  - lib/specinfra/processor.rb
338
343
  - lib/specinfra/properties.rb
339
344
  - lib/specinfra/runner.rb
@@ -353,6 +358,8 @@ files:
353
358
  - spec/command/linux/interface_spec.rb
354
359
  - spec/command/linux/inventory_spec.rb
355
360
  - spec/command/linux/ip6tables_spec.rb
361
+ - spec/command/linux/selinux_module_spec.rb
362
+ - spec/command/linux/selinux_spec.rb
356
363
  - spec/command/module/systemd_spec.rb
357
364
  - spec/command/redhat/interface_spec.rb
358
365
  - spec/command/redhat/package_spec.rb
@@ -406,6 +413,8 @@ test_files:
406
413
  - spec/command/linux/interface_spec.rb
407
414
  - spec/command/linux/inventory_spec.rb
408
415
  - spec/command/linux/ip6tables_spec.rb
416
+ - spec/command/linux/selinux_module_spec.rb
417
+ - spec/command/linux/selinux_spec.rb
409
418
  - spec/command/module/systemd_spec.rb
410
419
  - spec/command/redhat/interface_spec.rb
411
420
  - spec/command/redhat/package_spec.rb