specinfra 2.11.10 → 2.12.0

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: 8a97071348ad54dcf08b8b05371a50992e91b39e
4
- data.tar.gz: c366cc26ab8cbbe89fb81fba534627149b6f1982
3
+ metadata.gz: 45b0dd4144407ae23367d089d595d93e24a52780
4
+ data.tar.gz: e2fc78cba42b70f379fb8c1b45d6a6bdb92c5035
5
5
  SHA512:
6
- metadata.gz: 420b3b8494ce8404e88f4072b184fbcb456f4dab7673e52788220d108cbc00dd4e0cb149e47def44adf9b85f910995db57f38c0e2dd5253017bcce0a4746b7b2
7
- data.tar.gz: de2355776cce731781721402a60071f0b815e9f9dba0f41ff9d970e6809bf1f6d8fdb6002bcd37eb397a61d2b06e478f0418b0baf88254035a45aaa355f9a636
6
+ metadata.gz: bf3bbf50b30218cb9d286804b16121f7b2a6d5180dc14c7e2e96e14d1596e9c7139963a44749fee7657f784a4a5d2afa19255a13f71b09e5d22127fde91c3800
7
+ data.tar.gz: 86c4208d0fedd6178c15f7f4d5b97b77be7f8090ef786bf4bf52890182f8eddd9d43ea0237129aa3061c4268c4e608bac7a7a3e93e495d1f11a4ce933b7a0c4a
@@ -10,6 +10,7 @@ require 'specinfra/command/base'
10
10
  require 'specinfra/command/base/bridge'
11
11
  require 'specinfra/command/base/cron'
12
12
  require 'specinfra/command/base/file'
13
+ require 'specinfra/command/base/fstab'
13
14
  require 'specinfra/command/base/group'
14
15
  require 'specinfra/command/base/host'
15
16
  require 'specinfra/command/base/interface'
@@ -39,6 +40,7 @@ require 'specinfra/command/linux'
39
40
  require 'specinfra/command/linux/base'
40
41
  require 'specinfra/command/linux/base/bridge'
41
42
  require 'specinfra/command/linux/base/file'
43
+ require 'specinfra/command/linux/base/fstab'
42
44
  require 'specinfra/command/linux/base/interface'
43
45
  require 'specinfra/command/linux/base/inventory'
44
46
  require 'specinfra/command/linux/base/iptables'
@@ -2,10 +2,11 @@ class Specinfra::Command::Base::Cron < Specinfra::Command::Base
2
2
  class << self
3
3
  def check_has_entry(user, entry)
4
4
  entry_escaped = entry.gsub(/\*/, '\\*').gsub(/\[/, '\\[').gsub(/\]/, '\\]')
5
+ grep_command = "grep -v '^[[:space:]]*#' | grep -- ^#{escape(entry_escaped)}$"
5
6
  if user.nil?
6
- "crontab -l | grep -v \"#\" -- | grep -- #{escape(entry_escaped)}"
7
+ "crontab -l | #{grep_command}"
7
8
  else
8
- "crontab -u #{escape(user)} -l | grep -v \"#\" | grep -- #{escape(entry_escaped)}"
9
+ "crontab -u #{escape(user)} -l | #{grep_command}"
9
10
  end
10
11
  end
11
12
  end
@@ -0,0 +1,2 @@
1
+ class Specinfra::Command::Base::Fstab < Specinfra::Command::Base
2
+ end
@@ -8,5 +8,20 @@ class Specinfra::Command::Base::Group < Specinfra::Command::Base
8
8
  regexp = "^#{group}"
9
9
  "getent group | grep -w -- #{escape(regexp)} | cut -f 3 -d ':' | grep -w -- #{escape(gid)}"
10
10
  end
11
+
12
+ def get_gid(group)
13
+ "getent group #{escape(group)} | cut -f 3 -d ':'"
14
+ end
15
+
16
+ def update_gid(group, gid)
17
+ "groupmod -g #{escape(gid)} #{escape(group)}"
18
+ end
19
+
20
+ def add(group, options)
21
+ command = ['groupadd']
22
+ command << '-g' << escape(options[:gid]) if options[:gid]
23
+ command << escape(group)
24
+ command.join(' ')
25
+ end
11
26
  end
12
27
  end
@@ -0,0 +1,9 @@
1
+ class Specinfra::Command::Linux::Base::Fstab < Specinfra::Command::Base::Fstab
2
+ class << self
3
+ def check_has_entry(mount_point)
4
+ %Q(awk '{if($2=="#{escape(mount_point)}")print}' /etc/fstab | grep -v '^[[:space:]]*#')
5
+ end
6
+
7
+ alias :get_entry :check_has_entry
8
+ end
9
+ end
@@ -117,6 +117,41 @@ module Specinfra
117
117
  end
118
118
  end
119
119
 
120
+ def self.check_fstab_has_entry(expected_attr)
121
+ return false unless expected_attr[:mount_point]
122
+ cmd = Specinfra.command.get(:get_fstab_entry, expected_attr[:mount_point])
123
+ ret = Specinfra.backend.run_command(cmd)
124
+ return false if ret.failure?
125
+
126
+ fstab = ret.stdout.scan(/\S+/)
127
+ actual_attr = {
128
+ :device => fstab[0],
129
+ :mount_point => fstab[1],
130
+ :type => fstab[2],
131
+ :dump => fstab[4].to_i,
132
+ :pass => fstab[5].to_i
133
+ }
134
+ fstab[3].split(',').each do |option|
135
+ name, val = option.split('=')
136
+ if val.nil?
137
+ actual_attr[name.to_sym] = true
138
+ else
139
+ val = val.to_i if val.match(/^\d+$/)
140
+ actual_attr[name.to_sym] = val
141
+ end
142
+ end
143
+
144
+ unless expected_attr[:options].nil?
145
+ expected_attr.merge!(expected_attr[:options])
146
+ expected_attr.delete(:options)
147
+ end
148
+
149
+ expected_attr.each do |key, val|
150
+ return false if actual_attr[key] != val
151
+ end
152
+ true
153
+ end
154
+
120
155
  def self.check_routing_table_has_entry(expected_attr)
121
156
  return false if ! expected_attr[:destination]
122
157
  cmd = Specinfra.command.get(:get_routing_table_entry, expected_attr[:destination])
@@ -1,3 +1,3 @@
1
1
  module Specinfra
2
- VERSION = "2.11.10"
2
+ VERSION = "2.12.0"
3
3
  end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, { :family => nil }
4
+
5
+ describe get_command(:get_group_gid, 'foo') do
6
+ it { should eq "getent group foo | cut -f 3 -d ':'" }
7
+ end
8
+
9
+ describe get_command(:update_group_gid, 'foo', 1234) do
10
+ it { should eq "groupmod -g 1234 foo" }
11
+ end
12
+
13
+ describe get_command(:add_group, 'foo', :gid => 1234) do
14
+ it { should eq 'groupadd -g 1234 foo' }
15
+ end
16
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specinfra
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.10
4
+ version: 2.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-25 00:00:00.000000000 Z
11
+ date: 2015-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh
@@ -153,6 +153,7 @@ files:
153
153
  - lib/specinfra/command/base/bridge.rb
154
154
  - lib/specinfra/command/base/cron.rb
155
155
  - lib/specinfra/command/base/file.rb
156
+ - lib/specinfra/command/base/fstab.rb
156
157
  - lib/specinfra/command/base/group.rb
157
158
  - lib/specinfra/command/base/host.rb
158
159
  - lib/specinfra/command/base/interface.rb
@@ -212,6 +213,7 @@ files:
212
213
  - lib/specinfra/command/linux/base.rb
213
214
  - lib/specinfra/command/linux/base/bridge.rb
214
215
  - lib/specinfra/command/linux/base/file.rb
216
+ - lib/specinfra/command/linux/base/fstab.rb
215
217
  - lib/specinfra/command/linux/base/interface.rb
216
218
  - lib/specinfra/command/linux/base/inventory.rb
217
219
  - lib/specinfra/command/linux/base/ip6tables.rb
@@ -347,6 +349,7 @@ files:
347
349
  - spec/backend/exec/env_spec.rb
348
350
  - spec/backend/ssh/build_command_spec.rb
349
351
  - spec/command/base/file_spec.rb
352
+ - spec/command/base/group_spec.rb
350
353
  - spec/command/base/localhost_spec.rb
351
354
  - spec/command/base/package_spec.rb
352
355
  - spec/command/base/user_spec.rb
@@ -402,6 +405,7 @@ test_files:
402
405
  - spec/backend/exec/env_spec.rb
403
406
  - spec/backend/ssh/build_command_spec.rb
404
407
  - spec/command/base/file_spec.rb
408
+ - spec/command/base/group_spec.rb
405
409
  - spec/command/base/localhost_spec.rb
406
410
  - spec/command/base/package_spec.rb
407
411
  - spec/command/base/user_spec.rb