puppet-repl 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +53 -0
- data/.gitlab-ci.yml +28 -32
- data/.rspec +2 -1
- data/CHANGELOG.md +3 -0
- data/Gemfile +3 -3
- data/Gemfile.lock +4 -46
- data/README.md +5 -3
- data/Rakefile +4 -24
- data/lib/puppet-repl/cli.rb +5 -7
- data/lib/puppet-repl/support/input_responders.rb +1 -0
- data/lib/puppet-repl/support.rb +42 -2
- data/lib/version.rb +1 -1
- data/puppet-repl.gemspec +18 -76
- data/run_container_test.sh +12 -0
- data/spec/fixtures/invalid_node_obj.yaml +2 -2
- data/spec/fixtures/node_obj.yaml +45 -62
- data/spec/prepl_spec.rb +9 -9
- data/spec/puppet-repl_spec.rb +122 -178
- data/spec/remote_node_spec.rb +170 -0
- data/spec/spec_helper.rb +24 -16
- data/test_matrix.rb +42 -0
- metadata +9 -13
- data/VERSION +0 -1
- data/resources/classes.png +0 -0
- data/resources/classification.png +0 -0
- data/resources/command_line_node.png +0 -0
- data/resources/functions.png +0 -0
- data/resources/hiera.png +0 -0
- data/resources/set_node.png +0 -0
- data/resources/tab_complete.png +0 -0
- data/resources/variables.png +0 -0
data/spec/fixtures/node_obj.yaml
CHANGED
@@ -1,25 +1,8 @@
|
|
1
1
|
--- !ruby/object:Puppet::Node
|
2
2
|
name: puppetdev.localdomain
|
3
|
-
classes:
|
4
|
-
|
5
|
-
|
6
|
-
- pe-puppet.localdomain
|
7
|
-
use_application_services: false
|
8
|
-
database_host: pe-puppet.localdomain
|
9
|
-
puppetdb_host: pe-puppet.localdomain
|
10
|
-
database_port: "5432"
|
11
|
-
database_ssl: true
|
12
|
-
puppet_master_host: pe-puppet.localdomain
|
13
|
-
certificate_authority_host: pe-puppet.localdomain
|
14
|
-
console_port: "443"
|
15
|
-
puppetdb_database_name: pe-puppetdb
|
16
|
-
puppetdb_database_user: pe-puppetdb
|
17
|
-
pcp_broker_host: pe-puppet.localdomain
|
18
|
-
puppetdb_port: "8081"
|
19
|
-
console_host: pe-puppet.localdomain
|
20
|
-
"puppet_enterprise::profile::agent": {}
|
21
|
-
"puppet_enterprise::profile::mcollective::agent": {}
|
22
|
-
parameters:
|
3
|
+
classes:
|
4
|
+
stdlib:
|
5
|
+
parameters:
|
23
6
|
kernel: Linux
|
24
7
|
ipaddress6_lo: "::1"
|
25
8
|
network6_lo: "::1"
|
@@ -47,16 +30,16 @@
|
|
47
30
|
boardmanufacturer: "Intel Corporation"
|
48
31
|
timezone: UTC
|
49
32
|
bios_vendor: "Phoenix Technologies LTD"
|
50
|
-
os:
|
33
|
+
os:
|
51
34
|
architecture: x86_64
|
52
35
|
family: RedHat
|
53
36
|
hardware: x86_64
|
54
37
|
name: CentOS
|
55
|
-
release:
|
38
|
+
release:
|
56
39
|
full: "7.2.1511"
|
57
40
|
major: "7"
|
58
41
|
minor: "2"
|
59
|
-
selinux:
|
42
|
+
selinux:
|
60
43
|
enabled: false
|
61
44
|
osfamily: RedHat
|
62
45
|
operatingsystem: CentOS
|
@@ -92,7 +75,7 @@
|
|
92
75
|
swapsize: "1.08 GiB"
|
93
76
|
uptime: "0:34 hours"
|
94
77
|
mtu_eth0: 1500
|
95
|
-
identity:
|
78
|
+
identity:
|
96
79
|
gid: 0
|
97
80
|
group: root
|
98
81
|
uid: 0
|
@@ -106,33 +89,33 @@
|
|
106
89
|
mtu_lo: 65536
|
107
90
|
macaddress: "02:42:ac:11:00:02"
|
108
91
|
macaddress_eth0: "02:42:ac:11:00:02"
|
109
|
-
augeas:
|
92
|
+
augeas:
|
110
93
|
version: "1.4.0"
|
111
94
|
netmask6_lo: "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"
|
112
|
-
ruby:
|
95
|
+
ruby:
|
113
96
|
platform: x86_64-linux
|
114
97
|
sitedir: /opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0
|
115
98
|
version: "2.1.8"
|
116
99
|
blockdevice_sda_model: "VMware Virtual S"
|
117
100
|
blockdevice_sda_vendor: "VMware,"
|
118
|
-
processors:
|
101
|
+
processors:
|
119
102
|
count: 1
|
120
103
|
isa: x86_64
|
121
|
-
models:
|
104
|
+
models:
|
122
105
|
- "Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz"
|
123
106
|
physicalcount: 1
|
124
107
|
blockdevices: "fd0,sda,sr0"
|
125
108
|
boardproductname: "440BX Desktop Reference Platform"
|
126
|
-
networking:
|
109
|
+
networking:
|
127
110
|
mac: "02:42:ac:11:00:02"
|
128
111
|
ip6: "fe80::42:acff:fe11:2"
|
129
112
|
hostname: puppetdev
|
130
113
|
netmask6: "ffff:ffff:ffff:ffff::"
|
131
|
-
interfaces:
|
132
|
-
eth0:
|
114
|
+
interfaces:
|
115
|
+
eth0:
|
133
116
|
mac: "02:42:ac:11:00:02"
|
134
117
|
ip6: "fe80::42:acff:fe11:2"
|
135
|
-
bindings:
|
118
|
+
bindings:
|
136
119
|
- address: "172.17.0.2"
|
137
120
|
netmask: "255.255.0.0"
|
138
121
|
network: "172.17.0.0"
|
@@ -141,14 +124,14 @@
|
|
141
124
|
network: "172.17.0.0"
|
142
125
|
mtu: 1500
|
143
126
|
ip: "172.17.0.2"
|
144
|
-
bindings6:
|
127
|
+
bindings6:
|
145
128
|
- address: "fe80::42:acff:fe11:2"
|
146
129
|
netmask: "ffff:ffff:ffff:ffff::"
|
147
130
|
network: "fe80::"
|
148
131
|
network6: "fe80::"
|
149
|
-
lo:
|
132
|
+
lo:
|
150
133
|
ip6: "::1"
|
151
|
-
bindings:
|
134
|
+
bindings:
|
152
135
|
- address: "127.0.0.1"
|
153
136
|
netmask: "255.0.0.0"
|
154
137
|
network: "127.0.0.0"
|
@@ -157,7 +140,7 @@
|
|
157
140
|
network: "127.0.0.0"
|
158
141
|
mtu: 65536
|
159
142
|
ip: "127.0.0.1"
|
160
|
-
bindings6:
|
143
|
+
bindings6:
|
161
144
|
- address: "::1"
|
162
145
|
netmask: "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"
|
163
146
|
network: "::1"
|
@@ -171,15 +154,15 @@
|
|
171
154
|
domain: localdomain
|
172
155
|
network6: "fe80::"
|
173
156
|
memoryfree: "788.06 MiB"
|
174
|
-
system_uptime:
|
157
|
+
system_uptime:
|
175
158
|
days: 0
|
176
159
|
hours: 0
|
177
160
|
seconds: 2069
|
178
161
|
uptime: "0:34 hours"
|
179
162
|
uptime_seconds: 2069
|
180
163
|
memoryfree_mb: 788.0625
|
181
|
-
memory:
|
182
|
-
swap:
|
164
|
+
memory:
|
165
|
+
swap:
|
183
166
|
available: "1.08 GiB"
|
184
167
|
available_bytes: 1162366976
|
185
168
|
capacity: "0%"
|
@@ -187,7 +170,7 @@
|
|
187
170
|
total_bytes: 1162366976
|
188
171
|
used: "0 bytes"
|
189
172
|
used_bytes: 0
|
190
|
-
system:
|
173
|
+
system:
|
191
174
|
available: "788.06 MiB"
|
192
175
|
available_bytes: 826343424
|
193
176
|
capacity: "20.89%"
|
@@ -204,7 +187,7 @@
|
|
204
187
|
blockdevice_sr0_model: "VMware SATA CD01"
|
205
188
|
netmask: "255.255.0.0"
|
206
189
|
netmask_eth0: "255.255.0.0"
|
207
|
-
trusted:
|
190
|
+
trusted:
|
208
191
|
authenticated: remote
|
209
192
|
certname: puppetdev.localdomain
|
210
193
|
domain: localdomain
|
@@ -221,95 +204,95 @@
|
|
221
204
|
blockdevice_sda_size: 20971520000
|
222
205
|
kernelmajversion: "4.1"
|
223
206
|
filesystems: "cramfs,ext2,ext3,ext4,iso9660,squashfs,vfat"
|
224
|
-
mountpoints:
|
225
|
-
/etc/hostname:
|
207
|
+
mountpoints:
|
208
|
+
/etc/hostname:
|
226
209
|
filesystem: ext4
|
227
210
|
device: /dev/sda1
|
228
211
|
used_bytes: 5667684352
|
229
212
|
available_bytes: 13854396416
|
230
213
|
used: "5.28 GiB"
|
231
214
|
size: "18.18 GiB"
|
232
|
-
options:
|
215
|
+
options:
|
233
216
|
- rw
|
234
217
|
- relatime
|
235
218
|
- "data=ordered"
|
236
219
|
size_bytes: 19522080768
|
237
220
|
available: "12.90 GiB"
|
238
221
|
capacity: "29.03%"
|
239
|
-
/etc/hosts:
|
222
|
+
/etc/hosts:
|
240
223
|
filesystem: ext4
|
241
224
|
device: /dev/sda1
|
242
225
|
used_bytes: 5667684352
|
243
226
|
available_bytes: 13854396416
|
244
227
|
used: "5.28 GiB"
|
245
228
|
size: "18.18 GiB"
|
246
|
-
options:
|
229
|
+
options:
|
247
230
|
- rw
|
248
231
|
- relatime
|
249
232
|
- "data=ordered"
|
250
233
|
size_bytes: 19522080768
|
251
234
|
available: "12.90 GiB"
|
252
235
|
capacity: "29.03%"
|
253
|
-
/etc/resolv.conf:
|
236
|
+
/etc/resolv.conf:
|
254
237
|
filesystem: ext4
|
255
238
|
device: /dev/sda1
|
256
239
|
used_bytes: 5667684352
|
257
240
|
available_bytes: 13854396416
|
258
241
|
used: "5.28 GiB"
|
259
242
|
size: "18.18 GiB"
|
260
|
-
options:
|
243
|
+
options:
|
261
244
|
- rw
|
262
245
|
- relatime
|
263
246
|
- "data=ordered"
|
264
247
|
size_bytes: 19522080768
|
265
248
|
available: "12.90 GiB"
|
266
249
|
capacity: "29.03%"
|
267
|
-
partitions:
|
268
|
-
/dev/sda1:
|
250
|
+
partitions:
|
251
|
+
/dev/sda1:
|
269
252
|
mount: /etc/resolv.conf
|
270
253
|
size: "18.60 GiB"
|
271
254
|
size_bytes: 19970129920
|
272
|
-
/dev/sda2:
|
255
|
+
/dev/sda2:
|
273
256
|
size: "954.98 MiB"
|
274
257
|
size_bytes: 1001373696
|
275
|
-
load_averages:
|
258
|
+
load_averages:
|
276
259
|
"15m": 0.06
|
277
260
|
"1m": 0.06
|
278
261
|
"5m": 0.05
|
279
|
-
disks:
|
280
|
-
fd0:
|
262
|
+
disks:
|
263
|
+
fd0:
|
281
264
|
size: "0 bytes"
|
282
265
|
size_bytes: 0
|
283
|
-
sda:
|
266
|
+
sda:
|
284
267
|
model: "VMware Virtual S"
|
285
268
|
size: "19.53 GiB"
|
286
269
|
size_bytes: 20971520000
|
287
270
|
vendor: "VMware,"
|
288
|
-
sr0:
|
271
|
+
sr0:
|
289
272
|
model: "VMware SATA CD01"
|
290
273
|
size: "30.00 MiB"
|
291
274
|
size_bytes: 31457280
|
292
275
|
vendor: NECVMWar
|
293
|
-
dmi:
|
294
|
-
bios:
|
276
|
+
dmi:
|
277
|
+
bios:
|
295
278
|
release_date: "05/20/2014"
|
296
279
|
vendor: "Phoenix Technologies LTD"
|
297
280
|
version: "6.00"
|
298
|
-
board:
|
281
|
+
board:
|
299
282
|
manufacturer: "Intel Corporation"
|
300
283
|
product: "440BX Desktop Reference Platform"
|
301
284
|
serial_number: None
|
302
|
-
chassis:
|
285
|
+
chassis:
|
303
286
|
asset_tag: "No Asset Tag"
|
304
287
|
type: Other
|
305
288
|
manufacturer: "VMware, Inc."
|
306
|
-
product:
|
289
|
+
product:
|
307
290
|
name: "VMware Virtual Platform"
|
308
291
|
serial_number: "VMware-56 4d 25 bb 6b 40 eb bf-38 b3 07 cc d4 45 59 18"
|
309
292
|
uuid: "564D25BB-6B40-EBBF-38B3-07CCD4455918"
|
310
293
|
serialnumber: "VMware-56 4d 25 bb 6b 40 eb bf-38 b3 07 cc d4 45 59 18"
|
311
294
|
environment: production
|
312
|
-
facts:
|
295
|
+
facts:
|
313
296
|
time: 2016-05-10 13:14:57.080352 -07:00
|
314
297
|
environment_name: production
|
315
298
|
expiration: 2016-05-10 13:44:57.080364 -07:00
|
data/spec/prepl_spec.rb
CHANGED
@@ -26,11 +26,11 @@ describe 'prepl' do
|
|
26
26
|
expect(`bundle exec bin/prepl --play #{fixtures_file} --run-once`)
|
27
27
|
.to match(/Puppet::Type::File/)
|
28
28
|
end
|
29
|
-
xit do
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
29
|
+
# xit do
|
30
|
+
# # this test does not work without internet, and I am at 30K feet right now
|
31
|
+
# expect(`bundle exec bin/prepl --play #{file_url} --run-once`)
|
32
|
+
# .to match(/Puppet::Type::File/)
|
33
|
+
# end
|
34
34
|
|
35
35
|
describe 'remote_node' do
|
36
36
|
let(:node_obj) do
|
@@ -42,9 +42,9 @@ describe 'prepl' do
|
|
42
42
|
before :each do
|
43
43
|
allow(PuppetRepl).to receive(:get_remote_node).with(node_name).and_return(node_obj)
|
44
44
|
end
|
45
|
-
xit do
|
46
|
-
|
47
|
-
|
48
|
-
end
|
45
|
+
# xit do
|
46
|
+
# expect(`echo 'vars'| bundle exec bin/prepl -n #{node_name}`)
|
47
|
+
# .to match(/server_facts/)
|
48
|
+
# end
|
49
49
|
end
|
50
50
|
end
|
data/spec/puppet-repl_spec.rb
CHANGED
@@ -26,6 +26,90 @@ describe "PuppetRepl" do
|
|
26
26
|
repl.parser.evaluate_string(repl.scope, input)
|
27
27
|
end
|
28
28
|
|
29
|
+
describe 'native classes' do
|
30
|
+
describe 'create' do
|
31
|
+
let(:input) do
|
32
|
+
'class testfoo {}'
|
33
|
+
end
|
34
|
+
let(:repl_output) do
|
35
|
+
"\n => Puppet::Type::Component {\n loglevel\e[0;37m => \e[0m\e[0;36mnotice\e[0m,\n name\e[0;37m => \e[0m\e[0;33m\"Testfoo\"\e[0m,\n title\e[0;37m => \e[0m\e[0;33m\"Class[Testfoo]\"\e[0m\n}\n"
|
36
|
+
end
|
37
|
+
it do
|
38
|
+
repl.handle_input(input)
|
39
|
+
expect(output.string).to eq("\n")
|
40
|
+
expect(repl.scope.known_resource_types.hostclasses).to include('testfoo')
|
41
|
+
end
|
42
|
+
it do
|
43
|
+
repl.handle_input(input)
|
44
|
+
repl.handle_input("class{'testfoo':}")
|
45
|
+
expect(repl.scope.compiler.catalog.classes).to include('testfoo')
|
46
|
+
# expect(output.string).to include("\n => Puppet::Type::Component")
|
47
|
+
# expect(output.string).to include("name => \"Testfoo\"")
|
48
|
+
end
|
49
|
+
it do
|
50
|
+
repl.handle_input(input)
|
51
|
+
repl.handle_input("include testfoo")
|
52
|
+
expect(repl.scope.compiler.catalog.classes).to include('testfoo')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'native definitions' do
|
58
|
+
describe 'create' do
|
59
|
+
let(:input) do
|
60
|
+
'define testfoo {}'
|
61
|
+
end
|
62
|
+
let(:repl_output) do
|
63
|
+
"\n => Puppet::Type::Component {\n loglevel\e[0;37m => \e[0m\e[0;36mnotice\e[0m,\n name\e[0;37m => \e[0m\e[0;33m\"some_name\"\e[0m,\n title\e[0;37m => \e[0m\e[0;33m\"Testfoo[some_name]\"\e[0m\n}\n"
|
64
|
+
end
|
65
|
+
it do
|
66
|
+
repl.handle_input(input)
|
67
|
+
expect(repl.scope.known_resource_types.definitions.keys).to include('testfoo')
|
68
|
+
expect(output.string).to eq("\n")
|
69
|
+
end
|
70
|
+
it do
|
71
|
+
repl.handle_input(input)
|
72
|
+
repl.handle_input("testfoo{'some_name':}")
|
73
|
+
expect(repl.scope.compiler.resources.collect(&:name)).to include('some_name')
|
74
|
+
expect(repl.scope.compiler.resources.collect(&:type)).to include('Testfoo')
|
75
|
+
expect(output.string).to include("\n => Puppet::Type::Component")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe 'native functions', :native_functions => true do
|
81
|
+
let(:func) do
|
82
|
+
<<-EOF
|
83
|
+
function repl::bool2http($arg) {
|
84
|
+
case $arg {
|
85
|
+
false, undef, /(?i:false)/ : { 'Off' }
|
86
|
+
true, /(?i:true)/ : { 'On' }
|
87
|
+
default : { "$arg" }
|
88
|
+
}
|
89
|
+
}
|
90
|
+
EOF
|
91
|
+
end
|
92
|
+
before(:each) do
|
93
|
+
repl.handle_input(func)
|
94
|
+
end
|
95
|
+
describe 'create' do
|
96
|
+
it 'shows function' do
|
97
|
+
expect(output.string).to eq("\n")
|
98
|
+
end
|
99
|
+
end
|
100
|
+
describe 'run' do
|
101
|
+
let(:input) do
|
102
|
+
<<-EOF
|
103
|
+
repl::bool2http(false)
|
104
|
+
EOF
|
105
|
+
end
|
106
|
+
it do
|
107
|
+
repl.handle_input(input)
|
108
|
+
expect(output.string).to include('Off')
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
29
113
|
describe 'types' do
|
30
114
|
|
31
115
|
describe 'string' do
|
@@ -67,7 +151,10 @@ describe "PuppetRepl" do
|
|
67
151
|
end
|
68
152
|
it do
|
69
153
|
repl.play_back_string(input)
|
70
|
-
expect(output.string).to
|
154
|
+
expect(output.string).to include("$var1 = 'test'")
|
155
|
+
expect(output.string).to include("\"test\"")
|
156
|
+
expect(output.string).to include("$var2 = 'test2'")
|
157
|
+
expect(output.string).to include("\"test2\"")
|
71
158
|
end
|
72
159
|
end
|
73
160
|
describe '1 lines' do
|
@@ -76,10 +163,10 @@ describe "PuppetRepl" do
|
|
76
163
|
end
|
77
164
|
it do
|
78
165
|
repl.play_back_string(input)
|
79
|
-
expect(output.string).to
|
166
|
+
expect(output.string).to include("$var1 = 'test'")
|
167
|
+
expect(output.string).to include("\"test\"")
|
80
168
|
end
|
81
169
|
end
|
82
|
-
|
83
170
|
end
|
84
171
|
|
85
172
|
describe 'returns a array of resource_types' do
|
@@ -162,9 +249,8 @@ describe "PuppetRepl" do
|
|
162
249
|
"$file_path = '/tmp/test2.txt'"
|
163
250
|
end
|
164
251
|
it 'can process a variable' do
|
165
|
-
repl_output = "\n => \e[0;33m\"/tmp/test2.txt\"\e[0m\n"
|
166
252
|
repl.handle_input(input)
|
167
|
-
expect(output.string).to
|
253
|
+
expect(output.string).to match(/\/tmp\/test2.txt/)
|
168
254
|
end
|
169
255
|
end
|
170
256
|
|
@@ -242,12 +328,10 @@ describe "PuppetRepl" do
|
|
242
328
|
let(:input) do
|
243
329
|
"['/tmp/test3', '/tmp/test4'].each |String $path| { file{$path: ensure => present} }"
|
244
330
|
end
|
245
|
-
let(:repl_output) do
|
246
|
-
"\n => [\n \e[1;37m[0] \e[0m\e[0;33m\"/tmp/test3\"\e[0m,\n \e[1;37m[1] \e[0m\e[0;33m\"/tmp/test4\"\e[0m\n]\n"
|
247
|
-
end
|
248
331
|
it 'can process a each block' do
|
249
332
|
repl.handle_input(input)
|
250
|
-
expect(output.string).to
|
333
|
+
expect(output.string).to match(/\/tmp\/test3/)
|
334
|
+
expect(output.string).to match(/\/tmp\/test4/)
|
251
335
|
end
|
252
336
|
end
|
253
337
|
|
@@ -256,9 +340,9 @@ describe "PuppetRepl" do
|
|
256
340
|
"$::fqdn"
|
257
341
|
end
|
258
342
|
it 'should be able to resolve fqdn' do
|
259
|
-
repl_output =
|
343
|
+
repl_output = /foo\.example\.com/
|
260
344
|
repl.handle_input(input)
|
261
|
-
expect(output.string).to
|
345
|
+
expect(output.string).to match(repl_output)
|
262
346
|
end
|
263
347
|
end
|
264
348
|
|
@@ -355,9 +439,9 @@ describe "PuppetRepl" do
|
|
355
439
|
"md5('hello')"
|
356
440
|
end
|
357
441
|
it 'execute md5' do
|
358
|
-
repl_output =
|
442
|
+
repl_output = /5d41402abc4b2a76b9719d911017c592/
|
359
443
|
repl.handle_input(input)
|
360
|
-
expect(output.string).to
|
444
|
+
expect(output.string).to match(repl_output)
|
361
445
|
end
|
362
446
|
it 'execute swapcase' do
|
363
447
|
repl_output = /HELLO/
|
@@ -366,170 +450,30 @@ describe "PuppetRepl" do
|
|
366
450
|
end
|
367
451
|
end
|
368
452
|
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
end
|
393
|
-
|
394
|
-
describe 'remote node' do
|
395
|
-
let(:node_obj) do
|
396
|
-
YAML.load_file(File.join(fixtures_dir, 'node_obj.yaml'))
|
397
|
-
end
|
398
|
-
let(:node_name) do
|
399
|
-
'puppetdev.localdomain'
|
400
|
-
end
|
401
|
-
before :each do
|
402
|
-
allow(repl).to receive(:get_remote_node).with(node_name).and_return(node_obj)
|
403
|
-
repl.handle_input(":set node #{node_name}")
|
404
|
-
end
|
405
|
-
|
406
|
-
describe 'set' do
|
407
|
-
it 'sends message about resetting' do
|
408
|
-
expect(output.string).to eq("\n => Resetting to use node puppetdev.localdomain\n")
|
409
|
-
end
|
410
|
-
|
411
|
-
it "return node name" do
|
412
|
-
output.reopen # removes previous message
|
413
|
-
repl.handle_input('$::hostname')
|
414
|
-
expect(output.string).to match(/puppetdev.localdomain/)
|
415
|
-
end
|
416
|
-
|
417
|
-
it "return classification" do
|
418
|
-
output.reopen # removes previous message
|
419
|
-
repl.handle_input('classification')
|
420
|
-
expect(output.string).to match(/certificate_authority_host/)
|
421
|
-
end
|
422
|
-
end
|
423
|
-
|
424
|
-
describe 'facts' do
|
425
|
-
let(:input) do
|
426
|
-
"$::facts['os']['family'].downcase == 'debian'"
|
427
|
-
end
|
428
|
-
it 'fact evaulation should return false' do
|
429
|
-
repl_output = /false/
|
430
|
-
repl.handle_input(input)
|
431
|
-
expect(output.string).to match(repl_output)
|
432
|
-
end
|
433
|
-
|
434
|
-
end
|
435
|
-
describe 'use defaults when invalid' do
|
436
|
-
let(:node_obj) do
|
437
|
-
YAML.load_file(File.join(fixtures_dir, 'invalid_node_obj.yaml'))
|
438
|
-
end
|
439
|
-
let(:node_name) do
|
440
|
-
'invalid.localdomain'
|
441
|
-
end
|
442
|
-
it 'name' do
|
443
|
-
expect{repl.node.name}.to raise_error(PuppetRepl::Exception::UndefinedNode)
|
444
|
-
end
|
445
|
-
end
|
446
|
-
|
447
|
-
it 'set node name' do
|
448
|
-
expect(repl.remote_node_name = 'puppetdev.localdomain').to eq("puppetdev.localdomain")
|
449
|
-
end
|
450
|
-
|
451
|
-
describe 'print classes' do
|
452
|
-
let(:input) do
|
453
|
-
'resources'
|
454
|
-
end
|
455
|
-
it 'should be able to print classes' do
|
456
|
-
repl_output = /Settings/
|
457
|
-
repl.handle_input(input)
|
458
|
-
expect(output.string).to match(repl_output)
|
459
|
-
end
|
460
|
-
end
|
453
|
+
# this code no longer works in puppet 4.5+
|
454
|
+
# describe 'unidentified object' do
|
455
|
+
# let(:repl_output) { "\n" }
|
456
|
+
# describe "Node['foot']" do
|
457
|
+
# let(:input) { subject }
|
458
|
+
# it 'returns string' do
|
459
|
+
# repl.handle_input(input)
|
460
|
+
# expect(output.string).to eq(repl_output)
|
461
|
+
# end
|
462
|
+
# end
|
463
|
+
# describe "Puppet::Pops::Types::PStringType" do
|
464
|
+
# let(:input) { subject }
|
465
|
+
# it 'returns string' do
|
466
|
+
# repl.handle_input(input)
|
467
|
+
# expect(output.string).to eq(repl_output)
|
468
|
+
# end
|
469
|
+
# end
|
470
|
+
# describe 'Facts' do
|
471
|
+
# let(:input) { subject }
|
472
|
+
# it 'returns string' do
|
473
|
+
# repl.handle_input(input)
|
474
|
+
# expect(output.string).to eq(repl_output)
|
475
|
+
# end
|
476
|
+
# end
|
477
|
+
# end
|
461
478
|
|
462
|
-
describe 'vars' do
|
463
|
-
let(:input) do
|
464
|
-
"vars"
|
465
|
-
end
|
466
|
-
it 'display facts variable' do
|
467
|
-
repl_output = /facts/
|
468
|
-
repl.handle_input(input)
|
469
|
-
expect(output.string).to match(repl_output)
|
470
|
-
end
|
471
|
-
it 'display server facts variable' do
|
472
|
-
repl_output = /server_facts/
|
473
|
-
repl.handle_input(input)
|
474
|
-
expect(output.string).to match(repl_output) if Puppet.version.to_f >= 4.1
|
475
|
-
end
|
476
|
-
it 'display server facts variable' do
|
477
|
-
repl_output = /server_facts/
|
478
|
-
repl.handle_input(input)
|
479
|
-
expect(output.string).to match(repl_output) if Puppet.version.to_f >= 4.1
|
480
|
-
end
|
481
|
-
it 'display local variable' do
|
482
|
-
repl.handle_input("$var1 = 'value1'")
|
483
|
-
expect(output.string).to match(/value1/)
|
484
|
-
repl.handle_input("$var1")
|
485
|
-
expect(output.string).to match(/value1/)
|
486
|
-
end
|
487
|
-
it 'display productname variable' do
|
488
|
-
repl.handle_input("$productname")
|
489
|
-
expect(output.string).to match(/VMware Virtual Platform/)
|
490
|
-
end
|
491
|
-
end
|
492
|
-
|
493
|
-
describe 'execute functions' do
|
494
|
-
let(:input) do
|
495
|
-
"md5('hello')"
|
496
|
-
end
|
497
|
-
it 'execute md5' do
|
498
|
-
repl_output = /5d41402abc4b2a76b9719d911017c592/
|
499
|
-
repl.handle_input(input)
|
500
|
-
expect(output.string).to match(repl_output)
|
501
|
-
end
|
502
|
-
it 'execute swapcase' do
|
503
|
-
repl_output = /HELLO/
|
504
|
-
repl.handle_input("swapcase('hello')")
|
505
|
-
expect(output.string).to match(repl_output)
|
506
|
-
end
|
507
|
-
end
|
508
|
-
|
509
|
-
describe 'reset' do
|
510
|
-
let(:input) do
|
511
|
-
"file{'/tmp/reset': ensure => present}"
|
512
|
-
end
|
513
|
-
|
514
|
-
it 'can process a file' do
|
515
|
-
repl_output = /Puppet::Type::File/
|
516
|
-
repl.handle_input(input)
|
517
|
-
expect(output.string).to match(repl_output)
|
518
|
-
repl.handle_input('reset')
|
519
|
-
repl.handle_input(input)
|
520
|
-
expect(output.string).to match(repl_output)
|
521
|
-
end
|
522
|
-
end
|
523
|
-
|
524
|
-
describe 'classification' do
|
525
|
-
let(:input) do
|
526
|
-
"classification"
|
527
|
-
end
|
528
|
-
|
529
|
-
it 'shows certificate_authority_host' do
|
530
|
-
repl.handle_input(input)
|
531
|
-
expect(output.string).to match(/certificate_authority_host/)
|
532
|
-
end
|
533
|
-
end
|
534
|
-
end
|
535
479
|
end
|