ansible.netcommon icon indicating copy to clipboard operation
ansible.netcommon copied to clipboard

net_put for uploading files on routerOS

Open ialshaev opened this issue 1 year ago • 4 comments

SUMMARY

We observe strange behaviour when uploading certificates on routerOS. When the storage (i.e. /file) is empty and net_put based task is running at the first time the output surprises us with the following output:

TASK [role_name : copy file] ********************************************************************************************************
ok: [host] => (item=file_name) => {
    "ansible_loop_var": "file_name",
    "changed": false,
    "destination": "/file_name",
    "item": "file_name",
    "msg": "Warning: [Errno 2] No such file or directory: '/path/to/file/1d042134-4c09-468d-945c-9e8038c20c9d' idempotency check failed. Check dest"
}
  • the task result is "green" (not changed), which means that there is no changes. Although, we found that task successfully uploaded the file in the box and we can use it.

The next time, right after uploading procedure, we execute the playbook and expect to see "green" (not changed, as long as the file is persists in the box) we actually get "yellow" (changed) result:

TASK [role_name : copy file] ********************************************************************************************************
changed: [host] => (item=file_name) => {
    "ansible_loop_var": "file_name",
    "changed": true,
    "destination": "/file_name",
    "item": "file_name"
}

It seems like due to the warning "idempotency check failed. Check dest" the module behaves tricky against routerOS platforms.

p.s. The executed task is:

- name: "task name"
  ansible.netcommon.net_put:
    src: "path/to/dir/{{ item }}"
    protocol: sftp
    dest: "/{{ item }}"
  loop:
    - file1
    - file2
ISSUE TYPE
  • Bug Report
COMPONENT NAME
ansible.netcommon.net_put
ANSIBLE VERSION
2.15.2
COLLECTION VERSION
Collection         Version
------------------ -------
ansible.netcommon  5.1.2
OS / ENVIRONMENT

Mikrotik, routerOS 6.48.7

ialshaev avatar Aug 16 '23 10:08 ialshaev

the same problem

vint2k avatar Aug 28 '23 09:08 vint2k

same

liquorice-head avatar Aug 29 '23 10:08 liquorice-head

I've submitted a PR; it seems that, even after the fix, protocol must be "sftp" (instead of the default "scp").

lungj avatar Oct 25 '23 18:10 lungj

Dear developers, could you take a look on the PR and decide is it OK to merge such changes into main branch? Thank you in advance!

ialshaev avatar Feb 05 '24 16:02 ialshaev