specinfra 2.82.8 → 2.82.9
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/lib/specinfra/command.rb +1 -0
- data/lib/specinfra/command/darwin/base/group.rb +22 -0
- data/lib/specinfra/command/darwin/base/user.rb +38 -0
- data/lib/specinfra/version.rb +1 -1
- data/spec/command/darwin/group_spec.rb +15 -0
- data/spec/command/darwin/user_spec.rb +20 -0
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 12be641da0b979fbb7e114c6a6b40987d41a0e30
|
|
4
|
+
data.tar.gz: 23542c373ee045664d8612268396ed21c7278a1d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f7ba4a22c7825dbfd0c17734f2d69edf8e422903ec61e2d2318e6fe0a2dfcdcb81d8580aa4ed48535886888b2840897c5eae1ace0dc3e75b43b0569f492abeb6
|
|
7
|
+
data.tar.gz: e6599750de210765cc448f39fd36c3ebe7287a44625c375fc61fac01b95d01aa3180697855638cadb3eebdc4b2be752ad942128bb1d3a5306019de7981c64289
|
data/lib/specinfra/command.rb
CHANGED
|
@@ -174,6 +174,7 @@ require 'specinfra/command/darwin/base/package'
|
|
|
174
174
|
require 'specinfra/command/darwin/base/port'
|
|
175
175
|
require 'specinfra/command/darwin/base/process'
|
|
176
176
|
require 'specinfra/command/darwin/base/user'
|
|
177
|
+
require 'specinfra/command/darwin/base/group'
|
|
177
178
|
|
|
178
179
|
# Debian (inherit Linux)
|
|
179
180
|
require 'specinfra/command/debian'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class Specinfra::Command::Darwin::Base::Group < Specinfra::Command::Base::Group
|
|
2
|
+
class << self
|
|
3
|
+
|
|
4
|
+
def get_gid(group)
|
|
5
|
+
"dscl . -read /Groups/#{escape(group)} PrimaryGroupID | awk '{ print $2 }'"
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def update_gid(group, gid)
|
|
9
|
+
"dscl . -create /Groups/#{escape(group)} PrimaryGroupID #{escape(gid)}"
|
|
10
|
+
end
|
|
11
|
+
def add(group, options)
|
|
12
|
+
group_name = escape(group)
|
|
13
|
+
|
|
14
|
+
record_path = "/Groups/#{group_name}"
|
|
15
|
+
dscl_create = "dscl . -create #{record_path}"
|
|
16
|
+
command = [dscl_create]
|
|
17
|
+
command << "#{dscl_create} PrimaryGroupID #{escape(options[:gid])}" if options[:gid]
|
|
18
|
+
command << "#{dscl_create} RecordName #{escape(options[:groupname])}" if options[:groupname]
|
|
19
|
+
command.join(' && ')
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -11,5 +11,43 @@ class Specinfra::Command::Darwin::Base::User < Specinfra::Command::Base::User
|
|
|
11
11
|
def get_home_directory(user)
|
|
12
12
|
"finger #{escape(user)} | grep -E '^Directory' | awk '{ print $2 }'"
|
|
13
13
|
end
|
|
14
|
+
|
|
15
|
+
def update_home_directory(user, directory)
|
|
16
|
+
"dscl . -create /Users/#{escape(user)} NFSHomeDirectory #{escape(directory)}"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def update_login_shell(user, shell)
|
|
20
|
+
"dscl . -create /Users/#{escape(user)} UserShell #{escape(shell)}"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def update_encrypted_password(user, password)
|
|
24
|
+
"dscl . passwd /Users/#{escape(user)} #{escape(password)}"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def update_gid(user, gid)
|
|
28
|
+
"dscl . -create /Users/#{escape(user)} PrimaryGroupID #{escape(gid)}"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def add(user, options)
|
|
32
|
+
user_name = escape(user)
|
|
33
|
+
record_path = "/Users/#{user_name}"
|
|
34
|
+
dscl_create = "dscl . -create #{record_path}"
|
|
35
|
+
|
|
36
|
+
command = [dscl_create]
|
|
37
|
+
command << "#{dscl_create} UserShell #{escape(options[:shell])}" if options[:shell]
|
|
38
|
+
command << "#{dscl_create} UniqueID #{escape(options[:uid])}" if options[:uid]
|
|
39
|
+
command << "#{dscl_create} PrimaryGroupID #{escape(options[:gid])}" if options[:gid]
|
|
40
|
+
|
|
41
|
+
home_dir = if options[:home_directory]
|
|
42
|
+
escape(options[:home_directory])
|
|
43
|
+
else
|
|
44
|
+
record_path
|
|
45
|
+
end
|
|
46
|
+
command << "#{dscl_create} NFSHomeDirectory #{home_dir}"
|
|
47
|
+
|
|
48
|
+
command << "dscl . passwd #{record_path} #{escape(options[:password])}" if options[:password]
|
|
49
|
+
command << "createhomedir -b -u #{user_name}" if options[:create_home]
|
|
50
|
+
command.join(' && ')
|
|
51
|
+
end
|
|
14
52
|
end
|
|
15
53
|
end
|
data/lib/specinfra/version.rb
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
set :os, { :family => 'darwin' }
|
|
4
|
+
|
|
5
|
+
describe get_command(:get_group_gid, 'foo') do
|
|
6
|
+
it { should eq "dscl . -read /Groups/foo PrimaryGroupID | awk '{ print $2 }'" }
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe get_command(:update_group_gid, 'foo', 1234) do
|
|
10
|
+
it { should eq "dscl . -create /Groups/foo PrimaryGroupID 1234" }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe get_command(:add_group, 'foo', :gid => 1234, :groupname => 'bar') do
|
|
14
|
+
it { should eq 'dscl . -create /Groups/foo && dscl . -create /Groups/foo PrimaryGroupID 1234 && dscl . -create /Groups/foo RecordName bar' }
|
|
15
|
+
end
|
|
@@ -13,3 +13,23 @@ end
|
|
|
13
13
|
describe get_command(:get_user_home_directory, 'foo') do
|
|
14
14
|
it { should eq "finger foo | grep -E '^Directory' | awk '{ print $2 }'" }
|
|
15
15
|
end
|
|
16
|
+
|
|
17
|
+
describe get_command(:update_user_home_directory, 'user', 'dir') do
|
|
18
|
+
it { should eq "dscl . -create /Users/user NFSHomeDirectory dir" }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe get_command(:update_user_login_shell, 'user', '/bin/bash') do
|
|
22
|
+
it { should eq "dscl . -create /Users/user UserShell /bin/bash" }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe get_command(:update_user_encrypted_password, 'user', 'pass') do
|
|
26
|
+
it { should eq "dscl . passwd /Users/user pass" }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe get_command(:update_user_gid, 'user', '100') do
|
|
30
|
+
it { should eq "dscl . -create /Users/user PrimaryGroupID 100" }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe get_command(:add_user, 'foo', :home_directory => '/Users/foo', :password => '$6$foo/bar', :shell => '/bin/zsh', :create_home => true) do
|
|
34
|
+
it { should eq 'dscl . -create /Users/foo && dscl . -create /Users/foo UserShell /bin/zsh && dscl . -create /Users/foo NFSHomeDirectory /Users/foo && dscl . passwd /Users/foo \$6\$foo/bar && createhomedir -b -u foo' }
|
|
35
|
+
end
|
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.82.
|
|
4
|
+
version: 2.82.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gosuke Miyashita
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-02-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: net-scp
|
|
@@ -217,6 +217,7 @@ files:
|
|
|
217
217
|
- lib/specinfra/command/darwin.rb
|
|
218
218
|
- lib/specinfra/command/darwin/base.rb
|
|
219
219
|
- lib/specinfra/command/darwin/base/file.rb
|
|
220
|
+
- lib/specinfra/command/darwin/base/group.rb
|
|
220
221
|
- lib/specinfra/command/darwin/base/host.rb
|
|
221
222
|
- lib/specinfra/command/darwin/base/interface.rb
|
|
222
223
|
- lib/specinfra/command/darwin/base/inventory.rb
|
|
@@ -521,6 +522,7 @@ files:
|
|
|
521
522
|
- spec/command/cumulus/ppa_cumuluslinux_spec.rb
|
|
522
523
|
- spec/command/cumulus/ppa_cumulusnetworks_spec.rb
|
|
523
524
|
- spec/command/darwin/file_spec.rb
|
|
525
|
+
- spec/command/darwin/group_spec.rb
|
|
524
526
|
- spec/command/darwin/host_spec.rb
|
|
525
527
|
- spec/command/darwin/interface_spec.rb
|
|
526
528
|
- spec/command/darwin/port_spec.rb
|
|
@@ -658,6 +660,7 @@ test_files:
|
|
|
658
660
|
- spec/command/cumulus/ppa_cumuluslinux_spec.rb
|
|
659
661
|
- spec/command/cumulus/ppa_cumulusnetworks_spec.rb
|
|
660
662
|
- spec/command/darwin/file_spec.rb
|
|
663
|
+
- spec/command/darwin/group_spec.rb
|
|
661
664
|
- spec/command/darwin/host_spec.rb
|
|
662
665
|
- spec/command/darwin/interface_spec.rb
|
|
663
666
|
- spec/command/darwin/port_spec.rb
|