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协议进行远程命令执行或 ...
随机推荐
- T-SQL 语句的理解
1.T-SQL中各子句在逻辑上按照以下顺序进行处理 . . . .. .ORDER BY 查询实例: SELECT EMPID, YEAR(ORDERDATE) AS ORDERYEAR, COUNT ...
- linux c 笔记-1
指令帮助: man xxx_command man 2 xxx_command man 3 xxx_command eg. 打开文件的函数open, 如果不清楚传参,则 man open man 2 ...
- mongodb的查询语句学习摘要
看了些资料,对应只需要知道怎么查询和使用mongodb的我来说,这些足够啦. 左边是mongodb查询语句,右边是sql语句.对照着用,挺方便. db.users.find() select * fr ...
- python logging
参考: https://docs.python.org/2/howto/logging.html#logging-basic-tutorial https://docs.python.org/2/li ...
- vim 使用
vim有三种模式:输入模式,命令模式,底行模式,使用esc进入命令模式,在命令模式下按英文的冒号,进入底行模式:命令行模式下按i进入输入模式.vim编辑文件是将文件内容复制到缓冲区显示在屏幕上. vi ...
- 程序中使用ajax时,type为put,或者delete时在 IIS上没效果,发生HTTP Error 405.0 - Method Not Allowed
其实使用put delete 是在创建webapi中基本才会使用. WebDAV 是超文本传输协议 (HTTP) 的一组扩展,为 Internet 上计算机之间的编辑和文件管理提供了标准.利用这个协 ...
- LeetCode 414 Third Maximum Number
Problem: Given a non-empty array of integers, return the third maximum number in this array. If it d ...
- 451. Sort Characters By Frequency
题目: Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Inp ...
- 多个SVG图形集成到一个SVG图形上
SVG:使用XML格式定义图像的可缩放矢量图形(Scalable Vector Graphics). 优点就不多说了,下面看看怎么将多个svg图形集成到一个svg图形上. 如果使用bootstrap框 ...
- Linux常用命令学习2---(文件搜索命令locate find、命令搜索命令whereis which、字符串搜索命令grep、帮助命令man)
1.文件搜索命令:locate [文件名] 在后台数据库中按文件名搜索,搜索速度比find快,耗费资源更少 例子:locate test.txt,就会显示文件名包含 test.txt的所 ...