0
votes

So, the scenario is: I have a mini computer (running Ubuntu server 18.04) that is accessible using SSH from my local machine. Attached to the mini computer is a sensor device that is connected via USB, but accessed from the mini computer using SSH with [email protected] (no password) and is running a stripped back form of Linux.

I need to copy a config file onto the device, (and am able to do this from the mini computer using SCP successfully), but want to be able to do this from my local machine using Ansible as there will be hundreds of these to setup, each with different configurations.

The Ansible role looks like this:

- name: "Copy config file to mini PC"
  template:
    src: config.json.j2
    dest: "{{ pc_config_path}}"

- name: "Copy config file from mini PC to sensor
  command: "scp {{ pc_config_path}} root@{{ device_ip_addr }}:{{ device_config_path }}"
  become: yes

The first task executes successfully, but the second one just hangs.

I've tried shell and raw, and even creating a bash script and running that without success.

Not sure if this is a security limitation, but would like to find a solution. So any ideas would help.

Thanks.

1
try synchronize module to copy local to remote it's also using secure copyArbab Nazar
@ArbabNazar, I think you misread my issue, the problem isn't copying from my local to the the remote - that works fine. The problem is copying from the remote (eg. Raspberry Pi) to another device (e.g the sensor) attached to it.rodp82

1 Answers

2
votes

Figured out the scp command was waiting for a response to add the device to the list of known_hosts

Updated the task to

- name: "Copy gnd.json from PC to v2x unit"
  command: "scp -oStrictHostKeyChecking=no {{ pc_config_path }} root@{{ device_ip_addr }}:{{ device_config_path }}"

And everything worked