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 [email protected]
      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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/13bb319c-590e-4fd3-8232-f57104bc6e1e%40googlegroups.com.

Reply via email to