ansible.netcommon
ansible.netcommon copied to clipboard
net_put for uploading files on routerOS
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
the same problem
same
I've submitted a PR; it seems that, even after the fix, protocol
must be "sftp"
(instead of the default "scp"
).
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!