poise-service 1.4.0 → 1.4.1

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: cc314f2835262cc4716868dbe28806a24fb5d6f5
4
- data.tar.gz: 3283117be88a4eb5e43986d8482db391c51d0131
3
+ metadata.gz: c69f8bdc50849e5cfe6498cb3e248f0708e55a49
4
+ data.tar.gz: 8e60520adfb87a6a16e20b22f1a2869daa59c9cc
5
5
  SHA512:
6
- metadata.gz: 2c7888157443d3ce72a2b79283c443f6d9a59df86c031440edae4f1422a6f35c2e741b0c201964f8d0dc451d3cde9bf07aabf272255d1b6ca8cd8436051079a8
7
- data.tar.gz: 57e51c07b358673293c019684a101666d881def1b1fe9052fa0c5c8cb0feee82a4ab8ec07c4395e40dd13e5ec5371d36ad10dda8b620bbf7fb9faa49b8e1539a
6
+ metadata.gz: 07d5fe9c86e84cc4aaef0bab394969217e220ca8c922ebe75b51301f1bd73b396269b29ada43cee6e711bc4d4ac6c3223ee359c4366eb6aafc6b9d994e365744
7
+ data.tar.gz: d53e5e479b1bcfaac6cd860ec0b772f79506db7294c705c6dfebe3a3123f20a147ca5e24d81ce2e47494d600d6d5f284213647fd75d64691a79f3eb8ad090f19
@@ -1,5 +1,9 @@
1
1
  # Poise-Service Changelog
2
2
 
3
+ ## v1.4.1
4
+
5
+ * Fix `poise_service_user` on Solaris and make it closer to being usable on Windows.
6
+
3
7
  ## v1.4.0
4
8
 
5
9
  * [#31](https://github.com/poise/poise-service/pull/31) Add `shell` property to
@@ -49,10 +49,11 @@ module PoiseService
49
49
  # @return [String]
50
50
  attribute(:user, kind_of: String, name_attribute: true)
51
51
  # @!attribute group
52
- # Name of the group to create. Defaults to the name of the resource.
53
- # Set to false to disable group creation.
52
+ # Name of the group to create. Defaults to the name of the user,
53
+ # except on Windows where it defaults to false. Set to false to
54
+ # disable group creation.
54
55
  # @return [String, false]
55
- attribute(:group, kind_of: [String, FalseClass], name_attribute: true)
56
+ attribute(:group, kind_of: [String, FalseClass], default: lazy { default_group })
56
57
  # @!attribute uid
57
58
  # UID of the user to create. Optional, if not set the UID will be
58
59
  # allocated automatically.
@@ -79,10 +80,24 @@ module PoiseService
79
80
  # Find a default shell for service users. Tries to use nologin, but fall
80
81
  # back on false.
81
82
  #
83
+ # @api private
82
84
  # @return [String]
83
85
  def default_shell
84
86
  DEFAULT_SHELLS.find {|s| ::File.exist?(s) } || DEFAULT_SHELLS.last
85
87
  end
88
+
89
+ # Find the default group name. Returns false on Windows because service
90
+ # groups aren't needed there. Otherwise use the name of the service user.
91
+ #
92
+ # @api private
93
+ # @return [String, false]
94
+ def default_group
95
+ if node.platform_family?('windows')
96
+ false
97
+ else
98
+ user
99
+ end
100
+ end
86
101
  end
87
102
 
88
103
  # Provider for `poise_service_user`.
@@ -119,26 +134,37 @@ module PoiseService
119
134
  private
120
135
 
121
136
  # Create the system group.
137
+ #
138
+ # @api private
139
+ # @return [void]
122
140
  def create_group
123
141
  group new_resource.group do
124
142
  gid new_resource.gid
125
- system true
143
+ # Solaris doesn't support the idea of system groups.
144
+ system true unless node.platform_family?('solaris2')
126
145
  end
127
146
  end
128
147
 
129
148
  # Create the system user.
149
+ #
150
+ # @api private
151
+ # @return [void]
130
152
  def create_user
131
153
  user new_resource.user do
132
154
  comment "Service user for #{new_resource.name}"
133
155
  gid new_resource.group if new_resource.group
134
156
  home new_resource.home
135
157
  shell new_resource.shell
136
- system true
158
+ # Solaris doesn't support the idea of system users.
159
+ system true unless node.platform_family?('solaris2')
137
160
  uid new_resource.uid
138
161
  end
139
162
  end
140
163
 
141
164
  # Remove the system group.
165
+ #
166
+ # @api private
167
+ # @return [void]
142
168
  def remove_group
143
169
  create_group.tap do |r|
144
170
  r.action(:remove)
@@ -146,6 +172,9 @@ module PoiseService
146
172
  end
147
173
 
148
174
  # Remove the system user.
175
+ #
176
+ # @api private
177
+ # @return [void]
149
178
  def remove_user
150
179
  create_user.tap do |r|
151
180
  r.action(:remove)
@@ -16,5 +16,5 @@
16
16
 
17
17
 
18
18
  module PoiseService
19
- VERSION = '1.4.0'
19
+ VERSION = '1.4.1'
20
20
  end
@@ -18,6 +18,9 @@ require 'spec_helper'
18
18
 
19
19
  describe PoiseService::Resources::PoiseServiceUser do
20
20
  step_into(:poise_service_user)
21
+ # We need a platform because Chef no longer maps the user resource for chefspec.
22
+ # https://github.com/chef/chef/issues/5242
23
+ let(:chefspec_options) { {platform: 'ubuntu', version: '14.04'} }
21
24
  let(:shells) { [] }
22
25
  before do
23
26
  allow(File).to receive(:exist?) {|s| shells.include?(s) }
@@ -140,4 +143,19 @@ describe PoiseService::Resources::PoiseServiceUser do
140
143
  it { is_expected.to remove_user('poise') }
141
144
  end # /context with no group
142
145
  end # context with action :remove
146
+
147
+ context 'on Solaris' do
148
+ let(:chefspec_options) { {platform: 'solaris2', version: '5.11'} }
149
+
150
+ it { is_expected.to create_group('poise').with(gid: nil, system: nil) }
151
+ it { is_expected.to create_user('poise').with(gid: 'poise', home: nil, system: false, uid: nil, shell: '/bin/false') }
152
+ end # /context on Solaris
153
+
154
+ context 'on Windows' do
155
+ let(:chefspec_options) { {platform: 'windows', version: '2012R2'} }
156
+
157
+ it { is_expected.to_not create_group('poise') }
158
+ it { is_expected.to create_user('poise').with(gid: nil, home: nil, system: true, uid: nil, shell: '/bin/false') }
159
+ end # /context on Windows
160
+
143
161
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poise-service
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noah Kantrowitz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-21 00:00:00.000000000 Z
11
+ date: 2016-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: halite