copy 模块:
tasks:
- name: Copy ansible inventory file to client
copy: src=/etc/ansible/hosts dest=/etc/ansible/hosts
owner=root group=root mode=0644
[root@node01 ansible]# cat playbook.yml
- hosts: database
tasks:
- name: Copy ansible inventory file to client
copy: src=/etc/ansible/hosts dest=/etc/ansible/hosts
owner=mqm group=mqm mode=777
[root@node01 ansible]# ansible-playbook playbook.yml
[DEPRECATION WARNING]: DEFAULT_SUDO_USER option, In favor of become which is a generic framework . This feature will be removed in version 2.8. Deprecation warnings can be disabled by
setting deprecation_warnings=False in ansible.cfg.
PLAY [database] *******************************************************************************************************************************************************************************
TASK [Gathering Facts] ************************************************************************************************************************************************************************
ok: [192.168.137.3]
TASK [Copy ansible inventory file to client] **************************************************************************************************************************************************
changed: [192.168.137.3]
PLAY RECAP ************************************************************************************************************************************************************************************
192.168.137.3 : ok=2 changed=1 unreachable=0 failed=0
[root@node01 ansible]#
查看192.168.137.3 上的文件:
node2:/etc/ansible#ls -ltr
total 4
-rwxrwxrwx 1 mqm mqm 84 Oct 11 00:15 hosts
node2:/etc/ansible#
ansible copy模块
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
上一篇:ansible 配置变量
下一篇:ansible 批量重启服务
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
ansible模块--copy模块
将主控端的文件复制到远程主机,只针对文件src 源文件路径dest 目标文件路径content 将指定内容覆盖写入到目标主机文件中force=no 当主控端拷贝的文件名和目标名一
linux python java mysql centos -
ansible 常用模块 copy
模块说明 该copy模块将文件从本地或远程机器复制到远程机器上的某个位置
Ansible 文件系统 字符串 -
【Ansible】 Ansible工具copy模块的使用
对路径。如果src是一个目录,des...
python 本地文件 绝对路径 -
ansible之copy模块测试
ansible之copy模块测试
ansible copy 模块测试 -
ansible copy模块考题 ansible -m copy
背景ad-hoc ,通过一次执行一行命令,可以实现简单的文件管理、软件包管理、服务管理等;但是如果想要多次执行一个任务,或者一次执行多个任务,那么 ad-hoc 就显得有点繁琐和力不从心了,这时候就轮到 Playbook 登场了。Playbook 是由 yml 语法书写,结构清晰,可读性强,可以简单将其理解为一门编程语言(本身具有变量、分支、循环、监听器的概念)。在一个 Playbook 中可以包
ansible copy模块考题 Playbook Ansible安装JDK Ansible部署Boot项目 ad-hoc -
ansible 安装 copy模块 ansible的copy
今天,我们开始学习运维自动化工具Ansible。一、Ansible原理1.1 什么是AnsibleAnsible一种集成IT系统的配置管理、应用部署、执行特定任务的开源平台/框架。基于Python语言实现,核心模块包括:jinja2、PyYAML和paramiko。Ansible允许重复执行而不出错,客户端无agent,服务端无deamon进程。Ansible特点:Ansible支持
ansible 安装 copy模块 ansible copy模块 ansible file模块 ansible 修改文件变量 ansible安装部署