moose-inventory 1.0.7 → 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 +23 -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 +36 -21
- 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 +103 -49
- 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
|
@@ -9,7 +9,7 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
9
9
|
@mockarg_parts = {
|
|
10
10
|
config: File.join(spec_root, 'config/config.yml'),
|
|
11
11
|
format: 'yaml',
|
|
12
|
-
env: 'test'
|
|
12
|
+
env: 'test',
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
@mockargs = []
|
|
@@ -22,7 +22,7 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
22
22
|
@config.init(@mockargs)
|
|
23
23
|
|
|
24
24
|
@console = Moose::Inventory::Cli::Formatter
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
@db = Moose::Inventory::DB
|
|
27
27
|
@db.init if @db.db.nil?
|
|
28
28
|
|
|
@@ -52,18 +52,17 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
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 rm ungrouped)) }
|
|
59
59
|
|
|
60
60
|
# Check output
|
|
61
|
-
desired = {aborted: true}
|
|
61
|
+
desired = { aborted: true }
|
|
62
62
|
desired[:STDERR] =
|
|
63
63
|
"Cannot manually manipulate the automatic group 'ungrouped'\n"
|
|
64
64
|
expected(actual, desired)
|
|
65
|
-
end
|
|
66
|
-
|
|
65
|
+
end
|
|
67
66
|
|
|
68
67
|
#---------------
|
|
69
68
|
it '<non-existent group> ... should warn about non-existent groups' do
|
|
@@ -73,10 +72,10 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
73
72
|
# already exists.
|
|
74
73
|
|
|
75
74
|
# no items in the db
|
|
76
|
-
group_name =
|
|
77
|
-
actual = runner {
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
group_name = 'fake'
|
|
76
|
+
actual = runner { @app.start(%W(group rm #{group_name})) }
|
|
77
|
+
|
|
78
|
+
# @console.out(actual,'y')
|
|
80
79
|
desired = {}
|
|
81
80
|
desired[:STDOUT] =
|
|
82
81
|
"Remove group '#{group_name}':\n"\
|
|
@@ -114,26 +113,26 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
114
113
|
group = @db.models[:group].find(name: group_name)
|
|
115
114
|
expect(group).to be_nil
|
|
116
115
|
end
|
|
117
|
-
|
|
116
|
+
|
|
118
117
|
#---------------
|
|
119
118
|
it "GROUP ... should handle the automatic 'ungrouped' group for associated hosts" do
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
# Check output
|
|
119
|
+
host_name = 'test-host1'
|
|
120
|
+
group_name = 'test-group1'
|
|
121
|
+
|
|
122
|
+
tmp = runner { @app.start(%W(group add #{group_name} --hosts #{host_name})) }
|
|
123
|
+
expect(tmp[:unexpected]).to eq(false)
|
|
124
|
+
expect(tmp[:aborted]).to eq(false)
|
|
125
|
+
host = @db.models[:host].find(name: host_name)
|
|
126
|
+
groups_ds = host.groups_dataset
|
|
127
|
+
expect(groups_ds).not_to be_nil
|
|
128
|
+
expect(groups_ds[name: 'ungrouped']).to be_nil # Shouldn't be ungrouped
|
|
129
|
+
|
|
130
|
+
# Now do the rm
|
|
131
|
+
actual = runner { @app.start(%W(group rm #{group_name})) }
|
|
132
|
+
|
|
133
|
+
# @console.out(actual)
|
|
134
|
+
|
|
135
|
+
# Check output
|
|
137
136
|
desired = {}
|
|
138
137
|
desired[:STDOUT] =
|
|
139
138
|
"Remove group '#{group_name}':\n"\
|
|
@@ -147,16 +146,16 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
147
146
|
"Succeeded.\n"
|
|
148
147
|
expected(actual, desired)
|
|
149
148
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
149
|
+
# Check db
|
|
150
|
+
group = @db.models[:group].find(name: group_name)
|
|
151
|
+
expect(group).to be_nil
|
|
152
|
+
|
|
153
|
+
host = @db.models[:host].find(name: host_name)
|
|
154
|
+
expect(host).not_to be_nil
|
|
155
|
+
groups_ds = host.groups_dataset
|
|
156
|
+
expect(groups_ds).not_to be_nil
|
|
157
|
+
expect(groups_ds[name: 'ungrouped']).not_to be_nil
|
|
158
|
+
end
|
|
160
159
|
|
|
161
160
|
#---------------
|
|
162
161
|
it 'GROUP1 GROUP2 ... should remove multiple groups' do
|
|
@@ -168,24 +167,79 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
168
167
|
actual = runner { @app.start(%w(group rm) + names) }
|
|
169
168
|
|
|
170
169
|
# Check output
|
|
171
|
-
desired = {STDOUT: ''}
|
|
170
|
+
desired = { STDOUT: '' }
|
|
172
171
|
names.each do |name|
|
|
173
172
|
# Check output
|
|
174
173
|
desired[:STDOUT] = desired[:STDOUT] +
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
174
|
+
"Remove group '#{name}':\n"\
|
|
175
|
+
" - Retrieve group '#{name}'...\n"\
|
|
176
|
+
" - OK\n"\
|
|
177
|
+
" - Destroy group '#{name}'...\n"\
|
|
178
|
+
" - OK\n"\
|
|
179
|
+
" - All OK\n"
|
|
181
180
|
end
|
|
182
181
|
desired[:STDOUT] = desired[:STDOUT] + "Succeeded.\n"
|
|
183
182
|
expected(actual, desired)
|
|
184
|
-
|
|
185
183
|
|
|
186
184
|
# Check db
|
|
187
|
-
|
|
188
|
-
expect(
|
|
185
|
+
groups = @db.models[:group].all
|
|
186
|
+
expect(groups.count).to eq(0)
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
#---------------
|
|
190
|
+
it 'GROUP ... should remove GROUP, where GROUP has an associated parent.' do
|
|
191
|
+
@db.models[:group].create(name: 'parent')
|
|
192
|
+
runner { @app.start(%w(group addchild parent child)) }
|
|
193
|
+
|
|
194
|
+
actual = runner { @app.start(%w(group rm child)) }
|
|
195
|
+
|
|
196
|
+
# Check output
|
|
197
|
+
desired = { STDOUT: '' }
|
|
198
|
+
# Check output
|
|
199
|
+
desired[:STDOUT] = desired[:STDOUT] +
|
|
200
|
+
"Remove group 'child':\n"\
|
|
201
|
+
" - Retrieve group 'child'...\n"\
|
|
202
|
+
" - OK\n"\
|
|
203
|
+
" - Remove association {group:child <-> group:parent}...\n"\
|
|
204
|
+
" - OK\n"\
|
|
205
|
+
" - Destroy group 'child'...\n"\
|
|
206
|
+
" - OK\n"\
|
|
207
|
+
" - All OK\n"
|
|
208
|
+
|
|
209
|
+
desired[:STDOUT] = desired[:STDOUT] + "Succeeded.\n"
|
|
210
|
+
expected(actual, desired)
|
|
211
|
+
|
|
212
|
+
# Check db
|
|
213
|
+
groups = @db.models[:group].all
|
|
214
|
+
expect(groups.count).to eq(1)
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
#---------------
|
|
218
|
+
it 'GROUP ... should remove GROUP, where GROUP has an associated child.' do
|
|
219
|
+
@db.models[:group].create(name: 'parent')
|
|
220
|
+
runner { @app.start(%w(group addchild parent child)) }
|
|
221
|
+
|
|
222
|
+
actual = runner { @app.start(%w(group rm parent)) }
|
|
223
|
+
|
|
224
|
+
# Check output
|
|
225
|
+
desired = { STDOUT: '' }
|
|
226
|
+
# Check output
|
|
227
|
+
desired[:STDOUT] = desired[:STDOUT] +
|
|
228
|
+
"Remove group 'parent':\n"\
|
|
229
|
+
" - Retrieve group 'parent'...\n"\
|
|
230
|
+
" - OK\n"\
|
|
231
|
+
" - Remove association {group:parent <-> group:child}...\n"\
|
|
232
|
+
" - OK\n"\
|
|
233
|
+
" - Destroy group 'parent'...\n"\
|
|
234
|
+
" - OK\n"\
|
|
235
|
+
" - All OK\n"
|
|
236
|
+
|
|
237
|
+
desired[:STDOUT] = desired[:STDOUT] + "Succeeded.\n"
|
|
238
|
+
expected(actual, desired)
|
|
239
|
+
|
|
240
|
+
# Check db
|
|
241
|
+
groups = @db.models[:group].all
|
|
242
|
+
expect(groups.count).to eq(1)
|
|
189
243
|
end
|
|
190
244
|
end
|
|
191
245
|
end
|
|
@@ -9,7 +9,7 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
9
9
|
@mockarg_parts = {
|
|
10
10
|
config: File.join(spec_root, 'config/config.yml'),
|
|
11
11
|
format: 'yaml',
|
|
12
|
-
env: 'test'
|
|
12
|
+
env: 'test',
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
@mockargs = []
|
|
@@ -19,7 +19,7 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
@console = Moose::Inventory::Cli::Formatter
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
@config = Moose::Inventory::Config
|
|
24
24
|
@config.init(@mockargs)
|
|
25
25
|
|
|
@@ -49,65 +49,63 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
49
49
|
@app.start(%w(group addchild))
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
# @console.out(actual, 'y')
|
|
53
|
+
|
|
54
54
|
# Check output
|
|
55
|
-
desired = { aborted: true}
|
|
55
|
+
desired = { aborted: true }
|
|
56
56
|
desired[:STDERR] = "ERROR: Wrong number of arguments, 0 for 2 or more.\n"
|
|
57
57
|
expected(actual, desired)
|
|
58
58
|
end
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
#------------------------
|
|
61
61
|
it 'ungrouped ... should abort with an error' do
|
|
62
|
-
parent_name =
|
|
63
|
-
child_name =
|
|
64
|
-
|
|
65
|
-
actual = runner
|
|
62
|
+
parent_name = 'ungrouped'
|
|
63
|
+
child_name = 'fake'
|
|
64
|
+
|
|
65
|
+
actual = runner do
|
|
66
66
|
@app.start(%W(group addchild #{parent_name} #{child_name}))
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
# @console.out(actual, 'y')
|
|
70
|
+
|
|
71
71
|
# Check output
|
|
72
|
-
desired = { aborted: true}
|
|
72
|
+
desired = { aborted: true }
|
|
73
73
|
desired[:STDERR] = "ERROR: Cannot manually manipulate the automatic group 'ungrouped'.\n"
|
|
74
74
|
expected(actual, desired)
|
|
75
|
-
|
|
75
|
+
|
|
76
76
|
############################
|
|
77
|
-
# Should work the other way round too, when the child in the ungrouped item
|
|
78
|
-
parent_name =
|
|
79
|
-
child_name =
|
|
80
|
-
|
|
81
|
-
actual = runner
|
|
77
|
+
# Should work the other way round too, when the child in the ungrouped item
|
|
78
|
+
parent_name = 'fake'
|
|
79
|
+
child_name = 'ungrouped'
|
|
80
|
+
|
|
81
|
+
actual = runner do
|
|
82
82
|
@app.start(%W(group rmchild #{parent_name} #{child_name}))
|
|
83
83
|
end
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
# @console.out(actual, 'y')
|
|
86
|
+
|
|
87
87
|
# Check output
|
|
88
|
-
desired = { aborted: true}
|
|
88
|
+
desired = { aborted: true }
|
|
89
89
|
desired[:STDERR] = "ERROR: Cannot manually manipulate the automatic group 'ungrouped'.\n"
|
|
90
90
|
expected(actual, desired)
|
|
91
|
-
|
|
92
|
-
end
|
|
91
|
+
end
|
|
93
92
|
|
|
94
93
|
#------------------------
|
|
95
94
|
it 'GROUP CHILDGROUP ... should abort if GROUP does not exist' do
|
|
96
|
-
|
|
97
95
|
pname = 'parent_group'
|
|
98
96
|
cname = 'child group'
|
|
99
|
-
|
|
97
|
+
|
|
100
98
|
actual = runner do
|
|
101
99
|
@app.start(%W(group rmchild #{pname} #{cname}))
|
|
102
100
|
end
|
|
103
101
|
|
|
104
|
-
|
|
102
|
+
# @console.out(actual, 'y')
|
|
105
103
|
# Check output
|
|
106
|
-
desired = { aborted: true}
|
|
107
|
-
desired[:STDOUT] =
|
|
104
|
+
desired = { aborted: true }
|
|
105
|
+
desired[:STDOUT] =
|
|
108
106
|
"Dissociate parent group '#{pname}' from child group(s) '#{cname}':\n"\
|
|
109
107
|
" - retrieve group '#{pname}'...\n"
|
|
110
|
-
desired[:STDERR] =
|
|
108
|
+
desired[:STDERR] =
|
|
111
109
|
"ERROR: The group '#{pname}' does not exist.\n"\
|
|
112
110
|
"An error occurred during a transaction, any changes have been rolled back.\n"
|
|
113
111
|
expected(actual, desired)
|
|
@@ -115,21 +113,20 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
115
113
|
|
|
116
114
|
#------------------------
|
|
117
115
|
it 'GROUP CHILDGROUP ... should succeed with warnings if CHILDGROUP is not associated' do
|
|
118
|
-
|
|
119
116
|
pname = 'parent_group'
|
|
120
117
|
cname = 'child group'
|
|
121
118
|
|
|
122
119
|
runner { @app.start(%W(group add #{pname} #{cname})) }
|
|
123
|
-
|
|
120
|
+
|
|
124
121
|
actual = runner do
|
|
125
122
|
@app.start(%W(group rmchild #{pname} #{cname}))
|
|
126
123
|
end
|
|
127
124
|
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
# @console.out(actual, 'y')
|
|
126
|
+
|
|
130
127
|
# Check output
|
|
131
128
|
desired = {}
|
|
132
|
-
desired[:STDOUT] =
|
|
129
|
+
desired[:STDOUT] =
|
|
133
130
|
"Dissociate parent group '#{pname}' from child group(s) '#{cname}':\n"\
|
|
134
131
|
" - retrieve group '#{pname}'...\n"\
|
|
135
132
|
" - OK\n"\
|
|
@@ -137,9 +134,9 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
137
134
|
" - doesn't exist, skipping.\n"\
|
|
138
135
|
" - OK\n"\
|
|
139
136
|
" - all OK\n"\
|
|
140
|
-
"Succeeded, with warnings.\n"
|
|
141
|
-
|
|
142
|
-
desired[:STDERR] =
|
|
137
|
+
"Succeeded, with warnings.\n"
|
|
138
|
+
|
|
139
|
+
desired[:STDERR] =
|
|
143
140
|
"WARNING: Association {group:#{pname} <-> group:#{cname}} does not exist, skipping.\n"
|
|
144
141
|
|
|
145
142
|
expected(actual, desired)
|
|
@@ -147,30 +144,29 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
147
144
|
|
|
148
145
|
#------------------------
|
|
149
146
|
it 'GROUP CHILDGROUP ... should succeed without warnings if CHILDGROUP is associated' do
|
|
150
|
-
|
|
151
147
|
pname = 'parent_group'
|
|
152
148
|
cname = 'child group'
|
|
153
149
|
|
|
154
150
|
runner { @app.start(%W(group add #{pname} #{cname})) }
|
|
155
151
|
runner { @app.start(%W(group addchild #{pname} #{cname})) }
|
|
156
|
-
|
|
152
|
+
|
|
157
153
|
actual = runner do
|
|
158
154
|
@app.start(%W(group rmchild #{pname} #{cname}))
|
|
159
155
|
end
|
|
160
156
|
|
|
161
|
-
|
|
162
|
-
|
|
157
|
+
# @console.out(actual, 'y')
|
|
158
|
+
|
|
163
159
|
# Check output
|
|
164
160
|
desired = {}
|
|
165
|
-
desired[:STDOUT] =
|
|
161
|
+
desired[:STDOUT] =
|
|
166
162
|
"Dissociate parent group '#{pname}' from child group(s) '#{cname}':\n"\
|
|
167
163
|
" - retrieve group '#{pname}'...\n"\
|
|
168
164
|
" - OK\n"\
|
|
169
165
|
" - remove association {group:#{pname} <-> group:#{cname}}...\n"\
|
|
170
166
|
" - OK\n"\
|
|
171
167
|
" - all OK\n"\
|
|
172
|
-
"Succeeded.\n"
|
|
173
|
-
|
|
168
|
+
"Succeeded.\n"
|
|
169
|
+
|
|
174
170
|
expected(actual, desired)
|
|
175
171
|
end
|
|
176
172
|
end
|
|
@@ -9,7 +9,7 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
9
9
|
@mockarg_parts = {
|
|
10
10
|
config: File.join(spec_root, 'config/config.yml'),
|
|
11
11
|
format: 'yaml',
|
|
12
|
-
env: 'test'
|
|
12
|
+
env: 'test',
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
@mockargs = []
|
|
@@ -41,7 +41,7 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
41
41
|
result = @group.instance_methods(false).include?(:rmhost)
|
|
42
42
|
expect(result).to eq(true)
|
|
43
43
|
end
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
#----------------
|
|
46
46
|
|
|
47
47
|
#------------------------
|
|
@@ -51,7 +51,7 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
# Check output
|
|
54
|
-
desired = { aborted: true}
|
|
54
|
+
desired = { aborted: true }
|
|
55
55
|
desired[:STDERR] = "ERROR: Wrong number of arguments, 0 for 2 or more.\n"
|
|
56
56
|
expected(actual, desired)
|
|
57
57
|
end
|
|
@@ -65,16 +65,16 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
# Check output
|
|
68
|
-
desired = { aborted: true}
|
|
69
|
-
desired[:STDOUT] =
|
|
68
|
+
desired = { aborted: true }
|
|
69
|
+
desired[:STDOUT] =
|
|
70
70
|
"Dissociate group '#{group_name}' from host(s) '#{host_name}':\n"\
|
|
71
71
|
" - retrieve group '#{group_name}'...\n"
|
|
72
|
-
desired[:STDERR] =
|
|
72
|
+
desired[:STDERR] =
|
|
73
73
|
"ERROR: The group '#{group_name}' does not exist.\n"\
|
|
74
74
|
"An error occurred during a transaction, any changes have been rolled back.\n"
|
|
75
75
|
expected(actual, desired)
|
|
76
76
|
end
|
|
77
|
-
|
|
77
|
+
|
|
78
78
|
#------------------------
|
|
79
79
|
it 'GROUP HOST ... should dissociate the group from an existing group' do
|
|
80
80
|
host_name = 'test1'
|
|
@@ -82,22 +82,22 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
82
82
|
|
|
83
83
|
runner { @app.start(%W(host add #{host_name})) }
|
|
84
84
|
runner { @app.start(%W(group add #{group_name})) }
|
|
85
|
-
runner { @app.start(%W(group addhost #{group_name} #{host_name}
|
|
85
|
+
runner { @app.start(%W(group addhost #{group_name} #{host_name})) }
|
|
86
86
|
|
|
87
87
|
#
|
|
88
88
|
# Dissociate the host
|
|
89
89
|
# 1. expect that the group association is removed
|
|
90
90
|
# 2. expect that no association with ungrouped is made.
|
|
91
|
-
|
|
91
|
+
|
|
92
92
|
actual = runner do
|
|
93
|
-
@app.start(%W(group rmhost #{group_name} #{host_name}
|
|
93
|
+
@app.start(%W(group rmhost #{group_name} #{host_name}))
|
|
94
94
|
end
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
|
|
96
|
+
# @console.dump(actual, 'y')
|
|
97
|
+
|
|
98
98
|
# rubocop:disable Metrics/LineLength
|
|
99
|
-
desired = { aborted: false}
|
|
100
|
-
desired[:STDOUT] =
|
|
99
|
+
desired = { aborted: false }
|
|
100
|
+
desired[:STDOUT] =
|
|
101
101
|
"Dissociate group '#{group_name}' from host(s) '#{host_name}':\n"\
|
|
102
102
|
" - retrieve group '#{group_name}'...\n"\
|
|
103
103
|
" - OK\n"\
|
|
@@ -115,56 +115,55 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
115
115
|
hosts = group.hosts_dataset
|
|
116
116
|
expect(hosts.count).to eq(0)
|
|
117
117
|
end
|
|
118
|
-
|
|
118
|
+
|
|
119
119
|
#------------------------
|
|
120
120
|
it 'GROUP HOST ... should warn about non-existing associations' do
|
|
121
121
|
# 1. Should warn that the association doesn't exist.
|
|
122
|
-
# 2. Should complete with success. (desired state == actual state)
|
|
123
|
-
|
|
122
|
+
# 2. Should complete with success. (desired state == actual state)
|
|
123
|
+
|
|
124
124
|
host_name = 'test_host'
|
|
125
125
|
group_name = 'test_group'
|
|
126
126
|
runner { @app.start(%W(host add #{host_name})) }
|
|
127
127
|
runner { @app.start(%W(group add #{group_name})) }
|
|
128
128
|
runner { @app.start(%W(group addhost #{host_name})) }
|
|
129
|
-
|
|
129
|
+
|
|
130
130
|
actual = runner do
|
|
131
|
-
@app.start(%W(group rmhost #{group_name} #{host_name}))
|
|
131
|
+
@app.start(%W(group rmhost #{group_name} #{host_name}))
|
|
132
132
|
end
|
|
133
|
-
|
|
133
|
+
|
|
134
134
|
# rubocop:disable Metrics/LineLength
|
|
135
|
-
desired = { aborted: false}
|
|
136
|
-
desired[:STDOUT] =
|
|
135
|
+
desired = { aborted: false }
|
|
136
|
+
desired[:STDOUT] =
|
|
137
137
|
"Dissociate group '#{group_name}' from host(s) '#{host_name}':\n"\
|
|
138
138
|
" - retrieve group \'#{group_name}\'...\n"\
|
|
139
139
|
" - OK\n"\
|
|
140
|
-
" - remove association {group:#{group_name
|
|
140
|
+
" - remove association {group:#{group_name} <-> host:#{host_name}}...\n"\
|
|
141
141
|
" - doesn't exist, skipping.\n"\
|
|
142
142
|
" - OK\n"\
|
|
143
143
|
" - all OK\n"\
|
|
144
144
|
"Succeeded, with warnings.\n"
|
|
145
|
-
desired[:STDERR] =
|
|
145
|
+
desired[:STDERR] =
|
|
146
146
|
"WARNING: Association {group:#{group_name} <-> host:#{host_name}} "\
|
|
147
|
-
"doesn't exist, skipping.\n"
|
|
147
|
+
"doesn't exist, skipping.\n"
|
|
148
148
|
|
|
149
149
|
expected(actual, desired)
|
|
150
|
-
end
|
|
150
|
+
end
|
|
151
151
|
|
|
152
152
|
#------------------------
|
|
153
153
|
it '\'ungrouped\' HOST ... should abort with an error' do
|
|
154
|
-
|
|
155
154
|
host_name = 'test_host'
|
|
156
155
|
group_name = 'ungrouped'
|
|
157
156
|
|
|
158
157
|
runner { @app.start(%W(host add #{name})) } # <- auto creates the association with ungrouped
|
|
159
158
|
|
|
160
|
-
actual = runner { @app.start(%W(group rmhost #{group_name} #{host_name}
|
|
159
|
+
actual = runner { @app.start(%W(group rmhost #{group_name} #{host_name})) }
|
|
161
160
|
|
|
162
|
-
desired = { aborted: true}
|
|
161
|
+
desired = { aborted: true }
|
|
163
162
|
desired[:STDERR] =
|
|
164
163
|
"ERROR: Cannot manually manipulate the automatic group 'ungrouped'.\n"
|
|
165
164
|
expected(actual, desired)
|
|
166
165
|
end
|
|
167
|
-
|
|
166
|
+
|
|
168
167
|
#------------------------
|
|
169
168
|
it 'GROUP HOST1 HOST2 ... should dissociate the group from'\
|
|
170
169
|
' multiple hosts at once' do
|
|
@@ -173,33 +172,31 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
173
172
|
# if it has no other groups.
|
|
174
173
|
|
|
175
174
|
group_name = 'test_group'
|
|
176
|
-
host_names = %
|
|
175
|
+
host_names = %w(test_host1 test_host2 test_host3)
|
|
176
|
+
|
|
177
|
+
runner { @app.start(%W(group add #{group_name})) }
|
|
178
|
+
runner { @app.start(%W(group addhost #{group_name}) + host_names) }
|
|
177
179
|
|
|
178
|
-
runner { @app.start(%W(group add #{group_name} )) }
|
|
179
|
-
runner { @app.start(%W(group addhost #{group_name}) + host_names) }
|
|
180
|
-
|
|
181
180
|
actual = runner do
|
|
182
181
|
@app.start(%W(group rmhost #{group_name}) + host_names)
|
|
183
182
|
end
|
|
184
183
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
# rubocop:disable Metrics/LineLength
|
|
188
|
-
desired = { aborted: false}
|
|
184
|
+
# @console.out(actual, 'y')
|
|
185
|
+
desired = { aborted: false }
|
|
189
186
|
desired[:STDOUT] =
|
|
190
187
|
"Dissociate group '#{group_name}' from host(s) '#{host_names.join(',')}':\n"\
|
|
191
188
|
" - retrieve group \'#{group_name}\'...\n"\
|
|
192
189
|
" - OK\n"
|
|
193
190
|
host_names.each do |host|
|
|
194
191
|
desired[:STDOUT] = desired[:STDOUT] +
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
192
|
+
" - remove association {group:#{group_name} <-> host:#{host}}...\n"\
|
|
193
|
+
" - OK\n"\
|
|
194
|
+
" - add automatic association {group:ungrouped <-> host:#{host}}...\n"\
|
|
195
|
+
" - OK\n"\
|
|
199
196
|
end
|
|
200
197
|
desired[:STDOUT] = desired[:STDOUT] +
|
|
201
|
-
|
|
202
|
-
|
|
198
|
+
" - all OK\n"\
|
|
199
|
+
"Succeeded.\n"
|
|
203
200
|
expected(actual, desired)
|
|
204
201
|
# rubocop:enable Metrics/LineLength
|
|
205
202
|
|
|
@@ -210,6 +207,6 @@ RSpec.describe Moose::Inventory::Cli::Group do
|
|
|
210
207
|
host_names.each do |host|
|
|
211
208
|
expect(hosts[name: host]).to be_nil
|
|
212
209
|
end
|
|
213
|
-
end
|
|
210
|
+
end
|
|
214
211
|
end
|
|
215
212
|
end
|