ansible copy模块复制文件或文件夹,默认是从控制机器指定目录,复制到远程机器指定目录,复制文件夹的时候需要注意点如下:
Local path to a file to copy to the remote server. This can be absolute or relative. If path is a directory, it is copied recursively. In this case, if path ends with "/", only inside contents of that directory are copied to destination. Otherwise, if it does not end with "/", the directory itself with all contents is copied. This behavior is similar to the rsync command line tool.
【如果路径是一个文件夹,它会递归copy,这种情况下,如果路径以"/" 结尾,仅有文件夹下的文件(ps:如果文件夹下还是文件夹,就copy这些文件夹,忽略的上层目录)的内容被copy到目的地址,如果不以"/" 结尾,整个文件夹被copy到远程机器】
从ansible 2.8 开始, remote_src 已经开始支持了递归copy, remote_src 意为,把远程机器上的文件【文件夹】copy 到此远程机器上的另外一个地方。
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!