我正在尝试将大文件集(100个)复制到我的远程服务器。然而,使用'copy‘命令这个任务需要相当长的时间。稍微搜索一下,我就知道‘同步’是一个很好的选择。不幸的是,我当前的远程服务器没有'rsync‘,所以我也不能使用'synchronize’选项。
作为一种变通办法,我想在ansible主机中压缩文件夹,然后使用“unarchive”模块将其传输到远程服务器。
- name: Archive the folder
shell: zip <dest-zip-path> <path-to-folder>
delegate_to: local
我需要检查本地主机上的一个文件(/tmp/test.html),如果它存在,执行其他任务。请您帮助在localhost(工作站)中运行这个第一个任务(名称:检查、存在和复制)。
本地主机:工作站远程主机: servera,ser谓词
下面是我的playbook.yml
---
- name: Check exist and copy
hosts: all
tasks:
- name: check if file is exists #need to execute this task in workstation
stat:
path: /tmp/test.ht