ansible-copy
ansible是执行yaml文件控制远端服务器。
执行命令为 ansible-playbook my.yaml
playbook是ansible中的脚本,采用yaml语言。
VM1安装ansible,ip地址为172.125.1.20
VM2为一个新创建的虚拟机,ip地址为172.125.1.30.
VM1可以无密码ssh+root登录到VM2.
任务:将VM1安装的epel.repo文件copy到VM2中。
1)源文件设置
创建目录ansible-test(名称根据自己的需求修改)
cd ansible-test
创建目录files(固定名称)
copy /etc/yum.repos.d/epel.repo files/
2)增加VM2到hosts中
vi /etc/ansible/hosts
添加[VM2]
在【VM2】下面增加VM2 ip:172.125.1.30
3)编辑yaml文件:
- name: copy epel files toVM2
hosts: VM2
tasks:
- name: copy files
copy: src=epel.repo dest=/etc/yum.repos.d owner=root group=root mode=0644
运行:
ansible-playbook copyepel.yaml
[root@localhost ansible_test]# ansible-playbook copyepel_v1.yaml
PLAY [copy epel files to /var/tmp] *********************************************
TASK [setup] *******************************************************************
ok: [172.125.1.30]
TASK [copy files] **************************************************************
changed: [172.125.1.30]
PLAY RECAP *********************************************************************
172.125.1.30 : ok=2 changed=1 unreachable=0 failed=0
登录到VM2
cd /etc/yum.repos.d
epel.repo已经存在该目录下。说明ansible运行成功。
下一个文章中我们探讨一下template的使用
ansible-copy的更多相关文章
- ansible copy 模块的使用
copy copy 模块是将 ansible 管理主机上的文件拷贝上远程主机中,与 fetch 相反,如果目标路径不存在,则自动创建,如果 src 的目录带“/” 则复制该目录下的所有东西,如果 sr ...
- ansible copy 模块详解
ansible 模块 copy one.概述 copy 模块的作用就是拷贝文件,它与之前介绍过的 fetch 模块类似,不过,fetch 模块是从远程主机中拉取文件到 ansible 管理主机,而 c ...
- ansible copy file
ansible xxxip -m copy -a 'src=/localdir/file dest=/sss/xxx/basic_search/bin/'
- ansible copy 模块 changed false 没有变化
在分发配置文件的时候,我用命令ansible big_hosthub -m copy -a "src=/home/clouder/deploy-conf.xml dest=/home/cl ...
- ansible copy文件比较慢, 使用Synchronize模块
Ansible中的同步模块(rsync) Synchronize模块 1 2 3 4 5 6 7 This is a wrapper around rsync. Of course you cou ...
- ansible 自动化(1)
安装篇: yum安装 1.安装第三方epel源 centos 6的epel rpm -ivh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-rel ...
- ansible 安装使用
ansible ansible源码安装 yum -y install python-jinja2 PyPAML python-parmiko python-babel python-crypto ta ...
- Ansible系列(二):选项和常用模块
html { font-family: sans-serif } body { margin: 0 } article,aside,details,figcaption,figure,footer,h ...
- Ansible工具原理一
ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet.cfengine.chef.func.fabric)的优点,实现了批量系统配置.批量程序部署.批量运行命 ...
- devops工具-Ansible基础
一.Ansible介绍 简介 Ansible使用Python语言开发,是一个配置管理型工具,与之类似的工具还有Puppet.SaltStack.chef等,默认通过SSH协议进行远程命令执行或 ...
随机推荐
- hibernate中数据库方言
在配置hibernate.cfg.xml时需指定使用数据库的方言: 例: <property name="dialect">org.hibernate.dialect. ...
- oracle查询某一个字段的数量总和
select count(*) from (select count(*) from 表名称 group by 多种数据量 ) 表名; 举个栗子: 比如说我有一个数据类型的字段, 里面有很多种的数据类 ...
- Redis Cluster搭建方法简介22211111
Redis Cluster搭建方法简介 (2013-05-29 17:08:57) 转载▼ Redis Cluster即Redis的分布式版本,将是Redis继支持Lua脚本之后的又一重磅 ...
- windows7 启用管理员账户
在虚拟机中安装了windows7,方便使用qq,使用百度云,office等常用的软件.虚拟机使用的oracle的VirtualBox,个人使用体验不错,最棒的功能是能将物理机中的磁盘映射到虚拟机中网络 ...
- SQL查询语句行转列横向显示
http://blog.163.com/dreamman_yx/blog/static/26526894201121595846270/
- WebView基本使用
WebView mWebView; ProgressBar mProgressBar; mProgressBar = (ProgressBar) findViewById(R.id.news_prog ...
- [leetcode] 题型整理之排序
75. Sort Colors Given an array with n objects colored red, white or blue, sort them so that objects ...
- /var/run/yum.pid 已被锁定,PID 为 XXXX 的另一个程序正在运行。
安装st-load时, 终端提示 “/var/run/yum.pid 已被锁定,PID 为 13908 的另一个程序正在运行.” 解决方法:直接在终端运行 rm -f /var/run/yum.pid ...
- html学习第二天—— 第七章——CSS样式基本知识
外部式css样式,写在单独的一个文件中外部式css样式(也可称为外联式)就是把css代码写一个单独的外部文件中,这个css样式文件以“.css”为扩展名,在<head>内(不是在<s ...
- BFC的深入理解
一:BFC是什么东东 了解BFC前先一了解一下Box和Formatting Context (1)B: BOX即盒子,页面的基本构成元素.分为 inline . block 和 run-in 三种类型 ...