Thanks a mil!

Seem to be making progress, still received a failure though, looks like the 
python module is required on target, which does not appear to be possible 
now, 
May need to look at an alternative

{
    "_ansible_parsed": true,
    "exception": "  File \"/tmp/ansible_e1OJFD/ansible_module_expect.py\", 
line 95, in <module>\n    import pexpect\n",
    "_ansible_no_log": false,
    "changed": false,
    "invocation": {
        "module_args": {
            "chdir": null,
            "responses": {
                "#": [
                    "show platform cpu-load summary"
                ]
            },
            "removes": null,
            "echo": false,
            "creates": null,
            "command": null,
            "timeout": 30
        }
    },
    "msg": "The pexpect python module is required"
}

On Wednesday, August 29, 2018 at 12:47:13 PM UTC+2, Kai Stian Olstad wrote:
>
> On 29.08.2018 12:21, julian.mit...@gmail.com <javascript:> wrote: 
> > Fantastic. 
> > So the box is running acme sbc. 
> > Aim to achieve the following via AWX / Ansible: 
> > ***************# show platform cpu-load summary <------- the command to 
> > run 
> > Total load:       11% 
> >           CPU#00  14% 
> >           CPU#01  8% 
> > 
> > Load average: 2.86 3.00 3.00 2/281 7385 
>
> You have redacted the most important part the prompt. 
> Expect is petty easy, it looks for a string/text, when it sees that 
> ecpect respond with a command and press enter. 
> This string must be unique or else expect will type a command at the 
> wrong place. 
> But if you do not have # anywhere else you can use that. 
>
>
> > Playbook contents : 
> > 
> > --- 
> > - name: Check CPU Load 
> >   hosts: all 
> >   connection: local 
> >   gather_facts: yes 
> > 
> > 
> >   tasks: 
> > 
> >   - name: Get CPU Load 
> >     expect: 
> >       command: show platform cpu-load summary 
>
> The command is the ssh command you need to login. 
>
> So you should a provided the whole output above, staring from a Linux 
> prompt above. 
> Think of expect as a user that is typing the command manually. So need 
> to start from prompt to now what is needed in responses bellow, because 
> every keystroke you do expect has to do them also. 
>
>
> >       responses: 
> >         cpu 
>
> The responses part is where you have the question answer section, this 
> is the string expect is waiting for and the command it should type. 
>
> So in your case we need to use the prompt/string # since you redacted 
> the rest 
>
>    responses: 
>      '#': show platform cpu-load summary 
>
> So the # is the question/string/prompt and the part after colon is the 
> command to run. 
> The quotes is needed if not # is taken as a comment. 
>
> If you would like to run more than one command per unique prompt they 
> need to be in a list: 
>
>    responses: 
>      '#': 
>        - show platform cpu-load summary 
>        - show something else 
>
> You probably need to handle the password prompt in the responses too. 
>
> -- 
> 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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/772aab38-d4f1-488f-afd3-90ba90e2d56c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to