Thanks for help i have another question so as i am running script as
localhost it is making backup on local host even though in ssh into another
node i tried by combining backup and ssh process together but it didn't
worked error says no such file directory.
- name: make backup
shell: |
ssh user@hostname
tar cvf "$HOSTNAME"_`date +"%Y-%m-%d"`.tar /opt/backup_test
error:
TASK [make backup]
**************************************************************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": true, "cmd": "ssh user@hostname
\n tar cvf \"$HOSTNAME\"_`date +\"%Y-%m-%d\"`.tar /opt/backup_test",
"delta": "0:00:00.077642", "end": "2017-10-12 02:07:50.314514", "failed":
true, "msg": "non-zero return code", "rc": 2, "start": "2017-10-12
02:07:50.236872", "stderr": "Pseudo-terminal will not be allocated because
stdin is not a terminal.\r\ntar: Removing leading `/' from member
names\ntar: /opt/backup_test: Cannot stat: No such file or directory\ntar:
Exiting with failure status due to previous errors", "stderr_lines":
["Pseudo-terminal will not be allocated because stdin is not a terminal.",
"tar: Removing leading `/' from member names", "tar: /opt/backup_test:
Cannot stat: No such file or directory", "tar: Exiting with failure status
due to previous errors"], "stdout": "", "stdout_lines": []}
PLAY RECAP
**********************************************************************************************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=1
On Thursday, October 12, 2017 at 9:42:06 AM UTC-4, Kai Stian Olstad wrote:
>
> 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/06c56563-f4bb-45ed-b754-7f56fbb0509f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.