# Ansible expect module with Oracle SBC

**URL:** <https://forum.ansible.com/t/ansible-expect-module-with-oracle-sbc/32141>\
**Category:** Ansible Project\
**Created:** [February 5, 2020, 9:05am UTC](https://forum.ansible.com/t/ansible-expect-module-with-oracle-sbc/32141 "2020-02-05T09:05:57Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gerhard\_Van\_Der\_Wath](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@Gerhard\_Van\_Der\_Wath](https://forum.ansible.com/u/Gerhard_Van_Der_Wath)\
**Post date:** [February 5, 2020, 9:05am UTC](https://forum.ansible.com/t/ansible-expect-module-with-oracle-sbc/32141/1 "2020-02-05T09:05:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [February 11, 2020, 11:33am UTC](https://forum.ansible.com/t/ansible-expect-module-with-oracle-sbc/32141/2 "2020-02-11T11:33:32Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![Gerhard\_Van\_Der\_Wath](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@Gerhard\_Van\_Der\_Wath](https://forum.ansible.com/u/Gerhard_Van_Der_Wath)\
**Post date:** [February 12, 2020, 10:39am UTC](https://forum.ansible.com/t/ansible-expect-module-with-oracle-sbc/32141/3 "2020-02-12T10:39:08Z")

</div>

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](mailto: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.”  
}

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [February 12, 2020, 4:15pm UTC](https://forum.ansible.com/t/ansible-expect-module-with-oracle-sbc/32141/4 "2020-02-12T16:15:32Z")

</div>

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.

&nbsp;&nbsp;- name: Get CPU load  
&nbsp;&nbsp;&nbsp;&nbsp;expect:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;command: ssh admin@10.18.170.200  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;responses:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(?i)password: "#######"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#:  
&nbsp;&nbsp;&nbsp;&nbsp;- show platform cpu-load summary  
&nbsp;&nbsp;&nbsp;&nbsp;- 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)

---

<div class="post-metadata">

**Author:** ![Gerhard\_Van\_Der\_Wath](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@Gerhard\_Van\_Der\_Wath](https://forum.ansible.com/u/Gerhard_Van_Der_Wath)\
**Post date:** [February 13, 2020, 9:22am UTC](https://forum.ansible.com/t/ansible-expect-module-with-oracle-sbc/32141/5 "2020-02-13T09:22:37Z")

</div>

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 --------”,  
" Active High Total Total PerMax High”,  
“Total Sessions 1606 1661 3346 128530803 15238 2452”,  
“SIP Sessions 1606 1661 3346 128530803 15238 2452”,  
“H.323 Calls 0 0 0 0 0 0”,  
“”,  
“SIP Audio/Video Statistics – Period – -------- Lifetime --------”,  
" Active High Total Total PerMax High”,  
“Audio Calls 1541 1592 2582 90699117 8060 2096”,  
“Video Calls 0 0 0 113 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.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [February 13, 2020, 10:14am UTC](https://forum.ansible.com/t/ansible-expect-module-with-oracle-sbc/32141/6 "2020-02-13T10:14:27Z")

</div>

> Thank you Kai.
> 
> I think I am making progress, is this the output that is expected:
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"\*  
> \*",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"\* Disconnect IMMEDIATELY if you are not an authorized user!  
> \*",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"\* All access and use may be monitored and/or recorded. \*  
> ",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"\*  
> \*",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
> "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"SBCHA1# show sessions",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"11:17:24-107 Capacity=4000",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Session Statistics -- Period -- -------- Lifetime  
> --------",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" Active High Total Total PerMax  
> High",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Total Sessions 1606 1661 3346 128530803 15238  
> 2452",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"SIP Sessions 1606 1661 3346 128530803 15238  
> 2452",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"H.323 Calls 0 0 0 0 0  
> 0",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"SIP Audio/Video Statistics -- Period -- -------- Lifetime  
> --------",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" Active High Total Total PerMax  
> High",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Audio Calls 1541 1592 2582 90699117 8060  
> 2096",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Video Calls 0 0 0 113 7  
> 2",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Messaging Sessions 0 0 0 0 0  
> 0",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"SBCHA1# sh platform cpu-load",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Timestamp: 11:17:24 Thu 2020-02-13",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Total load : 9%",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"CPU 00 load : 9%",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"CPU 01 load : 9%",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"CPU 02 load : 10%",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"CPU 03 load : 9%",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"SBCHA1# exit",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"SBCHA1\> "  
> &nbsp;&nbsp;&nbsp;&nbsp;]

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.

---

<div class="post-metadata">

**Author:** ![Gerhard\_Van\_Der\_Wath](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@Gerhard\_Van\_Der\_Wath](https://forum.ansible.com/u/Gerhard_Van_Der_Wath)\
**Post date:** [February 18, 2020, 10:38am UTC](https://forum.ansible.com/t/ansible-expect-module-with-oracle-sbc/32141/7 "2020-02-18T10:38:40Z")

</div>

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 85 18.78% 32.74%  
00 1 82 18.80% 32.80%  
01 0 82 18.58% 32.70%  
01 1 85 18.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?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [February 18, 2020, 4:06pm UTC](https://forum.ansible.com/t/ansible-expect-module-with-oracle-sbc/32141/8 "2020-02-18T16:06:01Z")

</div>

> HI Kai.
> 
> When running this command via Ansible I am getting the following:
> 
> fatal: [######]: FAILED! =\> {  
> &nbsp;&nbsp;&nbsp;&nbsp;"changed": false,  
> &nbsp;&nbsp;&nbsp;&nbsp;"invocation": {  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"module\_args": {  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"chdir": null,  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"command": "ssh admin@#########",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"creates": null,  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"echo": false,  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"removes": null,  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"responses": {  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"#": [  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"show xcode load -detail",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"exit"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;],  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"(?i)password": "#######"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"timeout": 30  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
> &nbsp;&nbsp;&nbsp;&nbsp;},  
> &nbsp;&nbsp;&nbsp;&nbsp;"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 -  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- -\r\n 01 1 - - -\r\n 02 0 -  
> - -\r\n 02 1 - - -\r\n 03 0 - -  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-\r\n 03 1 - - -\r\n 04 0 - -  
> &nbsp;&nbsp;-\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  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;----- Load -----  
> &nbsp;&nbsp;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\<ENTER\> 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 "#"

---

<div class="post-metadata">

**Author:** ![Gerhard\_Van\_Der\_Wath](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@Gerhard\_Van\_Der\_Wath](https://forum.ansible.com/u/Gerhard_Van_Der_Wath)\
**Post date:** [June 29, 2020, 6:51am UTC](https://forum.ansible.com/t/ansible-expect-module-with-oracle-sbc/32141/9 "2020-06-29T06:51:39Z")

</div>

Hi Kai.

Trust you are well, we are testing adding new configs via Ansible on the SBC, just struggling, to handle the various prompt changes, as you navigate the different configuration levels, and I have tweaked the playbook, but not coming right.

Here is the below output.

The full traceback is:  
File “/tmp/ansible\_expect\_payload\_zp\_yu2yh/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”: {  
“(?i)password”: “########”,  
“(configure)#”: [  
“media-manager realm-config”  
],  
“(realm-config)#”: [  
“identifier TEST\_REALM\_2”,  
“addr-prefix 10.1.0.0/29”,  
“network-interfaces PEER\_F00:0”,  
“mm-in-realm disabled”,  
“mm-in-network enabled”,  
“mm-same-ip disabled”,  
“mm-in-system enabled”,  
“access-control-trust-level medium”,  
“invalid-signal-threshold 1’”,  
“maximum-signal-threshold 4000”,  
“untrusted-signal-threshold 0”,  
“options sip-connect-pbx-reg”,  
“qos-enable enabled”,  
“accounting-enable enabled”,  
“done”,  
“quit”  
],  
“HA1#”: [  
“save-config”,  
“verify-confog”,  
“activate-config”  
]  
},  
“timeout”: 30  
}  
},  
“msg”: “No remaining responses for ‘HA1#’, output was ’ activate-config\r\nActivate-Config received, processing.\r\nwaiting for request to finish\r\nRequest to ‘ACTIVATE-CONFIG’ has Finished, \r\nActivate Complete\r\nLABHA1#'”  
}  
…ignoring

Here is my playbook:

- name: Add config centrex child realm  
hosts: 10.11.171.20  
connection: local  
gather\_facts: yes

tasks:

- name: Add config  
expect:  
command: ssh admin@##########  
responses:  
(?i)password: “##########”  
‘HA1#’:

- conf t  
‘(configure)#’:

- media-manager realm-config  
‘(realm-config)#’:

- identifier TEST\_REALM\_2

- addr-prefix 10.1.0.0/29

- network-interfaces PEER\_F00:0

- mm-in-realm disabled

- mm-in-network enabled

- mm-same-ip disabled

- mm-in-system enabled

- access-control-trust-level medium

- invalid-signal-threshold 1’

- maximum-signal-threshold 4000

- untrusted-signal-threshold 0

- options sip-connect-pbx-reg

- qos-enable enabled

- accounting-enable enabled

- done

- quit  
‘HA1#’:

- save-config

- verify-confog

- activate-config  
ignore\_errors: true  
register: labsbc

- debug: var=labsbc.stdout\_lines
