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 [email protected]
> 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 [email protected]
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/20200212161532.gfkaw6ozvfjtkeb7%40olstad.com.