-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjunos_command_module_test
More file actions
354 lines (295 loc) · 25.5 KB
/
junos_command_module_test
File metadata and controls
354 lines (295 loc) · 25.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
root@masterhost:~/ansible_modules_redirection_test5/ansible-junos-stdlib/ansible_collections# ansible-playbook -i inventory_junos pb.juniper_junos_command.yml
[WARNING]: errors were encountered during the plugin load for junipernetworks.junos.junos_command: ["'NoneType' object has no attribute 'get'"]
ERROR! couldn't resolve module/action 'junipernetworks.junos.junos_command'. This often indicates a misspelling, missing collection, or incorrect module path.
The error appears to be in '/root/ansible_modules_redirection_test5/ansible-junos-stdlib/ansible_collections/pb.juniper_junos_command.yml': line 11, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
tasks:
- name: Run show version
^ here
root@masterhost:~/ansible_modules_redirection_test5/ansible-junos-stdlib/ansible_collections# cat juniper/device/meta/runtime.yml
requires_ansible: ">=2.17.0"
plugin_routing:
plugins:
modules:
hostname:
redirect: juniper.device.junos_hostname
interfaces:
redirect: juniper.device.junos_interfaces
acls:
redirect: juniper.device.junos_acls
acl_interfaces:
redirect: juniper.device.junos_acl_interfaces
banner:
redirect: juniper.device.junos_banner
bgp_address_family:
redirect: juniper.device.junos_bgp_address_family
bgp_global:
redirect: juniper.device.junos_bgp_global
ln -fs junos.py junos_command.py
root@masterhost:~/ansible_modules_redirection_test5/ansible-junos-stdlib/ansible_collections/juniper/device/plugins/action# ln -fs junos.py junos_command.py
root@masterhost:~/ansible_modules_redirection_test5/ansible-junos-stdlib/ansible_collections/juniper/device/plugins/action# ls -lrt | grep command
lrwxrwxrwx 1 root root 30 Apr 28 21:12 command.py -> juniper_junos_common_action.py
lrwxrwxrwx 1 root root 8 May 6 22:32 junos_command.py -> junos.py
root@masterhost:~/ansible_modules_redirection_test5/ansible-junos-stdlib/ansible_collections# ansible-playbook -i inventory_junos pb.juniper_junos_command.yml
[WARNING]: errors were encountered during the plugin load for junipernetworks.junos.junos_command: ["'NoneType' object has no attribute 'get'"]
ERROR! couldn't resolve module/action 'junipernetworks.junos.junos_command'. This often indicates a misspelling, missing collection, or incorrect module path.
The error appears to be in '/root/ansible_modules_redirection_test5/ansible-junos-stdlib/ansible_collections/pb.juniper_junos_command.yml': line 11, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
tasks:
- name: Run show version
^ here
root@masterhost:~/ansible_modules_redirection_test5/ansible-junos-stdlib/ansible_collections# cat juniper/device/meta/runtime.yml
requires_ansible: ">=2.17.0"
plugin_routing:
plugins:
modules:
hostname:
redirect: juniper.device.junos_hostname
interfaces:
redirect: juniper.device.junos_interfaces
acls:
redirect: juniper.device.junos_acls
acl_interfaces:
redirect: juniper.device.junos_acl_interfaces
banner:
redirect: juniper.device.junos_banner
bgp_address_family:
redirect: juniper.device.junos_bgp_address_family
bgp_global:
redirect: juniper.device.junos_bgp_global
root@masterhost:~/ansible_modules_redirection_test5/ansible-junos-stdlib/ansible_collections# vi junipernetworks/junos/meta/runtime.yml
---
requires_ansible: ">=2.15.0"
plugin_routing:
action:
# junos_facts:
# redirect: juniper.device.junos_facts
# junos_hostname:
# redirect: juniper.device.hostname
# junos_acls:
# redirect: juniper.device.acls
# junos_interfaces:
# redirect: juniper.device.interfaces
# netconf:
# redirect: juniper.device.junos
modules:
acl_interfaces:
redirect: juniper.device.junos_acl_interfaces
junos_banner: #debug
redirect: juniper.device.junos_banner
junos_command: #debug
redirect: juniper.device.junos_command
root@masterhost:~/ansible_modules_redirection_test5/ansible-junos-stdlib/ansible_collections/juniper/device/plugins/action# ln -fs junos.py junos_command.py
root@masterhost:~/ansible_modules_redirection_test5/ansible-junos-stdlib/ansible_collections/juniper/device/plugins/action# ls -lrt | grep command
lrwxrwxrwx 1 root root 30 Apr 28 21:12 command.py -> juniper_junos_common_action.py
lrwxrwxrwx 1 root root 8 May 6 22:32 junos_command.py -> junos.py
root@masterhost:~/ansible_modules_redirection_test5/ansible-junos-stdlib/ansible_collections# ansible-playbook -i inventory_junos pb.juniper_junos_command.yml
[WARNING]: errors were encountered during the plugin load for junipernetworks.junos.junos_command: ["'NoneType' object has no attribute 'get'"]
[WARNING]: errors were encountered during the plugin load for assert: ["'NoneType' object has no attribute 'get'"]
PLAY [Functional Test - junos_command module] **************************************************************************************************
TASK [Run show version] ************************************************************************************************************************
[WARNING]: errors were encountered during the plugin load for junipernetworks.junos.junos: ["'NoneType' object has no attribute 'get'"]
ok: [10.220.10.59]
TASK [Assert show version output is returned] **************************************************************************************************
ok: [10.220.10.59] => {
"changed": false,
"msg": "All assertions passed"
}
TASK [Run show version with wait_for condition (positive match)] *******************************************************************************
ok: [10.220.10.59]
TASK [Assert wait_for with positive match passed] **********************************************************************************************
ok: [10.220.10.59] => {
"changed": false,
"msg": "All assertions passed"
}
TASK [Run multiple commands] *******************************************************************************************************************
ok: [10.220.10.59]
TASK [Assert multiple commands worked] *********************************************************************************************************
ok: [10.220.10.59] => {
"changed": false,
"msg": "All assertions passed"
}
TASK [Run show version with json output] *******************************************************************************************************
ok: [10.220.10.59]
TASK [Assert json output is returned] **********************************************************************************************************
ok: [10.220.10.59] => {
"changed": false,
"msg": "All assertions passed"
}
TASK [Run RPC get-software-information] ********************************************************************************************************
ok: [10.220.10.59]
TASK [Assert RPC output] ***********************************************************************************************************************
ok: [10.220.10.59] => {
"changed": false,
"msg": "All assertions passed"
}
PLAY RECAP *************************************************************************************************************************************
10.220.10.59 : ok=10 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
===========================================================================
juniper.device.command module test:
===========================================================================
root@masterhost:~/ansible_modules_redirection_test5/ansible-junos-stdlib/ansible_collections# ansible-playbook -i inventory_device pb.juniper_junos_command_device.yml
PLAY [Test juniper.device.command module] ******************************************************************************************************
TASK [TEST 1 - Execute single "show version" command.] *****************************************************************************************
ok: [10.53.115.24]
TASK [Check TEST 1] ****************************************************************************************************************************
ok: [10.53.115.24] => {
"changed": false,
"msg": "All assertions passed"
}
TASK [Creates directory] ***********************************************************************************************************************
ok: [10.53.115.24]
TASK [TEST 2 - Execute three commands.] ********************************************************************************************************
ok: [10.53.115.24]
TASK [Check TEST 2] ****************************************************************************************************************************
ok: [10.53.115.24] => {
"changed": false,
"msg": "All assertions passed"
}
TASK [Print the command output of each.] *******************************************************************************************************
ok: [10.53.115.24] => (item={'msg': 'The command executed successfully.', 'command': 'show version', 'format': 'text', 'changed': False, 'failed': False, 'stdout': '\nHostname: evoeventtesty-RE0-re0\nModel: ptx10008\nJunos: 22.3R3.8-EVO\nYocto: 3.0.2\nLinux Kernel: 5.2.60-yocto-standard-g278f9ad\nJUNOS-EVO OS 64-bit [junos-evo-install-ptx-x86-64-22.3R3.8-EVO]\n', 'stdout_lines': ['', 'Hostname: evoeventtesty-RE0-re0', 'Model: ptx10008', 'Junos: 22.3R3.8-EVO', 'Yocto: 3.0.2', 'Linux Kernel: 5.2.60-yocto-standard-g278f9ad', 'JUNOS-EVO OS 64-bit [junos-evo-install-ptx-x86-64-22.3R3.8-EVO]']}) => {
"ansible_loop_var": "item",
"item": {
"changed": false,
"command": "show version",
"failed": false,
"format": "text",
"msg": "The command executed successfully.",
"stdout": "\nHostname: evoeventtesty-RE0-re0\nModel: ptx10008\nJunos: 22.3R3.8-EVO\nYocto: 3.0.2\nLinux Kernel: 5.2.60-yocto-standard-g278f9ad\nJUNOS-EVO OS 64-bit [junos-evo-install-ptx-x86-64-22.3R3.8-EVO]\n",
"stdout_lines": [
"",
"Hostname: evoeventtesty-RE0-re0",
"Model: ptx10008",
"Junos: 22.3R3.8-EVO",
"Yocto: 3.0.2",
"Linux Kernel: 5.2.60-yocto-standard-g278f9ad",
"JUNOS-EVO OS 64-bit [junos-evo-install-ptx-x86-64-22.3R3.8-EVO]"
]
},
"item.stdout": "\nHostname: evoeventtesty-RE0-re0\nModel: ptx10008\nJunos: 22.3R3.8-EVO\nYocto: 3.0.2\nLinux Kernel: 5.2.60-yocto-standard-g278f9ad\nJUNOS-EVO OS 64-bit [junos-evo-install-ptx-x86-64-22.3R3.8-EVO]\n"
}
ok: [10.53.115.24] => (item={'msg': 'The command executed successfully.', 'command': 'show system uptime', 'format': 'text', 'changed': False, 'failed': False, 'stdout': '\nCurrent time: 2025-05-06 22:53:27 PDT\nTime Source: NTP CLOCK \nNode booted: 2025-04-29 23:10:37 PDT (6d 23:42 ago)\nSystem booted: 2025-04-29 23:11:27 PDT (6d 23:42 ago)\nProtocols started: 2025-04-29 23:11:58 PDT (6d 23:41 ago)\nLast configured: 2025-05-06 22:07:04 PDT (00:46:23 ago) by root\n10:53PM up 6 days, 23:42, 1 user, load averages: 0.16, 0.12, 0.23\n', 'stdout_lines': ['', 'Current time: 2025-05-06 22:53:27 PDT', 'Time Source: NTP CLOCK ', 'Node booted: 2025-04-29 23:10:37 PDT (6d 23:42 ago)', 'System booted: 2025-04-29 23:11:27 PDT (6d 23:42 ago)', 'Protocols started: 2025-04-29 23:11:58 PDT (6d 23:41 ago)', 'Last configured: 2025-05-06 22:07:04 PDT (00:46:23 ago) by root', '10:53PM up 6 days, 23:42, 1 user, load averages: 0.16, 0.12, 0.23']}) => {
"ansible_loop_var": "item",
"item": {
"changed": false,
"command": "show system uptime",
"failed": false,
"format": "text",
"msg": "The command executed successfully.",
"stdout": "\nCurrent time: 2025-05-06 22:53:27 PDT\nTime Source: NTP CLOCK \nNode booted: 2025-04-29 23:10:37 PDT (6d 23:42 ago)\nSystem booted: 2025-04-29 23:11:27 PDT (6d 23:42 ago)\nProtocols started: 2025-04-29 23:11:58 PDT (6d 23:41 ago)\nLast configured: 2025-05-06 22:07:04 PDT (00:46:23 ago) by root\n10:53PM up 6 days, 23:42, 1 user, load averages: 0.16, 0.12, 0.23\n",
"stdout_lines": [
"",
"Current time: 2025-05-06 22:53:27 PDT",
"Time Source: NTP CLOCK ",
"Node booted: 2025-04-29 23:10:37 PDT (6d 23:42 ago)",
"System booted: 2025-04-29 23:11:27 PDT (6d 23:42 ago)",
"Protocols started: 2025-04-29 23:11:58 PDT (6d 23:41 ago)",
"Last configured: 2025-05-06 22:07:04 PDT (00:46:23 ago) by root",
"10:53PM up 6 days, 23:42, 1 user, load averages: 0.16, 0.12, 0.23"
]
},
"item.stdout": "\nCurrent time: 2025-05-06 22:53:27 PDT\nTime Source: NTP CLOCK \nNode booted: 2025-04-29 23:10:37 PDT (6d 23:42 ago)\nSystem booted: 2025-04-29 23:11:27 PDT (6d 23:42 ago)\nProtocols started: 2025-04-29 23:11:58 PDT (6d 23:41 ago)\nLast configured: 2025-05-06 22:07:04 PDT (00:46:23 ago) by root\n10:53PM up 6 days, 23:42, 1 user, load averages: 0.16, 0.12, 0.23\n"
}
ok: [10.53.115.24] => (item={'msg': 'The command executed successfully.', 'command': 'show interface terse', 'format': 'text', 'changed': False, 'failed': False, 'stdout': '\nInterface Admin Link Proto Local Remote\npfh-0/0/0 up up\npfh-0/0/0.16383 up up inet \net-0/0/1 up up\net-0/0/1.16386 up up multiservice\net-0/0/3 up up\net-0/0/3.16386 up up multiservice\net-0/0/5 up up\net-0/0/5.16386 up up multiservice\net-0/0/7 up up\net-0/0/7.16386 up up multiservice\net-0/0/9 up up\net-0/0/9.16386 up up multiservice\net-0/0/11 up up\net-0/0/11.16386 up up multiservice\net-0/0/13 up up\net-0/0/13.16386 up up multiservice\net-0/0/15 up up\net-0/0/15.16386 up up multiservice\nre0:mgmt-0 up up\nre0:mgmt-0.0 up up inet 10.53.115.24/19 \nre1:mgmt-0 up up\nre1:mgmt-0.0 up up inet 10.53.99.35/19 \ndsc up up\nesi up up\nfti0 up up\nfti1 up up\nfti2 up up\nfti3 up up\nfti4 up up\nfti5 up up\nfti6 up up\nfti7 up up\nirb up up\nlo0 up up\nlo0.0 up up inet 128.53.115.24 --> 0/0\n iso 47.0005.80ff.f800.0000.0108.0001.1280.5311.5024.00\n inet6 abcd::128:53:115:24 --> \n fe80::5604:af0:35:7318--> \nlsi up up\npip0 up up\nvtep up up\n', 'stdout_lines': ['', 'Interface Admin Link Proto Local Remote', 'pfh-0/0/0 up up', 'pfh-0/0/0.16383 up up inet ', 'et-0/0/1 up up', 'et-0/0/1.16386 up up multiservice', 'et-0/0/3 up up', 'et-0/0/3.16386 up up multiservice', 'et-0/0/5 up up', 'et-0/0/5.16386 up up multiservice', 'et-0/0/7 up up', 'et-0/0/7.16386 up up multiservice', 'et-0/0/9 up up', 'et-0/0/9.16386 up up multiservice', 'et-0/0/11 up up', 'et-0/0/11.16386 up up multiservice', 'et-0/0/13 up up', 'et-0/0/13.16386 up up multiservice', 'et-0/0/15 up up', 'et-0/0/15.16386 up up multiservice', 're0:mgmt-0 up up', 're0:mgmt-0.0 up up inet 10.53.115.24/19 ', 're1:mgmt-0 up up', 're1:mgmt-0.0 up up inet 10.53.99.35/19 ', 'dsc up up', 'esi up up', 'fti0 up up', 'fti1 up up', 'fti2 up up', 'fti3 up up', 'fti4 up up', 'fti5 up up', 'fti6 up up', 'fti7 up up', 'irb up up', 'lo0 up up', 'lo0.0 up up inet 128.53.115.24 --> 0/0', ' iso 47.0005.80ff.f800.0000.0108.0001.1280.5311.5024.00', ' inet6 abcd::128:53:115:24 --> ', ' fe80::5604:af0:35:7318--> ', 'lsi up up', 'pip0 up up', 'vtep up up']}) => {
"ansible_loop_var": "item",
"item": {
"changed": false,
"command": "show interface terse",
"failed": false,
"format": "text",
"msg": "The command executed successfully.",
"stdout": "\nInterface Admin Link Proto Local Remote\npfh-0/0/0 up up\npfh-0/0/0.16383 up up inet \net-0/0/1 up up\net-0/0/1.16386 up up multiservice\net-0/0/3 up up\net-0/0/3.16386 up up multiservice\net-0/0/5 up up\net-0/0/5.16386 up up multiservice\net-0/0/7 up up\net-0/0/7.16386 up up multiservice\net-0/0/9 up up\net-0/0/9.16386 up up multiservice\net-0/0/11 up up\net-0/0/11.16386 up up multiservice\net-0/0/13 up up\net-0/0/13.16386 up up multiservice\net-0/0/15 up up\net-0/0/15.16386 up up multiservice\nre0:mgmt-0 up up\nre0:mgmt-0.0 up up inet 10.53.115.24/19 \nre1:mgmt-0 up up\nre1:mgmt-0.0 up up inet 10.53.99.35/19 \ndsc up up\nesi up up\nfti0 up up\nfti1 up up\nfti2 up up\nfti3 up up\nfti4 up up\nfti5 up up\nfti6 up up\nfti7 up up\nirb up up\nlo0 up up\nlo0.0 up up inet 128.53.115.24 --> 0/0\n iso 47.0005.80ff.f800.0000.0108.0001.1280.5311.5024.00\n inet6 abcd::128:53:115:24 --> \n fe80::5604:af0:35:7318--> \nlsi up up\npip0 up up\nvtep up up\n",
"stdout_lines": [
"",
"Interface Admin Link Proto Local Remote",
"pfh-0/0/0 up up",
"pfh-0/0/0.16383 up up inet ",
"et-0/0/1 up up",
"et-0/0/1.16386 up up multiservice",
"et-0/0/3 up up",
"et-0/0/3.16386 up up multiservice",
"et-0/0/5 up up",
"et-0/0/5.16386 up up multiservice",
"et-0/0/7 up up",
"et-0/0/7.16386 up up multiservice",
"et-0/0/9 up up",
"et-0/0/9.16386 up up multiservice",
"et-0/0/11 up up",
"et-0/0/11.16386 up up multiservice",
"et-0/0/13 up up",
"et-0/0/13.16386 up up multiservice",
"et-0/0/15 up up",
"et-0/0/15.16386 up up multiservice",
"re0:mgmt-0 up up",
"re0:mgmt-0.0 up up inet 10.53.115.24/19 ",
"re1:mgmt-0 up up",
"re1:mgmt-0.0 up up inet 10.53.99.35/19 ",
"dsc up up",
"esi up up",
"fti0 up up",
"fti1 up up",
"fti2 up up",
"fti3 up up",
"fti4 up up",
"fti5 up up",
"fti6 up up",
"fti7 up up",
"irb up up",
"lo0 up up",
"lo0.0 up up inet 128.53.115.24 --> 0/0",
" iso 47.0005.80ff.f800.0000.0108.0001.1280.5311.5024.00",
" inet6 abcd::128:53:115:24 --> ",
" fe80::5604:af0:35:7318--> ",
"lsi up up",
"pip0 up up",
"vtep up up"
]
},
"item.stdout": "\nInterface Admin Link Proto Local Remote\npfh-0/0/0 up up\npfh-0/0/0.16383 up up inet \net-0/0/1 up up\net-0/0/1.16386 up up multiservice\net-0/0/3 up up\net-0/0/3.16386 up up multiservice\net-0/0/5 up up\net-0/0/5.16386 up up multiservice\net-0/0/7 up up\net-0/0/7.16386 up up multiservice\net-0/0/9 up up\net-0/0/9.16386 up up multiservice\net-0/0/11 up up\net-0/0/11.16386 up up multiservice\net-0/0/13 up up\net-0/0/13.16386 up up multiservice\net-0/0/15 up up\net-0/0/15.16386 up up multiservice\nre0:mgmt-0 up up\nre0:mgmt-0.0 up up inet 10.53.115.24/19 \nre1:mgmt-0 up up\nre1:mgmt-0.0 up up inet 10.53.99.35/19 \ndsc up up\nesi up up\nfti0 up up\nfti1 up up\nfti2 up up\nfti3 up up\nfti4 up up\nfti5 up up\nfti6 up up\nfti7 up up\nirb up up\nlo0 up up\nlo0.0 up up inet 128.53.115.24 --> 0/0\n iso 47.0005.80ff.f800.0000.0108.0001.1280.5311.5024.00\n inet6 abcd::128:53:115:24 --> \n fe80::5604:af0:35:7318--> \nlsi up up\npip0 up up\nvtep up up\n"
}
TASK [TEST 3 - Two commands with XML output.] **************************************************************************************************
ok: [10.53.115.24]
TASK [Check TEST 3] ****************************************************************************************************************************
ok: [10.53.115.24] => {
"changed": false,
"msg": "All assertions passed"
}
TASK [TEST 4 - show route with XML output - show version with JSON output] *********************************************************************
ok: [10.53.115.24]
TASK [Check TEST 4] ****************************************************************************************************************************
ok: [10.53.115.24] => {
"changed": false,
"msg": "All assertions passed"
}
TASK [TEST 5 - save outputs in dest_dir] *******************************************************************************************************
ok: [10.53.115.24]
TASK [Check TEST 5] ****************************************************************************************************************************
ok: [10.53.115.24] => {
"changed": false,
"msg": "All assertions passed"
}
TASK [TEST 6 - save output to dest] ************************************************************************************************************
ok: [10.53.115.24]
TASK [Check TEST 6] ****************************************************************************************************************************
ok: [10.53.115.24] => {
"changed": false,
"msg": "All assertions passed"
}
TASK [TEST 7 - save output to dest] ************************************************************************************************************
ok: [10.53.115.24]
TASK [Check TEST 7] ****************************************************************************************************************************
ok: [10.53.115.24] => {
"changed": false,
"msg": "All assertions passed"
}
TASK [TEST 8 - Multiple commands, save outputs, but don't return them] *************************************************************************
ok: [10.53.115.24]
TASK [Check TEST 8] ****************************************************************************************************************************
ok: [10.53.115.24] => {
"changed": false,
"msg": "All assertions passed"
}
PLAY RECAP *************************************************************************************************************************************
10.53.115.24 : ok=18 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0