kanrisuru 0.2.2 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/kanrisuru.gemspec +8 -8
- data/lib/kanrisuru/core.rb +9 -0
- data/lib/kanrisuru/core/apt.rb +324 -0
- data/lib/kanrisuru/core/file.rb +1 -1
- data/lib/kanrisuru/core/ip.rb +7 -7
- data/lib/kanrisuru/core/path.rb +0 -1
- data/lib/kanrisuru/core/stat.rb +1 -2
- data/lib/kanrisuru/core/system.rb +2 -1
- data/lib/kanrisuru/core/yum.rb +386 -0
- data/lib/kanrisuru/remote/os.rb +3 -1
- data/lib/kanrisuru/util.rb +4 -4
- data/lib/kanrisuru/util/bits.rb +19 -0
- data/lib/kanrisuru/util/os_family.rb +6 -1
- data/lib/kanrisuru/version.rb +1 -1
- data/spec/functional/core/apt_spec.rb +181 -0
- data/spec/functional/core/stream_spec.rb +1 -1
- data/spec/functional/core/yum_spec.rb +160 -0
- data/spec/unit/template_spec.rb +0 -2
- metadata +21 -17
@@ -145,6 +145,11 @@ module Kanrisuru
|
|
145
145
|
state: 'current',
|
146
146
|
type: 'distribution'
|
147
147
|
},
|
148
|
+
rhel: {
|
149
|
+
name: 'RHEL',
|
150
|
+
type: 'alias',
|
151
|
+
to: 'redhat'
|
152
|
+
},
|
148
153
|
centos: {
|
149
154
|
name: 'CentOS',
|
150
155
|
type: 'alias',
|
@@ -174,7 +179,7 @@ module Kanrisuru
|
|
174
179
|
sles: {
|
175
180
|
name: 'SUSE Linux Enterprise Server',
|
176
181
|
os_family: 'linux',
|
177
|
-
upstream: '
|
182
|
+
upstream: 'opensuse',
|
178
183
|
model: 'commercial',
|
179
184
|
state: 'current',
|
180
185
|
type: 'distribution'
|
data/lib/kanrisuru/version.rb
CHANGED
@@ -0,0 +1,181 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Kanrisuru::Core::Apt do
|
6
|
+
TestHosts.each_os do |os_name|
|
7
|
+
context "with #{os_name}" do
|
8
|
+
let(:host_json) { TestHosts.host(os_name) }
|
9
|
+
let(:host) do
|
10
|
+
Kanrisuru::Remote::Host.new(
|
11
|
+
host: host_json['hostname'],
|
12
|
+
username: host_json['username'],
|
13
|
+
keys: [host_json['ssh_key']]
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
after do
|
18
|
+
host.disconnect
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'apt install' do
|
22
|
+
it 'installs package' do
|
23
|
+
case os_name
|
24
|
+
when 'debian', 'ubuntu'
|
25
|
+
host.su('root')
|
26
|
+
result = host.apt('install', packages: %w[ffmpeg curl])
|
27
|
+
expect(result).to be_success
|
28
|
+
|
29
|
+
result = host.which('ffmpeg')
|
30
|
+
expect(result).to be_success
|
31
|
+
paths = result.map(&:path)
|
32
|
+
expect(paths).to include(match('ffmpeg'))
|
33
|
+
|
34
|
+
result = host.which('curl')
|
35
|
+
expect(result).to be_success
|
36
|
+
paths = result.map(&:path)
|
37
|
+
expect(paths).to include(match('curl'))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe 'apt remove' do
|
43
|
+
it 'removes installed packages' do
|
44
|
+
case os_name
|
45
|
+
when 'debian', 'ubuntu'
|
46
|
+
host.su('root')
|
47
|
+
result = host.apt('remove', packages: ['ffmpeg'])
|
48
|
+
expect(result).to be_success
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'purges installed packages' do
|
53
|
+
case os_name
|
54
|
+
when 'debian', 'ubuntu'
|
55
|
+
host.su('root')
|
56
|
+
result = host.apt('purge', packages: ['ffmpeg'])
|
57
|
+
expect(result).to be_success
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe 'apt autoremove' do
|
63
|
+
it 'removes unused packages' do
|
64
|
+
case os_name
|
65
|
+
when 'debian', 'ubuntu'
|
66
|
+
host.su('root')
|
67
|
+
result = host.apt('autoremove')
|
68
|
+
expect(result).to be_success
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe 'apt clean' do
|
74
|
+
it 'cleans packages' do
|
75
|
+
case os_name
|
76
|
+
when 'debian', 'ubuntu'
|
77
|
+
host.su('root')
|
78
|
+
result = host.apt('clean')
|
79
|
+
expect(result).to be_success
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'autocleans packages' do
|
84
|
+
case os_name
|
85
|
+
when 'debian', 'ubuntu'
|
86
|
+
host.su('root')
|
87
|
+
result = host.apt('autoclean')
|
88
|
+
expect(result).to be_success
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe 'apt update' do
|
94
|
+
it 'updates packages' do
|
95
|
+
case os_name
|
96
|
+
when 'debian', 'ubuntu'
|
97
|
+
host.su('root')
|
98
|
+
result = host.apt('update')
|
99
|
+
expect(result).to be_success
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe 'apt upgrade' do
|
105
|
+
it 'upgrades packages' do
|
106
|
+
case os_name
|
107
|
+
when 'debian', 'ubuntu'
|
108
|
+
host.su('root')
|
109
|
+
result = host.apt('upgrade')
|
110
|
+
expect(result).to be_success
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'fully upgrades packages' do
|
115
|
+
case os_name
|
116
|
+
when 'debian', 'ubuntu'
|
117
|
+
host.su('root')
|
118
|
+
result = host.apt('full-upgrade')
|
119
|
+
expect(result).to be_success
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe 'apt show' do
|
125
|
+
it 'shows details of listed packages' do
|
126
|
+
case os_name
|
127
|
+
when 'debian', 'ubuntu'
|
128
|
+
result = host.apt('show', packages: %w[wget curl git sudo])
|
129
|
+
expect(result).to be_success
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe 'apt list' do
|
135
|
+
it 'lists all packages' do
|
136
|
+
case os_name
|
137
|
+
when 'debian', 'ubuntu'
|
138
|
+
host.su('root')
|
139
|
+
result = host.apt('list')
|
140
|
+
expect(result).to be_success
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'lists installed packages' do
|
145
|
+
case os_name
|
146
|
+
when 'debian', 'ubuntu'
|
147
|
+
host.su('root')
|
148
|
+
result = host.apt('list', installed: true)
|
149
|
+
expect(result).to be_success
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'lists upgradable packages' do
|
154
|
+
case os_name
|
155
|
+
when 'debian', 'ubuntu'
|
156
|
+
host.su('root')
|
157
|
+
result = host.apt('list', upgradable: true)
|
158
|
+
expect(result).to be_success
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'lists all versions for packages' do
|
163
|
+
case os_name
|
164
|
+
when 'debian', 'ubuntu'
|
165
|
+
host.su('root')
|
166
|
+
result = host.apt('list', all_versions: true)
|
167
|
+
expect(result).to be_success
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'searches packages' do
|
172
|
+
case os_name
|
173
|
+
when 'debian', 'ubuntu'
|
174
|
+
result = host.apt('search', query: 'wget')
|
175
|
+
expect(result).to be_success
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
@@ -89,7 +89,7 @@ RSpec.describe Kanrisuru::Core::Stream do
|
|
89
89
|
result = host.read_file_chunk("#{spec_dir}/test-file-chunk.txt", 2, 4)
|
90
90
|
expect(result).to be_success
|
91
91
|
expect(result.data.length).to eq(3)
|
92
|
-
expect(result.data).to eq([
|
92
|
+
expect(result.data).to eq(%w[is is a])
|
93
93
|
end
|
94
94
|
|
95
95
|
it 'cats a file' do
|
@@ -0,0 +1,160 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Kanrisuru::Core::Yum do
|
6
|
+
TestHosts.each_os do |os_name|
|
7
|
+
context "with #{os_name}" do
|
8
|
+
let(:host_json) { TestHosts.host(os_name) }
|
9
|
+
let(:host) do
|
10
|
+
Kanrisuru::Remote::Host.new(
|
11
|
+
host: host_json['hostname'],
|
12
|
+
username: host_json['username'],
|
13
|
+
keys: [host_json['ssh_key']]
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
after do
|
18
|
+
host.disconnect
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'upgrades packages' do
|
22
|
+
case os_name
|
23
|
+
when 'centos', 'rhel', 'fedora'
|
24
|
+
host.su('root')
|
25
|
+
result = host.yum('upgrade')
|
26
|
+
expect(result).to be_success
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'updates packages' do
|
31
|
+
case os_name
|
32
|
+
when 'centos', 'rhel', 'fedora'
|
33
|
+
host.su('root')
|
34
|
+
result = host.yum('update')
|
35
|
+
expect(result).to be_success
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'installs local package from RPM' do
|
40
|
+
case os_name
|
41
|
+
when 'fedora'
|
42
|
+
package = 'rpmfusion-free-release-32.noarch.rpm'
|
43
|
+
url = "https://download1.rpmfusion.org/free/fedora/#{package}"
|
44
|
+
|
45
|
+
result = host.wget(url)
|
46
|
+
expect(result).to be_success
|
47
|
+
file = host.file("~/#{package}")
|
48
|
+
expect(file).to be_exists
|
49
|
+
|
50
|
+
host.su('root')
|
51
|
+
result = host.yum('localinstall', repos: file.expand_path)
|
52
|
+
expect(result).to be_success
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'lists installed packages' do
|
57
|
+
case os_name
|
58
|
+
when 'centos', 'rhel', 'fedora'
|
59
|
+
result = host.yum('list', installed: true)
|
60
|
+
expect(result).to be_success
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'lists repos' do
|
65
|
+
case os_name
|
66
|
+
when 'centos', 'rhel', 'fedora'
|
67
|
+
result = host.yum('repolist')
|
68
|
+
expect(result).to be_success
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'lists installed repos' do
|
73
|
+
case os_name
|
74
|
+
when 'centos', 'rhel', 'fedora'
|
75
|
+
result = host.yum('repolist', repos: 'updates')
|
76
|
+
expect(result).to be_success
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'searches a single package' do
|
81
|
+
case os_name
|
82
|
+
when 'centos', 'rhel', 'fedora'
|
83
|
+
result = host.yum('search', packages: 'curl')
|
84
|
+
expect(result).to be_success
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'searches all packages' do
|
89
|
+
case os_name
|
90
|
+
when 'centos', 'rhel', 'fedora'
|
91
|
+
result = host.yum('search', all: true, packages: %w[curl ffmpeg])
|
92
|
+
expect(result).to be_success
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'installs a package' do
|
97
|
+
case os_name
|
98
|
+
when 'centos', 'rhel', 'fedora'
|
99
|
+
host.su('root')
|
100
|
+
result = host.yum('install', packages: %(ffmpeg curl))
|
101
|
+
expect(result).to be_success
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'removes installed packages' do
|
106
|
+
case os_name
|
107
|
+
when 'centos', 'rhel', 'fedora'
|
108
|
+
host.su('root')
|
109
|
+
result = host.yum('remove', packages: ['ffmpeg'])
|
110
|
+
expect(result).to be_success
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'purges installed packages' do
|
115
|
+
case os_name
|
116
|
+
when 'centos', 'rhel', 'fedora'
|
117
|
+
host.su('root')
|
118
|
+
result = host.yum('erase', packages: ['ffmpeg'])
|
119
|
+
expect(result).to be_success
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'gets info for one package' do
|
124
|
+
case os_name
|
125
|
+
when 'centos', 'rhel', 'fedora'
|
126
|
+
host.su('root')
|
127
|
+
result = host.yum('info', packages: 'yum')
|
128
|
+
expect(result).to be_success
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'gets info for installed packages' do
|
133
|
+
case os_name
|
134
|
+
when 'centos', 'rhel', 'fedora'
|
135
|
+
host.su('root')
|
136
|
+
result = host.yum('info', installed: true)
|
137
|
+
expect(result).to be_success
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'cleans packages' do
|
142
|
+
case os_name
|
143
|
+
when 'centos', 'rhel', 'fedora'
|
144
|
+
host.su('root')
|
145
|
+
result = host.yum('clean', all: true)
|
146
|
+
expect(result).to be_success
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'autoremoves packages' do
|
151
|
+
case os_name
|
152
|
+
when 'centos', 'rhel', 'fedora'
|
153
|
+
host.su('root')
|
154
|
+
result = host.yum('autoremove')
|
155
|
+
expect(result).to be_success
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
data/spec/unit/template_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kanrisuru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Mammina
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -16,98 +16,98 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.10.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 3.10.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubocop
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.12.1
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 1.12.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rubocop-rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 2.2.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 2.2.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: simplecov
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.21.2
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.21.2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: net-ping
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 2.0.8
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 2.0.8
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: net-scp
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 3.0.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 3.0.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: net-ssh
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 6.1.0
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 6.1.0
|
111
111
|
description:
|
112
112
|
email: ryan@avamia.com
|
113
113
|
executables: []
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- lib/kanrisuru.rb
|
132
132
|
- lib/kanrisuru/command.rb
|
133
133
|
- lib/kanrisuru/core.rb
|
134
|
+
- lib/kanrisuru/core/apt.rb
|
134
135
|
- lib/kanrisuru/core/archive.rb
|
135
136
|
- lib/kanrisuru/core/disk.rb
|
136
137
|
- lib/kanrisuru/core/file.rb
|
@@ -145,6 +146,7 @@ files:
|
|
145
146
|
- lib/kanrisuru/core/system.rb
|
146
147
|
- lib/kanrisuru/core/transfer.rb
|
147
148
|
- lib/kanrisuru/core/user.rb
|
149
|
+
- lib/kanrisuru/core/yum.rb
|
148
150
|
- lib/kanrisuru/logger.rb
|
149
151
|
- lib/kanrisuru/mode.rb
|
150
152
|
- lib/kanrisuru/os_package.rb
|
@@ -165,6 +167,7 @@ files:
|
|
165
167
|
- lib/kanrisuru/util/os_family.rb
|
166
168
|
- lib/kanrisuru/util/signal.rb
|
167
169
|
- lib/kanrisuru/version.rb
|
170
|
+
- spec/functional/core/apt_spec.rb
|
168
171
|
- spec/functional/core/archive_spec.rb
|
169
172
|
- spec/functional/core/disk_spec.rb
|
170
173
|
- spec/functional/core/file_spec.rb
|
@@ -178,6 +181,7 @@ files:
|
|
178
181
|
- spec/functional/core/system_spec.rb
|
179
182
|
- spec/functional/core/transfer_spec.rb
|
180
183
|
- spec/functional/core/user_spec.rb
|
184
|
+
- spec/functional/core/yum_spec.rb
|
181
185
|
- spec/functional/os_package_spec.rb
|
182
186
|
- spec/functional/remote/cluster_spec.rb
|
183
187
|
- spec/functional/remote/cpu_spec.rb
|
@@ -219,5 +223,5 @@ requirements: []
|
|
219
223
|
rubygems_version: 3.1.2
|
220
224
|
signing_key:
|
221
225
|
specification_version: 4
|
222
|
-
summary: Manage remote servers with ruby.
|
226
|
+
summary: Manage remote servers over ssh with ruby.
|
223
227
|
test_files: []
|