How to get fetch files from non-inventory servers ?
623 views
Skip to first unread message
ka...@wizni.com
unread,
Nov 1, 2016, 10:10:17 PM11/1/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
Hi all,
How to get fetch files from non-inventory servers ?
After searching in docs for 2 days, I cannot find any explicit scp/sftp module. This could be due to fact that ansible already does file transfers bw servers by scp/sftp.
But I want to fetch some file on ansible server every time a playbook is run. from a server thats not in inventory file. I have setup a restricted user ( with password ) on sftp server.
I want this transfer over sftp. Any help /advise / pointer in right direction is highly welcome.
I am on ansible 2.1.0.0 if that matters.
Thanks, Kapil
Dick Davies
unread,
Nov 2, 2016, 4:53:37 AM11/2/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible list
There'd be no harm in putting the server in the inventory ( with
ansible_ssh_user set to the restricted user)
if you want to take advantage of the built-in mechanisms. Nothing says
everything in the inventory has
to be actively managed by Ansible.
Pull the file locally at the start of the play and push it up to wherever.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
You can use shell/command modules to make an sftp. What's the issue here?
You can do another dirty trick use delegate to switch server but that would require the server already in inventory.
So I would use shell module and run my scp the old way.
M B
ka...@wizni.com
unread,
Nov 2, 2016, 12:27:50 PM11/2/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
Could have done this, but simple sftp doesnt work with password provided over command line. needs another layer of ssh-pass / expect-send I am missing scp with username/password.
Last thing I can try discussing with end users is instead of user/password ... gather all public keys of ansible-servers and add them in sftp server.
Brian Coca
unread,
Nov 2, 2016, 2:00:57 PM11/2/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
You can use fetch module with delegate_to that server, you might also need to set other connection parameters on that task.