Re: [ansible-project] Ansible expect module with Oracle SBC
On Tue, Feb 18, 2020 at 02:38:40AM -0800, Gerhard Van Der Wath wrote: > HI Kai. > > When running this command via Ansible I am getting the following: > > fatal: [##]: FAILED! => { > "changed": false, > "invocation": { > "module_args": { > "chdir": null, > "command": "ssh admin@#", > "creates": null, > "echo": false, > "removes": null, > "responses": { > "#": [ > "show xcode load -detail", > "exit" > ], > "(?i)password": "###" > }, > "timeout": 30 > } > }, > "msg": "No remaining responses for '#', output was 'Sess Current As the message says, expect still get the # prompt but doesn't have any more responses to type in. > Maximum\r\n === === = === ===\r\n 00 0 14 > 3.33% 29.28%\r\n 00 1 17 2.97% 29.02%\r\n 01 0 - > --\r\n 01 1 - --\r\n 02 0 - > --\r\n 02 1 - --\r\n 03 0 - - > -\r\n 03 1 - --\r\n 04 0 - - > -\r\n 04 1 - --\r\n 05 0 - - > -\r\n 05 1 - --\r\n 06 0 - - > -\r\n 06 1 - --\r\n 07 0 - - > -\r\n 07 1 - --\r\n 08 0 - - > -\r\n 08 1 - --\r\n 09 0 - - > -\r\n 09 1 - --\r\n 10 0 - - > -\r\n 10 1 - --\r\n 11 0 - - > -\r\n 11 1 - --\r\nSBCHA1#'" The last part "\r\nSBCHA1#" show that expect get the prompt again. > The output of the command is as below: > > HA1# show xcode load -detail > 12:37:54 > Total Sessions:334 > - Load - > TCM DSP #Sess Current Maximum In the output you have a #. Since you have said to expect that "#" is the sting to trigger a response it will type exit here, but since this is not the prompt this causes issues. The text expect should trigger on in responses has to be unique, an in you case # is not. So you need to add more characters to it. If the prompt always is "BCHA1#" you can use that instead of only "#" -- Kai Stian Olstad -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/20200218160601.geskqbuvmww7l7ly%40olstad.com.
Re: [ansible-project] Ansible expect module with Oracle SBC
HI Kai. When running this command via Ansible I am getting the following: The full traceback is: File "/tmp/ansible_expect_payload__etk4d92/ansible_expect_payload.zip/ansible/modules/commands/expect.py", line 123, in wrapped fatal: [##]: FAILED! => { "changed": false, "invocation": { "module_args": { "chdir": null, "command": "ssh admin@#", "creates": null, "echo": false, "removes": null, "responses": { "#": [ "show xcode load -detail", "exit" ], "(?i)password": "###" }, "timeout": 30 } }, "msg": "No remaining responses for '#', output was 'Sess Current Maximum\r\n === === = === ===\r\n 00 0 14 3.33% 29.28%\r\n 00 1 17 2.97% 29.02%\r\n 01 0 - --\r\n 01 1 - --\r\n 02 0 - --\r\n 02 1 - --\r\n 03 0 - - -\r\n 03 1 - --\r\n 04 0 - - -\r\n 04 1 - --\r\n 05 0 - - -\r\n 05 1 - --\r\n 06 0 - - -\r\n 06 1 - --\r\n 07 0 - - -\r\n 07 1 - --\r\n 08 0 - - -\r\n 08 1 - --\r\n 09 0 - - -\r\n 09 1 - --\r\n 10 0 - - -\r\n 10 1 - --\r\n 11 0 - - -\r\n 11 1 - --\r\nSBCHA1#'" } The output of the command is as below: HA1# show xcode load -detail 12:37:54 Total Sessions:334 - Load - TCM DSP #Sess Current Maximum === === = === === 00 0 8518.78% 32.74% 00 1 8218.80% 32.80% 01 0 8218.58% 32.70% 01 1 8518.56% 32.68% 02 0 - -- 02 1 - -- 03 0 - -- 03 1 - -- 04 0 - -- 04 1 - -- 05 0 - -- 05 1 - -- 06 0 - -- 06 1 - -- 07 0 - -- 07 1 - -- 08 0 - -- 08 1 - -- 09 0 - -- 09 1 - -- 10 0 - -- 10 1 - -- 11 0 - -- 11 1 - -- I am guessing it is the - character that may be causing an issue? On Thursday, 13 February 2020 12:14:49 UTC+2, Kai Stian Olstad wrote: > > On Thu, Feb 13, 2020 at 01:22:37AM -0800, Gerhard Van Der Wath wrote: > > Thank you Kai. > > > > I think I am making progress, is this the output that is expected: > > > > "* > > > *", > > "* Disconnect IMMEDIATELY if you are not an authorized user! > > > *", > > "*All access and use may be monitored and/or recorded. > * > > ", > > "* > > > *", > > > > "**", > > "", > > "", > > "SBCHA1# show sessions", > > "11:17:24-107 Capacity=4000", > > "Session Statistics-- Period -- Lifetime > > ", > > "ActiveHigh Total Total PerMax > > > High", > > "Total Sessions160616613346 128530803 15238 > > > 2452", > > "SIP Sessions 160616613346 128530803 15238 > > > 2452", > > "H.323 Calls 0 0 0 0 0 > > > 0", > > "", > > "SIP Audio/Video Statistics-- Period -- Lifetime > > ", > > "ActiveHigh Total Total PerMax > > > High", > > "Audio Calls 154115922582 906991178060 > > > 2096", > > "Video Calls 0 0 0113 7 > > > 2", > > "Messaging Sessions 0 0 0 0 0 > > > 0", > > "SBCHA1# sh platform cpu-load", > > "Timestamp: 11:17:24 Thu 2020-02-13", > > "Total load : 9%", > > "CPU 00 load : 9%", > > "CPU 01 load : 9%", > > "CPU 02 load : 10%", > > "CPU 03 load : 9%", > > "SBCHA1# exit", > > "SBCHA1> " > > ] > > It is as expected. >
Re: [ansible-project] Ansible expect module with Oracle SBC
On Thu, Feb 13, 2020 at 01:22:37AM -0800, Gerhard Van Der Wath wrote: > Thank you Kai. > > I think I am making progress, is this the output that is expected: > > "* > *", > "* Disconnect IMMEDIATELY if you are not an authorized user! > *", > "*All access and use may be monitored and/or recorded.* > ", > "* > *", > > "**", > "", > "", > "SBCHA1# show sessions", > "11:17:24-107 Capacity=4000", > "Session Statistics-- Period -- Lifetime > ", > "ActiveHigh Total Total PerMax > High", > "Total Sessions160616613346 128530803 15238 > 2452", > "SIP Sessions 160616613346 128530803 15238 > 2452", > "H.323 Calls 0 0 0 0 0 > 0", > "", > "SIP Audio/Video Statistics-- Period -- Lifetime > ", > "ActiveHigh Total Total PerMax > High", > "Audio Calls 154115922582 906991178060 > 2096", > "Video Calls 0 0 0113 7 > 2", > "Messaging Sessions 0 0 0 0 0 > 0", > "SBCHA1# sh platform cpu-load", > "Timestamp: 11:17:24 Thu 2020-02-13", > "Total load : 9%", > "CPU 00 load : 9%", > "CPU 01 load : 9%", > "CPU 02 load : 10%", > "CPU 03 load : 9%", > "SBCHA1# exit", > "SBCHA1> " > ] It is as expected. Expect doesn't do any magic it only looks for the key in the output and types the response an hit enter and shows all the output. > > As a note, the SBC does have a ASCII banner, not sure if it may cause > issues. If the banner contain the same string as in our responses it will. That why it's important that the responses are unique. -- Kai Stian Olstad -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/20200213101427.veliswrhdqjka2nw%40olstad.com.
Re: [ansible-project] Ansible expect module with Oracle SBC
Thank you Kai. I think I am making progress, is this the output that is expected: "* *", "* Disconnect IMMEDIATELY if you are not an authorized user! *", "*All access and use may be monitored and/or recorded.* ", "* *", "**", "", "", "SBCHA1# show sessions", "11:17:24-107 Capacity=4000", "Session Statistics-- Period -- Lifetime ", "ActiveHigh Total Total PerMax High", "Total Sessions160616613346 128530803 15238 2452", "SIP Sessions 160616613346 128530803 15238 2452", "H.323 Calls 0 0 0 0 0 0", "", "SIP Audio/Video Statistics-- Period -- Lifetime ", "ActiveHigh Total Total PerMax High", "Audio Calls 154115922582 906991178060 2096", "Video Calls 0 0 0113 7 2", "Messaging Sessions 0 0 0 0 0 0", "SBCHA1# sh platform cpu-load", "Timestamp: 11:17:24 Thu 2020-02-13", "Total load : 9%", "CPU 00 load : 9%", "CPU 01 load : 9%", "CPU 02 load : 10%", "CPU 03 load : 9%", "SBCHA1# exit", "SBCHA1> " ] As a note, the SBC does have a ASCII banner, not sure if it may cause issues. On Wednesday, 12 February 2020 18:15:53 UTC+2, Kai Stian Olstad wrote: > > On Wed, Feb 12, 2020 at 02:39:08AM -0800, Gerhard Van Der Wath wrote: > > Hi Kai. > > > > Thank you for taking the time to get back to me. > > > > It is highly appreciated, and apologies for the formatting of my > request, I > > will correct this in future. > > > > I am in uncharted waters here as I am new to Ansible, and coding in > > general, but I have made some changes to the code: > > > > - name: Check CPU > > hosts: 10.18.170.200 > > connection: local > > gather_facts: yes > > > > > > tasks: > > > > - name: Get CPU load > > expect: > > command: ssh ad...@10.18.170.200 > > responses: > >(?i)password: "###" > > > > - name: basic command > > expect: > > command: show platform cpu-load summary > > responses: > >(?i)#: > > You can't split it like that. > Two tasks in Ansible have nothing do to with each other. > > The expect command will always be the ssh and in the response section it > will > contain the command for the interface. > > So it will be something like this. > > - name: Get CPU load > expect: > command: ssh ad...@10.18.170.200 > responses: > (?i)password: "###" > #: > - show platform cpu-load summary > - exit > > When expect sees "password" it will type "###" and hit enter. > When it sees "#" it will write the first element in the list(show...) of > the > second time expect sees "#" it will write "exit" and hit enter. > (I presume exit terminate the connection, if not change it to the correct > command) > > -- > Kai Stian Olstad > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/74084223-62a4-4662-b77b-48b7ed35191f%40googlegroups.com.
Re: [ansible-project] Ansible expect module with Oracle SBC
On Wed, Feb 12, 2020 at 02:39:08AM -0800, Gerhard Van Der Wath wrote: > Hi Kai. > > Thank you for taking the time to get back to me. > > It is highly appreciated, and apologies for the formatting of my request, I > will correct this in future. > > I am in uncharted waters here as I am new to Ansible, and coding in > general, but I have made some changes to the code: > > - name: Check CPU > hosts: 10.18.170.200 > connection: local > gather_facts: yes > > > tasks: > > - name: Get CPU load > expect: > command: ssh admin@10.18.170.200 > responses: >(?i)password: "###" > > - name: basic command > expect: > command: show platform cpu-load summary > responses: >(?i)#: You can't split it like that. Two tasks in Ansible have nothing do to with each other. The expect command will always be the ssh and in the response section it will contain the command for the interface. So it will be something like this. - name: Get CPU load expect: command: ssh admin@10.18.170.200 responses: (?i)password: "###" #: - show platform cpu-load summary - exit When expect sees "password" it will type "###" and hit enter. When it sees "#" it will write the first element in the list(show...) of the second time expect sees "#" it will write "exit" and hit enter. (I presume exit terminate the connection, if not change it to the correct command) -- Kai Stian Olstad -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/20200212161532.gfkaw6ozvfjtkeb7%40olstad.com.
Re: [ansible-project] Ansible expect module with Oracle SBC
Hi Kai. Thank you for taking the time to get back to me. It is highly appreciated, and apologies for the formatting of my request, I will correct this in future. I am in uncharted waters here as I am new to Ansible, and coding in general, but I have made some changes to the code: - name: Check CPU hosts: 10.18.170.200 connection: local gather_facts: yes tasks: - name: Get CPU load expect: command: ssh admin@10.18.170.200 responses: (?i)password: "###" - name: basic command expect: command: show platform cpu-load summary responses: (?i)#: I am getting the below fatal: [10.18.170.200]: FAILED! => { "changed": false, "invocation": { "module_args": { "chdir": null, "command": "show platform cpu-load", "creates": null, "echo": false, "removes": null, "responses": { "(?i)#": null }, "timeout": 30 } }, "msg": "The command was not found or was not executable: show." } On Tuesday, 11 February 2020 13:33:54 UTC+2, Kai Stian Olstad wrote: > > On Wed, Feb 05, 2020 at 01:05:57AM -0800, Gerhard Van Der Wath wrote: > > Hi. > > Hi, if you had posted a plain text mail instead of HTML you would have > gotten a > replay a lot sooner. > As you can see bellow you formatting is hard to read. > > > > tasks: > > > > - name: Get CPU load > > expect: > > command: ssh admin@# > > responses: > > 'password: ': > > - ### > > '#': > > - sh platform cpu-load > > > > > > > > Error: > > > > fatal: [##]: FAILED! => { "changed": false, "invocation": { > > "module_args": { "chdir": null, "command": "ssh admin@##", > "creates": > > null, "echo": false, "removes": null, "responses": { "#": [ "sh platform > > cpu-load" ], "password: ": [ "##" ] }, "timeout": 30 } }, "msg": "No > > remaining responses for '#', output was ' sh platform > > cpu-load\r\nTimestamp: 10:49:41 Wed 2020-02-05\r\nTotal load : 4%\r\nCPU > 00 > > load : 5%\r\nCPU 01 load : 3%\r\nCPU 02 load : 5%\r\nCPU 03 load : > > 5%\r\nVOXBDLHA1#'" } > > As the msg says expect has gotten a prompt # put have no more command to > give. > Remember that expect is you substitute for a human typing inn commands, so > you > need to provide all command from start, ssh in you case, to the exit of > the ssh command. > > So you need to add an element to the item "#" in your responses to exit > the command. > > -- > Kai Stian Olstad > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/13bb319c-590e-4fd3-8232-f57104bc6e1e%40googlegroups.com.
Re: [ansible-project] Ansible expect module with Oracle SBC
On Wed, Feb 05, 2020 at 01:05:57AM -0800, Gerhard Van Der Wath wrote: > Hi. Hi, if you had posted a plain text mail instead of HTML you would have gotten a replay a lot sooner. As you can see bellow you formatting is hard to read. > tasks: > > - name: Get CPU load > expect: > command: ssh admin@# > responses: > 'password: ': > - ### > '#': > - sh platform cpu-load > > > > Error: > > fatal: [##]: FAILED! => { "changed": false, "invocation": { > "module_args": { "chdir": null, "command": "ssh admin@##", "creates": > null, "echo": false, "removes": null, "responses": { "#": [ "sh platform > cpu-load" ], "password: ": [ "##" ] }, "timeout": 30 } }, "msg": "No > remaining responses for '#', output was ' sh platform > cpu-load\r\nTimestamp: 10:49:41 Wed 2020-02-05\r\nTotal load : 4%\r\nCPU 00 > load : 5%\r\nCPU 01 load : 3%\r\nCPU 02 load : 5%\r\nCPU 03 load : > 5%\r\nVOXBDLHA1#'" } As the msg says expect has gotten a prompt # put have no more command to give. Remember that expect is you substitute for a human typing inn commands, so you need to provide all command from start, ssh in you case, to the exit of the ssh command. So you need to add an element to the item "#" in your responses to exit the command. -- Kai Stian Olstad -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/2020023332.l6sb4feyxlgdtduo%40olstad.com.
[ansible-project] Ansible expect module with Oracle SBC
Hi. I am having an issue with Ansible's expect module. I am trying to run simple commands on a Oracle SBC, but getting some errors. Playbook: - name: Check CPU hosts: all connection: local gather_facts: yes tasks: - name: Get CPU load expect: command: ssh admin@# responses: 'password: ': - ### '#': - sh platform cpu-load Error: fatal: [##]: FAILED! => { "changed": false, "invocation": { "module_args": { "chdir": null, "command": "ssh admin@##", "creates": null, "echo": false, "removes": null, "responses": { "#": [ "sh platform cpu-load" ], "password: ": [ "##" ] }, "timeout": 30 } }, "msg": "No remaining responses for '#', output was ' sh platform cpu-load\r\nTimestamp: 10:49:41 Wed 2020-02-05\r\nTotal load : 4%\r\nCPU 00 load : 5%\r\nCPU 01 load : 3%\r\nCPU 02 load : 5%\r\nCPU 03 load : 5%\r\nVOXBDLHA1#'" } I #ed out the IP and password Your assistance will be appreciated. -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/2ed4a7da-5295-44a8-9dc6-61d114d0255e%40googlegroups.com.