moose-inventory 1.0.8 → 1.0.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 +5 -5
- data/.github/workflows/ci.yml +35 -0
- data/.gitignore +1 -1
- data/BACKLOG.md +184 -0
- data/Gemfile.lock +60 -0
- data/README.md +14 -5
- data/bin/moose-inventory +1 -1
- data/docs/release/publishing.md +113 -0
- data/docs/release/release-readiness.md +41 -0
- data/docs/security-audit-2026-05-21.md +71 -0
- data/lib/moose_inventory/cli/formatter.rb +16 -17
- data/lib/moose_inventory/cli/group.rb +1 -1
- data/lib/moose_inventory/cli/group_add.rb +19 -21
- data/lib/moose_inventory/cli/group_addchild.rb +36 -40
- data/lib/moose_inventory/cli/group_addhost.rb +14 -18
- data/lib/moose_inventory/cli/group_addvar.rb +37 -37
- data/lib/moose_inventory/cli/group_get.rb +23 -26
- data/lib/moose_inventory/cli/group_list.rb +12 -15
- data/lib/moose_inventory/cli/group_listvars.rb +12 -14
- data/lib/moose_inventory/cli/group_rm.rb +21 -23
- data/lib/moose_inventory/cli/group_rmchild.rb +5 -6
- data/lib/moose_inventory/cli/group_rmhost.rb +12 -16
- data/lib/moose_inventory/cli/group_rmvar.rb +5 -5
- data/lib/moose_inventory/cli/host.rb +1 -1
- data/lib/moose_inventory/cli/host_add.rb +18 -18
- data/lib/moose_inventory/cli/host_addgroup.rb +9 -9
- data/lib/moose_inventory/cli/host_addvar.rb +6 -6
- data/lib/moose_inventory/cli/host_get.rb +15 -18
- data/lib/moose_inventory/cli/host_list.rb +3 -3
- data/lib/moose_inventory/cli/host_listvars.rb +21 -23
- data/lib/moose_inventory/cli/host_rm.rb +9 -9
- data/lib/moose_inventory/cli/host_rmgroup.rb +5 -5
- data/lib/moose_inventory/cli/host_rmvar.rb +3 -3
- data/lib/moose_inventory/config/config.rb +43 -40
- data/lib/moose_inventory/db/db.rb +70 -50
- data/lib/moose_inventory/db/models.rb +11 -12
- data/lib/moose_inventory/version.rb +1 -1
- data/moose-inventory.gemspec +35 -20
- data/scripts/check.sh +8 -0
- data/scripts/ci/check_permissions.sh +32 -0
- data/scripts/ci/check_security.sh +50 -0
- data/scripts/ci/package_sanity.sh +46 -0
- data/scripts/files.rb +1 -4
- data/scripts/install_dependencies.sh +17 -0
- data/scripts/reports.sh +2 -2
- data/spec/lib/moose_inventory/cli/cli_spec.rb +13 -14
- data/spec/lib/moose_inventory/cli/group_add_spec.rb +118 -119
- data/spec/lib/moose_inventory/cli/group_addchild_spec.rb +49 -51
- data/spec/lib/moose_inventory/cli/group_addhost_spec.rb +80 -83
- data/spec/lib/moose_inventory/cli/group_addvar_spec.rb +91 -91
- data/spec/lib/moose_inventory/cli/group_get_spec.rb +22 -23
- data/spec/lib/moose_inventory/cli/group_list_spec.rb +19 -20
- data/spec/lib/moose_inventory/cli/group_listvar_spec.rb +35 -36
- data/spec/lib/moose_inventory/cli/group_rm_spec.rb +75 -78
- data/spec/lib/moose_inventory/cli/group_rmchild_spec.rb +41 -45
- data/spec/lib/moose_inventory/cli/group_rmhost_spec.rb +43 -46
- data/spec/lib/moose_inventory/cli/group_rmvar_spec.rb +131 -131
- data/spec/lib/moose_inventory/cli/group_spec.rb +9 -9
- data/spec/lib/moose_inventory/cli/host_add_spec.rb +103 -43
- data/spec/lib/moose_inventory/cli/host_addgroup_spec.rb +78 -80
- data/spec/lib/moose_inventory/cli/host_addvar_spec.rb +122 -122
- data/spec/lib/moose_inventory/cli/host_get_spec.rb +16 -16
- data/spec/lib/moose_inventory/cli/host_list_spec.rb +8 -8
- data/spec/lib/moose_inventory/cli/host_listvar_spec.rb +50 -52
- data/spec/lib/moose_inventory/cli/host_rm_spec.rb +12 -12
- data/spec/lib/moose_inventory/cli/host_rmgroup_spec.rb +48 -51
- data/spec/lib/moose_inventory/cli/host_rmvar_spec.rb +136 -136
- data/spec/lib/moose_inventory/config/config_spec.rb +16 -3
- data/spec/lib/moose_inventory/db/db_spec.rb +224 -2
- data/spec/lib/moose_inventory/db/models_spec.rb +10 -11
- data/spec/shared/shared_config_setup.rb +2 -2
- data/spec/spec_helper.rb +7 -8
- metadata +99 -136
- data/.coveralls.yml +0 -0
- data/.rubocop.yml +0 -793
- data/Guardfile +0 -38
- data/config/dotfiles/coveralls.yml +0 -0
- data/config/dotfiles/gitignore +0 -20
- data/config/dotfiles/rubocop.yml +0 -793
- data/scripts/guard_quality.sh +0 -3
- data/scripts/guard_test.sh +0 -2
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
pkg_dir="tmp/pkg"
|
|
5
|
+
extract_dir="tmp/package-sanity"
|
|
6
|
+
rm -rf "$pkg_dir" "$extract_dir"
|
|
7
|
+
mkdir -p "$pkg_dir" "$extract_dir"
|
|
8
|
+
|
|
9
|
+
gem_path="$pkg_dir/moose-inventory.gem"
|
|
10
|
+
gem build moose-inventory.gemspec --output "$gem_path"
|
|
11
|
+
|
|
12
|
+
gem specification "$gem_path" name --yaml > "$pkg_dir/name.yml"
|
|
13
|
+
gem specification "$gem_path" version --yaml > "$pkg_dir/version.yml"
|
|
14
|
+
gem specification "$gem_path" executables --yaml > "$pkg_dir/executables.yml"
|
|
15
|
+
gem specification "$gem_path" require_paths --yaml > "$pkg_dir/require_paths.yml"
|
|
16
|
+
gem specification "$gem_path" files --yaml > "$pkg_dir/files.yml"
|
|
17
|
+
|
|
18
|
+
tar -xf "$gem_path" -C "$extract_dir"
|
|
19
|
+
tar -xzf "$extract_dir/data.tar.gz" -C "$extract_dir"
|
|
20
|
+
|
|
21
|
+
required_files=(
|
|
22
|
+
"bin/moose-inventory"
|
|
23
|
+
"lib/moose_inventory.rb"
|
|
24
|
+
"lib/moose_inventory/version.rb"
|
|
25
|
+
"README.md"
|
|
26
|
+
"LICENSE.txt"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
for path in "${required_files[@]}"; do
|
|
30
|
+
if [[ ! -f "$extract_dir/$path" ]]; then
|
|
31
|
+
echo "Packaged gem is missing required file: $path" >&2
|
|
32
|
+
exit 1
|
|
33
|
+
fi
|
|
34
|
+
done
|
|
35
|
+
|
|
36
|
+
if ! grep -q "^- moose-inventory$" "$pkg_dir/executables.yml"; then
|
|
37
|
+
echo "Packaged gem metadata does not expose the moose-inventory executable." >&2
|
|
38
|
+
exit 1
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
if ! bundle exec ruby -Ilib bin/moose-inventory --config spec/config/config.yml version | grep -q '^Version '; then
|
|
42
|
+
echo "CLI version smoke failed." >&2
|
|
43
|
+
exit 1
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
printf 'Package sanity passed: %s\n' "$gem_path"
|
data/scripts/files.rb
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
sudo dnf groupinstall -y "C Development Tools and Libraries" "Development Tools"
|
|
5
|
+
sudo dnf install -y \
|
|
6
|
+
ansible \
|
|
7
|
+
ruby \
|
|
8
|
+
ruby-devel \
|
|
9
|
+
rubygem-bundler \
|
|
10
|
+
sqlite \
|
|
11
|
+
sqlite-libs \
|
|
12
|
+
sqlite-devel \
|
|
13
|
+
mariadb-connector-c-devel \
|
|
14
|
+
libpq-devel \
|
|
15
|
+
libffi \
|
|
16
|
+
libffi-devel \
|
|
17
|
+
rpm-build
|
data/scripts/reports.sh
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
RSpec.describe Moose::Inventory::Cli::Application do
|
|
4
4
|
before do
|
|
5
5
|
@app = Moose::Inventory::Cli::Application
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
describe
|
|
8
|
+
describe '.version' do
|
|
9
9
|
# --------------------
|
|
10
10
|
it 'method should be responsive' do
|
|
11
11
|
result = @app.instance_methods(false).include?(:version)
|
|
12
12
|
expect(result).to eq(true)
|
|
13
13
|
end
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
# --------------------
|
|
16
|
-
# it 'should output version information' do
|
|
17
|
-
# actual = runner { @app.version }
|
|
18
|
-
#
|
|
19
|
-
# desired = {}
|
|
20
|
-
# desired[:STDERR] = "Version #{Moose::Inventory::VERSION}"
|
|
21
|
-
#
|
|
22
|
-
# expected(actual, desired)
|
|
23
|
-
# end
|
|
24
|
-
|
|
16
|
+
# it 'should output version information' do
|
|
17
|
+
# actual = runner { @app.version }
|
|
18
|
+
#
|
|
19
|
+
# desired = {}
|
|
20
|
+
# desired[:STDERR] = "Version #{Moose::Inventory::VERSION}"
|
|
21
|
+
#
|
|
22
|
+
# expected(actual, desired)
|
|
23
|
+
# end
|
|
25
24
|
end
|
|
26
|
-
|
|
25
|
+
end
|
|
@@ -12,20 +12,20 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
12
12
|
env: 'test',
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
@mockargs = []
|
|
15
|
+
@mockargs = []
|
|
16
16
|
@mockarg_parts.each do |key, val|
|
|
17
17
|
@mockargs << "--#{key}"
|
|
18
18
|
@mockargs << val
|
|
19
19
|
end
|
|
20
20
|
@mockargs << '--trace' # extra info for debugging
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
@console = Moose::Inventory::Cli::Formatter
|
|
23
23
|
|
|
24
24
|
@config = Moose::Inventory::Config
|
|
25
25
|
@config.init(@mockargs)
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
@db = Moose::Inventory::DB
|
|
28
|
-
@db.init if @db.db.nil?
|
|
28
|
+
@db.init if @db.db.nil?
|
|
29
29
|
|
|
30
30
|
@host = Moose::Inventory::Cli::Host
|
|
31
31
|
@group = Moose::Inventory::Cli::Group
|
|
@@ -48,29 +48,29 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
48
48
|
it '<no arguments> ... should bail with an error' do
|
|
49
49
|
actual = runner { @app.start(%w(group add)) }
|
|
50
50
|
|
|
51
|
-
desired = {aborted: true}
|
|
51
|
+
desired = { aborted: true }
|
|
52
52
|
desired[:STDERR] = "ERROR: Wrong number of arguments, 0 for 1 or more.\n"
|
|
53
53
|
expected(actual, desired)
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
# --------------------
|
|
57
57
|
it 'ungrouped ... should abort with an error' do
|
|
58
|
-
actual = runner { @app.start(%
|
|
58
|
+
actual = runner { @app.start(%w(group add ungrouped)) }
|
|
59
59
|
|
|
60
60
|
# Check output
|
|
61
|
-
desired = {aborted: true}
|
|
61
|
+
desired = { aborted: true }
|
|
62
62
|
desired[:STDERR] =
|
|
63
63
|
"ERROR: Cannot manually manipulate the automatic group 'ungrouped'\n"
|
|
64
64
|
expected(actual, desired)
|
|
65
|
-
end
|
|
65
|
+
end
|
|
66
66
|
|
|
67
67
|
# --------------------
|
|
68
68
|
it 'GROUP ... should add a group to the db' do
|
|
69
69
|
name = 'test'
|
|
70
70
|
actual = runner { @app.start(%W(group add #{name})) }
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
# @console.out(actual)
|
|
73
|
+
|
|
74
74
|
# Check output
|
|
75
75
|
desired = {}
|
|
76
76
|
desired[:STDOUT] =
|
|
@@ -94,8 +94,8 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
94
94
|
|
|
95
95
|
actual = runner { @app.start(%W(group add #{name})) }
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
# @console.out(actual)
|
|
98
|
+
|
|
99
99
|
# Check output
|
|
100
100
|
desired = {}
|
|
101
101
|
desired[:STDOUT] =
|
|
@@ -105,12 +105,11 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
105
105
|
" - OK\n"\
|
|
106
106
|
" - all OK\n"\
|
|
107
107
|
"Succeeded, with warnings.\n"
|
|
108
|
-
desired[:STDERR] =
|
|
108
|
+
desired[:STDERR] =
|
|
109
109
|
"WARNING: Group '#{name}' already exists, skipping creation.\n"
|
|
110
110
|
|
|
111
111
|
expected(actual, desired)
|
|
112
112
|
|
|
113
|
-
|
|
114
113
|
expected(actual, desired)
|
|
115
114
|
end
|
|
116
115
|
|
|
@@ -120,16 +119,16 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
120
119
|
|
|
121
120
|
actual = runner { @app.start(%w(group add) + names) }
|
|
122
121
|
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
# @console.out(actual)
|
|
123
|
+
|
|
125
124
|
# Check output
|
|
126
|
-
desired = {STDOUT: ''}
|
|
125
|
+
desired = { STDOUT: '' }
|
|
127
126
|
names.each do |name|
|
|
128
|
-
desired[:STDOUT] =
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
127
|
+
desired[:STDOUT] = desired[:STDOUT] +
|
|
128
|
+
"Add group '#{name}':\n"\
|
|
129
|
+
" - create group...\n"\
|
|
130
|
+
" - OK\n"\
|
|
131
|
+
" - all OK\n"\
|
|
133
132
|
end
|
|
134
133
|
desired[:STDOUT] = desired[:STDOUT] + "Succeeded\n"
|
|
135
134
|
|
|
@@ -145,7 +144,7 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
145
144
|
# --------------------
|
|
146
145
|
it 'GROUP1 --hosts HOST1 ... should add the '\
|
|
147
146
|
'group and associate it with existing hosts' do
|
|
148
|
-
|
|
147
|
+
|
|
149
148
|
host_name = 'test-host'
|
|
150
149
|
@db.models[:host].create(name: host_name)
|
|
151
150
|
|
|
@@ -154,8 +153,8 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
154
153
|
@app.start(%W(group add #{group_name} --hosts #{host_name}))
|
|
155
154
|
end
|
|
156
155
|
|
|
157
|
-
|
|
158
|
-
|
|
156
|
+
# @console.out(actual)
|
|
157
|
+
|
|
159
158
|
# Check output
|
|
160
159
|
desired = {}
|
|
161
160
|
desired[:STDOUT] =
|
|
@@ -179,57 +178,57 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
179
178
|
|
|
180
179
|
# --------------------
|
|
181
180
|
it 'GROUP1 --hosts HOST ... should create HOST if necessary, and warn' do
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
181
|
+
host_name = 'test-host'
|
|
182
|
+
|
|
183
|
+
# DON'T CREATE THE HOST! That's the point!
|
|
184
|
+
|
|
185
|
+
group_name = 'test-group'
|
|
186
|
+
actual = runner do
|
|
187
|
+
@app.start(%W(group add #{group_name} --hosts #{host_name}))
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# @console.out(actual)
|
|
191
|
+
|
|
192
|
+
# Check output
|
|
193
|
+
desired = {}
|
|
194
|
+
desired[:STDOUT] =
|
|
195
|
+
"Add group '#{group_name}':\n"\
|
|
196
|
+
" - create group...\n"\
|
|
197
|
+
" - OK\n"\
|
|
198
|
+
" - add association {group:#{group_name} <-> host:#{host_name}}...\n"\
|
|
199
|
+
" - host doesn't exist, creating now...\n"\
|
|
200
|
+
" - OK\n"\
|
|
201
|
+
" - OK\n"\
|
|
202
|
+
" - all OK\n"\
|
|
203
|
+
"Succeeded, with warnings.\n"
|
|
204
|
+
desired[:STDERR] =
|
|
205
|
+
"WARNING: Host '#{host_name}' doesn't exist, but will be created.\n"
|
|
206
|
+
|
|
207
|
+
expected(actual, desired)
|
|
208
|
+
|
|
209
|
+
# Check db
|
|
210
|
+
group = @db.models[:group].find(name: group_name)
|
|
211
|
+
hosts = group.hosts_dataset
|
|
212
|
+
expect(hosts).not_to be_nil
|
|
213
|
+
expect(hosts.count).to eq(1)
|
|
214
|
+
expect(hosts[name: host_name]).not_to be_nil
|
|
216
215
|
end
|
|
217
216
|
|
|
218
217
|
# --------------------
|
|
219
218
|
it 'GROUP1 --hosts HOST ... should skip if association already exists, and warn' do
|
|
220
219
|
host_name = 'test-host'
|
|
221
220
|
group_name = 'test-group'
|
|
222
|
-
|
|
221
|
+
|
|
223
222
|
# Create group and association
|
|
224
223
|
runner { @app.start(%W(group add #{group_name} --hosts #{host_name})) }
|
|
225
|
-
|
|
224
|
+
|
|
226
225
|
# Do it again, to prove that we skip
|
|
227
226
|
actual = runner do
|
|
228
227
|
@app.start(%W(group add #{group_name} --hosts #{host_name}))
|
|
229
228
|
end
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
229
|
+
|
|
230
|
+
# @console.out(actual, 'y')
|
|
231
|
+
|
|
233
232
|
# Check output
|
|
234
233
|
desired = {}
|
|
235
234
|
desired[:STDOUT] =
|
|
@@ -242,12 +241,12 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
242
241
|
" - OK\n"\
|
|
243
242
|
" - all OK\n"\
|
|
244
243
|
"Succeeded, with warnings.\n"
|
|
245
|
-
desired[:STDERR] =
|
|
244
|
+
desired[:STDERR] =
|
|
246
245
|
"WARNING: Group '#{group_name}' already exists, skipping creation.\n"\
|
|
247
246
|
"WARNING: Association {group:#{group_name} <-> host:#{host_name}} already exists, skipping creation.\n"
|
|
248
|
-
|
|
247
|
+
|
|
249
248
|
expected(actual, desired)
|
|
250
|
-
|
|
249
|
+
|
|
251
250
|
# Check db
|
|
252
251
|
group = @db.models[:group].find(name: group_name)
|
|
253
252
|
hosts = group.hosts_dataset
|
|
@@ -255,35 +254,35 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
255
254
|
expect(hosts.count).to eq(1)
|
|
256
255
|
expect(hosts[name: host_name]).not_to be_nil
|
|
257
256
|
end
|
|
258
|
-
|
|
257
|
+
|
|
259
258
|
# --------------------
|
|
260
259
|
it 'GROUP --hosts HOST1,HOST2 ... should add the group and '\
|
|
261
260
|
'associate it with multiple hosts' do
|
|
262
|
-
|
|
261
|
+
|
|
263
262
|
# The group should be added
|
|
264
263
|
# Each host should be associated with the group
|
|
265
264
|
# Each host should be removed from the automatic 'ungrouped' group
|
|
266
|
-
|
|
265
|
+
|
|
267
266
|
group_name = 'test-group'
|
|
268
267
|
host_names = %w(host1 host2 host3)
|
|
269
|
-
|
|
268
|
+
|
|
270
269
|
# Add just the first host. This ensure that we cover paths for both
|
|
271
270
|
# and existing host (with an 'ungrouped' association) and for none
|
|
272
|
-
# existing groups.
|
|
271
|
+
# existing groups.
|
|
273
272
|
tmp = runner { @app.start(%W(host add #{host_names[0]})) }
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
# Now run the actual group addition
|
|
273
|
+
|
|
274
|
+
# @console.out(tmp, 'y')
|
|
275
|
+
|
|
276
|
+
# Now run the actual group addition
|
|
278
277
|
actual = runner do
|
|
279
278
|
@app.start(%W(group add #{group_name} --hosts #{host_names.join(',')}))
|
|
280
279
|
end
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
280
|
+
|
|
281
|
+
# @console.out(actual,'y')
|
|
282
|
+
|
|
284
283
|
# Check output
|
|
285
284
|
desired = { aborted: false, STDERR: '', STDOUT: '' }
|
|
286
|
-
desired[:STDOUT] =
|
|
285
|
+
desired[:STDOUT] =
|
|
287
286
|
"Add group '#{group_name}':\n"\
|
|
288
287
|
" - create group...\n"\
|
|
289
288
|
" - OK\n"\
|
|
@@ -291,22 +290,22 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
291
290
|
" - OK\n"\
|
|
292
291
|
" - remove automatic association {group:ungrouped <-> host:#{host_names[0]}}...\n"\
|
|
293
292
|
" - OK\n"
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
293
|
+
|
|
294
|
+
host_names.slice(1, host_names.length - 1).each do |host_name|
|
|
295
|
+
desired[:STDOUT] = desired[:STDOUT] +
|
|
296
|
+
" - add association {group:#{group_name} <-> host:#{host_name}}...\n"\
|
|
297
|
+
" - host doesn't exist, creating now...\n"\
|
|
298
|
+
" - OK\n"\
|
|
299
|
+
" - OK\n"
|
|
300
|
+
desired[:STDERR] = desired[:STDERR] +
|
|
301
|
+
"WARNING: Host '#{host_name}' doesn't exist, but will be created.\n"
|
|
303
302
|
end
|
|
304
|
-
desired[:STDOUT] = desired[:STDOUT] +
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
303
|
+
desired[:STDOUT] = desired[:STDOUT] +
|
|
304
|
+
" - all OK\n"\
|
|
305
|
+
"Succeeded, with warnings.\n"
|
|
306
|
+
|
|
308
307
|
expected(actual, desired)
|
|
309
|
-
|
|
308
|
+
|
|
310
309
|
# Check db
|
|
311
310
|
group = @db.models[:group].find(name: group_name)
|
|
312
311
|
hosts = group.hosts_dataset
|
|
@@ -323,16 +322,16 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
323
322
|
'with an error' do
|
|
324
323
|
name = 'testhost'
|
|
325
324
|
group_names = %w(group1 ungrouped)
|
|
326
|
-
|
|
325
|
+
|
|
327
326
|
actual = runner do
|
|
328
327
|
@app.start(%W(host add #{name} --groups #{group_names.join(',')}))
|
|
329
328
|
end
|
|
330
|
-
|
|
329
|
+
|
|
331
330
|
# Check output
|
|
332
331
|
desired = { aborted: true, STDERR: '', STDOUT: '' }
|
|
333
332
|
desired[:STDERR] =
|
|
334
|
-
|
|
335
|
-
|
|
333
|
+
"ERROR: Cannot manually manipulate the automatic group 'ungrouped'.\n"
|
|
334
|
+
|
|
336
335
|
expected(actual, desired)
|
|
337
336
|
end
|
|
338
337
|
|
|
@@ -347,38 +346,38 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
347
346
|
actual = runner do
|
|
348
347
|
@app.start(%w(group add) + group_names + %W(--hosts #{host_names.join(',')}))
|
|
349
348
|
end
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
349
|
+
|
|
350
|
+
# @console.out(actual,'y')
|
|
351
|
+
|
|
353
352
|
# Check output
|
|
354
353
|
desired = { aborted: false, STDERR: '', STDOUT: '' }
|
|
355
354
|
first_pass = true
|
|
356
355
|
group_names.each do |group|
|
|
357
|
-
desired[:STDOUT] = desired[:STDOUT] +
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
356
|
+
desired[:STDOUT] = desired[:STDOUT] +
|
|
357
|
+
"Add group '#{group}':\n"\
|
|
358
|
+
" - create group...\n"\
|
|
359
|
+
" - OK\n"
|
|
360
|
+
|
|
362
361
|
host_names.each do |host|
|
|
363
|
-
desired[:STDOUT] = desired[:STDOUT] +
|
|
364
|
-
|
|
362
|
+
desired[:STDOUT] = desired[:STDOUT] +
|
|
363
|
+
" - add association {group:#{group} <-> host:#{host}}...\n"
|
|
365
364
|
if first_pass
|
|
366
|
-
desired[:STDOUT] = desired[:STDOUT] +
|
|
367
|
-
|
|
368
|
-
|
|
365
|
+
desired[:STDOUT] = desired[:STDOUT] +
|
|
366
|
+
" - host doesn't exist, creating now...\n"\
|
|
367
|
+
" - OK\n"
|
|
369
368
|
end
|
|
370
|
-
desired[:STDOUT] = desired[:STDOUT] +
|
|
371
|
-
|
|
369
|
+
desired[:STDOUT] = desired[:STDOUT] +
|
|
370
|
+
" - OK\n"
|
|
372
371
|
end
|
|
373
|
-
desired[:STDOUT] = desired[:STDOUT] +
|
|
374
|
-
|
|
372
|
+
desired[:STDOUT] = desired[:STDOUT] +
|
|
373
|
+
" - all OK\n"
|
|
375
374
|
first_pass = false
|
|
376
|
-
end
|
|
377
|
-
|
|
375
|
+
end
|
|
376
|
+
|
|
378
377
|
desired[:STDOUT] = desired[:STDOUT] + "Succeeded, with warnings.\n"
|
|
379
378
|
host_names.each do |host|
|
|
380
|
-
desired[:STDERR] =
|
|
381
|
-
|
|
379
|
+
desired[:STDERR] = desired[:STDERR] +
|
|
380
|
+
"WARNING: Host '#{host}' doesn't exist, but will be created.\n"
|
|
382
381
|
end
|
|
383
382
|
expected(actual, desired)
|
|
384
383
|
|