Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to copy a local file to a remove server without using the Copy module?

Tags:

ansible

I'm working on a playbook to upload a configuration file to remote servers, but the remote servers do not have python installed (which is a requirement for using modules). I have successfully written other playbooks using the raw feature to avoid having to install python on the servers, but I can't find any examples in the Ansible documentation to perform a file upload using bare-bones ssh. Is a non-module based upload possible?

like image 306
Jay Avatar asked Oct 22 '25 05:10

Jay


1 Answers

No sure why do you use Ansible this way, but you can make a local task with scp:

- name: remote task
  raw: echo remote

- name: local scp
  local_action: command scp /path/to/localfile {{ inventory_hostname }}:/path/to/remotefile

- name: remote task
  raw: cat /path/to/remotefile

I usually check and install python with raw module and continue with Ansible core modules.

like image 141
Konstantin Suvorov Avatar answered Oct 23 '25 19:10

Konstantin Suvorov