ibmi_sync_files – Synchronize a list of files from current IBM i node A to another IBM i node B.
Synopsis
The
ibmi_sync_files
module synchronize a list of files from current IBM i node to another IBM i node.Only supports SAVF(.file) and MBR(only supports “database” subtype Physical files(PF-DTA attribute)) format synchronize between QSYS and QSYS.
Parameters
- dest
Path on the destination host that will be synchronized from the source.
The path must be absolute.
If specify, all the src files will be synchronized to the directory that dest speicified. Individual dest key in src_list will be ignored.
If not specify, individual dest will be the dest value inputted in src_list.
If both dest and dest key in src_list are not specify, individual dest will be equal to individual src in src_list.
Example ‘/test/dir/’
required: falsetype: str- private_key
Specifies SSH private key used to connect to remote IBM i host.
The path can be absolute or relative.
required: falsetype: pathdefault: ~/.ssh/id_rsa- remote_host
The remote IBM i node address.
Can be IP or host name.
required: Truetype: str- remote_user
The user name to connect to the remote IBM i node.
required: Truetype: str- src_list
src files information list on the source host.
Evey src_list element should be a dict. dict can contain ‘src’ and ‘dest’. ‘dest’ is optional.
The src key is the path to the src, and must be absolute.
The dest key is the path on the destination host that will be synchronized from the source.
required: Truetype: listelements: dict
Examples
- name: Synchronize a list of different types of files to host.com.
ibm.power_ibmi.ibmi_sync_files:
src_list:
- {'src': '/tmp/c1.file', 'dest': '/qsys.lib/test.lib/'}
- {'src': '/qsys.lib/test.lib/test.file', 'dest': '/qsys.lib/test.lib'}
- {'src': '/tmp/c2.SAVF', 'dest': '/qsys.lib/test.lib/'}
- {'src': '/tmp/c3.bin', 'dest': '/test/dir'}
- {'src': '/qsys.lib/c4.file/test.mbr', 'dest': '/qsys.lib/test.lib/c5.file'}
- {'src': '~/c6.txt', 'dest': '~/testfolder'}
remote_host: 'host.com'
remote_user: 'user'
private_key: '/home/test/id_rsa'
Notes
Note
Need install paramiko package on target IBM i.
Make sure ssh passwordless login works from IBM i node A to IBM i node B.
private_key must be a rsa key in the legacy PEM private key format.
Dependency PTFs 7.2 MF65149 7.3 MF65148
Doesn’t support IASP by now.
Return Values
- delta
The execution delta time.returned: alwaystype: strsample: 0:00:00.307534- stdout
The standard output.returned: alwaystype: strsample: Complete synchronize file list to remote host host.com- stderr
The standard error.returned: alwaystype: strsample: Exception. not a valid RSA private key file. Use -vvv for more information.- rc
The action return code. 0 means success.returned: alwaystype: intsample: 255- msg
The general message returned.returned: alwaystype: strsample: No files were successfully transferred.- success_list
The success transferred list.returned: alwaystype: listsample:[{"dest": "/qsys.lib/fish.lib/", "src": "/tmp/c1.file"}, {"dest": "/qsys.lib/fish.lib/", "src": "/tmp/c2.SAVF"}, {"src": "/tmp/c3.log"}]- fail_list
The fail transferred list.returned: alwaystype: listsample:[{"dest": "/qsys.lib/fish.lib/", "fail_reason": "Can\u0027t sync file to /QSYS.LIB", "src": "/qsys.lib/fish.lib/test.file"}, {"dest": "/qsys.lib/fish.lib/", "fail_reason": "src /qsys.lib/fish.lib/test.file doesn\u0027t exist.", "src": "/tmp/c4.SAVF"}]- stdout_lines
The standard output split in lines.returned: alwaystype: listsample:["Complete synchronize file list to remote host host.com"]- stderr_lines
The standard error split in lines.returned: alwaystype: listsample:["Exception. not a valid RSA private key file. Use -vvv for more information."]