poise-service 1.3.1 → 1.4.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: 620447ed47a3030f8b4450f2c0ff5fec761a2188
4
- data.tar.gz: 675005000178c19f5b7d4422857d67372fe3d50a
3
+ metadata.gz: cc314f2835262cc4716868dbe28806a24fb5d6f5
4
+ data.tar.gz: 3283117be88a4eb5e43986d8482db391c51d0131
5
5
  SHA512:
6
- metadata.gz: 61d7319f04b307c041e763ff157993957a627703bb22b32845f5cf8aae3e8f34acfc10dc955239d5258a1775a49c7a79d41b1c590e242601d1cbafa388166553
7
- data.tar.gz: b908f0d756102441e6921f57ec639282b65f0d4f76546824d2e22f4e0d069bd72a062572ac89c54a43bf5661529b41a5fd2e76c8591d8cb430fa6caa8fd6feb1
6
+ metadata.gz: 2c7888157443d3ce72a2b79283c443f6d9a59df86c031440edae4f1422a6f35c2e741b0c201964f8d0dc451d3cde9bf07aabf272255d1b6ca8cd8436051079a8
7
+ data.tar.gz: 57e51c07b358673293c019684a101666d881def1b1fe9052fa0c5c8cb0feee82a4ab8ec07c4395e40dd13e5ec5371d36ad10dda8b620bbf7fb9faa49b8e1539a
@@ -1,3 +1,3 @@
1
1
  ---
2
2
  #<% require 'poise_boiler' %>
3
- <%= PoiseBoiler.kitchen(platforms: %w{linux centos-5}, driver: 'rackspace') %>
3
+ <%= PoiseBoiler.kitchen(platforms: %w{linux centos-5 ubuntu-16.04}, driver: 'rackspace') %>
@@ -2,7 +2,7 @@ sudo: false
2
2
  cache: bundler
3
3
  language: ruby
4
4
  rvm:
5
- - '2.2'
5
+ - 2.3.1
6
6
  env:
7
7
  global:
8
8
  - RACKSPACE_USERNAME=coderanger
@@ -1,5 +1,10 @@
1
1
  # Poise-Service Changelog
2
2
 
3
+ ## v1.4.0
4
+
5
+ * [#31](https://github.com/poise/poise-service/pull/31) Add `shell` property to
6
+ `poise_service_user` resource.
7
+
3
8
  ## v1.3.1
4
9
 
5
10
  * [#25](https://github.com/poise/poise-service/pull/25) Cope with a service user
data/README.md CHANGED
@@ -219,9 +219,10 @@ end
219
219
 
220
220
  * `user` – Name of the user. *(name attribute)*
221
221
  * `group` – Name of the group. Set to `false` to disable group creation. *(name attribute)*
222
- * `uid` – UID of the user. If unspecified it will be automatically allocated.
223
- * `gid` – GID of the group. If unspecified it will be automatically allocated.
222
+ * `uid` – UID of the user. *(default: automatic)*
223
+ * `gid` – GID of the group. *(default: automatic)*
224
224
  * `home` – Home directory of the user.
225
+ * `shell` – Shell of the user. *(default: /bin/nologin if present or /bin/false)*
225
226
 
226
227
  ## Providers
227
228
 
@@ -24,6 +24,10 @@ module PoiseService
24
24
  # (see PoiseServiceUser::Resource)
25
25
  # @since 1.0.0
26
26
  module PoiseServiceUser
27
+ # Shells to look for in order.
28
+ # @api private
29
+ DEFAULT_SHELLS = %w{/bin/nologin /usr/bin/nologin /bin/false}
30
+
27
31
  # A `poise_service_user` resource to create service users/groups.
28
32
  #
29
33
  # @since 1.0.0
@@ -59,11 +63,26 @@ module PoiseService
59
63
  # allocated automatically.
60
64
  # @return [Integer]
61
65
  attribute(:gid, kind_of: Integer)
66
+ # @!attribute shell
67
+ # Login shell for the user. Optional, if not set the shell will be
68
+ # determined automatically.
69
+ # @return [String]
70
+ attribute(:shell, kind_of: String, default: lazy { default_shell })
62
71
  # @!attribute home
63
72
  # Home directory of the user. This directory will not be created if it
64
73
  # does not exist. Optional.
65
74
  # @return [String]
66
75
  attribute(:home, kind_of: String)
76
+
77
+ private
78
+
79
+ # Find a default shell for service users. Tries to use nologin, but fall
80
+ # back on false.
81
+ #
82
+ # @return [String]
83
+ def default_shell
84
+ DEFAULT_SHELLS.find {|s| ::File.exist?(s) } || DEFAULT_SHELLS.last
85
+ end
67
86
  end
68
87
 
69
88
  # Provider for `poise_service_user`.
@@ -113,7 +132,7 @@ module PoiseService
113
132
  comment "Service user for #{new_resource.name}"
114
133
  gid new_resource.group if new_resource.group
115
134
  home new_resource.home
116
- shell '/bin/false'
135
+ shell new_resource.shell
117
136
  system true
118
137
  uid new_resource.uid
119
138
  end
@@ -16,5 +16,5 @@
16
16
 
17
17
 
18
18
  module PoiseService
19
- VERSION = '1.3.1'
19
+ VERSION = '1.4.0'
20
20
  end
@@ -21,7 +21,8 @@ poise_service_test 'default' do
21
21
  base_port 5000
22
22
  end
23
23
 
24
- if node['platform_family'] == 'rhel' && node['platform_version'].start_with?('7')
24
+ if node['platform_family'] == 'rhel' && node['platform_version'].start_with?('7') || \
25
+ node['platform'] == 'ubuntu' && node['platform_version'].to_i >= 16
25
26
  file '/no_sysvinit'
26
27
  file '/no_upstart'
27
28
  file '/no_inittab'
@@ -18,12 +18,16 @@ require 'spec_helper'
18
18
 
19
19
  describe PoiseService::Resources::PoiseServiceUser do
20
20
  step_into(:poise_service_user)
21
+ let(:shells) { [] }
22
+ before do
23
+ allow(File).to receive(:exist?) {|s| shells.include?(s) }
24
+ end
21
25
  recipe do
22
26
  poise_service_user 'poise'
23
27
  end
24
28
 
25
29
  it { is_expected.to create_group('poise').with(gid: nil, system: true) }
26
- it { is_expected.to create_user('poise').with(gid: 'poise', home: nil, system: true, uid: nil) }
30
+ it { is_expected.to create_user('poise').with(gid: 'poise', home: nil, system: true, uid: nil, shell: '/bin/false') }
27
31
 
28
32
  context 'with an explicit user and group name' do
29
33
  recipe do
@@ -34,7 +38,7 @@ describe PoiseService::Resources::PoiseServiceUser do
34
38
  end
35
39
 
36
40
  it { is_expected.to create_group('poise_group').with(gid: nil, system: true) }
37
- it { is_expected.to create_user('poise_user').with(gid: 'poise_group', home: nil, system: true, uid: nil) }
41
+ it { is_expected.to create_user('poise_user').with(gid: 'poise_group', home: nil, system: true, uid: nil, shell: '/bin/false') }
38
42
  end # /context with an explicit user and group name
39
43
 
40
44
  context 'with no group' do
@@ -45,7 +49,7 @@ describe PoiseService::Resources::PoiseServiceUser do
45
49
  end
46
50
 
47
51
  it { is_expected.to_not create_group('poise') }
48
- it { is_expected.to create_user('poise').with(gid: nil, home: nil, system: true, uid: nil) }
52
+ it { is_expected.to create_user('poise').with(gid: nil, home: nil, system: true, uid: nil, shell: '/bin/false') }
49
53
  end # /context with no group
50
54
 
51
55
  context 'with explicit uid' do
@@ -56,7 +60,7 @@ describe PoiseService::Resources::PoiseServiceUser do
56
60
  end
57
61
 
58
62
  it { is_expected.to create_group('poise').with(gid: nil, system: true) }
59
- it { is_expected.to create_user('poise').with(gid: 'poise', home: nil, system: true, uid: 100) }
63
+ it { is_expected.to create_user('poise').with(gid: 'poise', home: nil, system: true, uid: 100, shell: '/bin/false') }
60
64
  end # /context with explicit uid
61
65
 
62
66
  context 'with explicit gid' do
@@ -67,7 +71,7 @@ describe PoiseService::Resources::PoiseServiceUser do
67
71
  end
68
72
 
69
73
  it { is_expected.to create_group('poise').with(gid: 100, system: true) }
70
- it { is_expected.to create_user('poise').with(gid: 'poise', home: nil, system: true, uid: nil) }
74
+ it { is_expected.to create_user('poise').with(gid: 'poise', home: nil, system: true, uid: nil, shell: '/bin/false') }
71
75
  end # /context with explicit gid
72
76
 
73
77
  context 'with home directory' do
@@ -78,9 +82,29 @@ describe PoiseService::Resources::PoiseServiceUser do
78
82
  end
79
83
 
80
84
  it { is_expected.to create_group('poise').with(gid: nil, system: true) }
81
- it { is_expected.to create_user('poise').with(gid: 'poise', home: '/home/poise', system: true, uid: nil) }
85
+ it { is_expected.to create_user('poise').with(gid: 'poise', home: '/home/poise', system: true, uid: nil, shell: '/bin/false') }
82
86
  end # /context with home directory
83
87
 
88
+ context 'with shell' do
89
+ recipe do
90
+ poise_service_user 'poise' do
91
+ shell '/bin/bash'
92
+ end
93
+ end
94
+
95
+ it { is_expected.to create_group('poise').with(gid: nil, system: true) }
96
+ it { is_expected.to create_user('poise').with(gid: 'poise', home: nil, system: true, uid: nil, shell: '/bin/bash') }
97
+ end # /context with shell
98
+
99
+ context 'with /bin/nologin existing' do
100
+ let(:shells) { %w{/bin/nologin} }
101
+ recipe do
102
+ poise_service_user 'poise'
103
+ end
104
+
105
+ it { is_expected.to create_user('poise').with(shell: '/bin/nologin') }
106
+ end # /context with /bin/nologin existing
107
+
84
108
  context 'with action :remove' do
85
109
  recipe do
86
110
  poise_service_user 'poise' do
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.3.1
4
+ version: 1.4.0
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-05-27 00:00:00.000000000 Z
11
+ date: 2016-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: halite
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  version: '0'
148
148
  requirements: []
149
149
  rubyforge_project:
150
- rubygems_version: 2.6.2
150
+ rubygems_version: 2.6.4
151
151
  signing_key:
152
152
  specification_version: 4
153
153
  summary: A Chef cookbook for managing system services.
@@ -173,4 +173,3 @@ test_files:
173
173
  - test/spec/service_providers/upstart_spec.rb
174
174
  - test/spec/spec_helper.rb
175
175
  - test/spec/utils_spec.rb
176
- has_rdoc: