当前位置:网站首页>ansible copy 模块
ansible copy 模块
2022-08-06 01:45:00 【Direct_】
文章目录
copy 模块
主要用于将管理主机上的数据信息拷贝给多台主机
官方文档:https://docs.ansible.com/ansible/latest/modules/copy_module.html#copy-module
参数 | 选项默认值 | 说明 |
---|---|---|
src | 指定将本地管理主机的数据信息进行远程复制 | |
backup | no* yes | 默认数据复制到远程主机,会覆盖原有文件(yes 将源文件进行备份) |
content | 在文件中添加信息 | |
dest(required) | 将数据复制到远程节点的路径信息 | |
group | 文件数据复制到远程主机,设置文件属组用户信息 | |
mode | 文件数据复制到远程主机,设置数据的权限 eg 0644 0755 | |
owner | 文件数据复制到远程主机,设置文件属主用户信息 | |
remote_src | no* yes | 如果设置为yes,表示将远程主机上的数据进行移动操作。如果设置为no, 表示将管理主机上的数据进行分发操作 |
注:(required)为必须使用的参数为默认参数,copy模块在复制数据时,如果数据为软链接文件,会将链接指定源文件进行复制
修改权限时候 需要加0 例如:chmod 0644 0755
示例:
- 将本地 test.txt 文件拷贝到远程机器上,并修改文件用户(
owner
)、权限(mode
),将原本目录下存在的同名文件备份(backup
),如果文件内容相同则不会备份
[[email protected] ~]# ansible dong -m copy -a "src=/root/test.txt dest=/root owner=dong group=dong mode=600 backup=yes"
参数解析:
src=/root/test.txt 本地文件路径
dest=/root 远程服务器文件路径
owner=dong 用户
group=dong 用户组
mode=600 设置权限
backup=yes 是否备份(yes是备份,no是不备份,同名文件,内容不同则备份)
- content 指定内容,并生成目标文件
ansible dong -m copy -a "content='test line1\ntest lin2' dest=/root/123.txt"
参数解析:
content 添加文件内容,将内容写入远程机器文件
dest 定义远程服务器文件路径
边栏推荐
猜你喜欢
关于近期轻量化部署任务的一个小结
typescript73 - create your own type declaration files (shared types within the project)
PyTorch笔记 - Attention Is All You Need (4)
STP实验
Nacos安装指南
typescript74 - create your own type declaration files (provide declaration files for existing js)
海康联网网关平台级联EasyCVR出现通道无法上线现象,是什么原因?
方法区、永久代、元空间
Compose Advanced Challenge is here!Live Preview|August 7th at 19:30 pm face to face with GDE instructor
OpenWrt之Kernel version hash 的那些事
随机推荐
deque(双端数组)——STL
(状压dp)最短Hamilton路径
typescript69 - type declaration file overview
Live playback including PPT download | Build Online Deep Learning based on Flink & DeepRec
EasyCVR通过进程启动无报错,但是自动退出该如何解决?
【报错已解决】com.alibaba.fastjson.JSONException: syntax error, expect {, actual [, pos 0
【回顾】基于树莓派下的4G模块(EC200U-CN)实现远程控制短信的收发
Nacos安装指南
DAY24:信息搜集
使用MySQL截取JSON串,结果为null
SSH-KeyGen - Authentication key generation, management and conversion
codeforces 4A.watermelon
学生违规使用数据库致学校IP永久被封
【hiflow】-- 腾讯云场景连接器实现定时查询疫情信息
MVCC interview questions
阿里云技术专家郝晨栋:云上可观测能力,问题的发现与定位实践
OpenWrt之feeds.conf.default详解
History and Development of Character Encodings (ASCII, GBK, Unicode)
linux下mysql cpu占用过高问题查找思路
现货白银分析原来就这么简单