On 12.10.2017 15:29, Zimidar Boy wrote:
TASK [Creates Sftp session to send files to terastation.]
****************************************************************************************************************************************************************************************************************************
changed: [localhost] => {"changed": true, "cmd": "sftp user@hostname",
"delta": "0:00:01.136744", "end": "2017-10-11 05:14:25.224441", "failed":
false, "rc": 0, "start": "2017-10-11 05:14:24.087697", "stdout":
"Connecting to terastation...\r\nPassword: \r\nsftp> exit", "stdout_lines":
["Connecting to terastation...", "Password: ", "sftp> exit"]}

It do login but just run and exit afterward, and exit is the last of you responses.


Here is sample of my script:

- hosts: localhost
  sudo: true
  tasks:

   - name: Log  into node
     shell: ssh user@hostname

   - name: make backup of files
     shell: tar cvf "$HOSTNAME"_`date +"%Y-%m-%d"`.tar
/etc/ansible/playbooks


   - name: Creates Sftp session to send files to terastation.
     expect:
       command: sftp user@hostname
       responses:
           (?i)Password: "1rfr2345"
           (?i)sftp>: "cd abc/def/"
           (?i)sftp>: "put "$HOSTNAME"_`date +"%Y-%m-%d"`.tar  "
           (?i)sftp>: "exit"


If more info needed pls let me know. Thanks in advance.

I think you only can have one unique question with the responses in a list like this.

  - name: Creates Sftp session to send files to terastation.
    expect:
      command: sftp user@hostname
      responses:
        (?i)Password: "1rfr2345"
        (?i)sftp>:
          - "cd abc/def/"
          - "put "$HOSTNAME"_`date +"%Y-%m-%d"`.tar  "
          - "exit"

--
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1c748f5832bf9809a4c224fd683209fd%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to