Ansible远程执行脚本示例
首先创建一个shell脚本
cat /tmp/df.sh
#!/bin/bash df -h|grep vda|awk '{print $5}'
然后把该脚本分发到各个机器上
ansible compass -m copy -a "src=/tmp/df.sh dest=/tmp/df.sh mode=0755"
最后是批量执行该shell脚本
ansible compass -m shell -a "/tmp/df.sh"|more
执行效果如下:
[root@weifengansible]# ansible compass -m shell -a "/tmp/df.sh"|more
192.168.0.185 | SUCCESS | rc= >>
%
192.168.0.191 | SUCCESS | rc= >>
%
192.168.0.188 | SUCCESS | rc= >>
%
192.168.0.190 | SUCCESS | rc= >>
%
192.168.0.186 | SUCCESS | rc= >>
%
192.168.0.189 | SUCCESS | rc= >>
%
192.168.0.196 | SUCCESS | rc= >>
%
192.168.0.195 | SUCCESS | rc= >>
Ansible远程执行脚本示例的更多相关文章
- Ansible 远程执行脚本
1. 先在服务端创建一个 shell 脚本 [root@localhost ~]$ cat /tmp/test.sh #!/bin/bash echo "hello world" ...
- Linux centosVMware 自动化运维Ansible介绍、Ansible安装、远程执行命令、拷贝文件或者目录、远程执行脚本、管理任务计划、安装rpm包/管理服务、 playbook的使用、 playbook中的循环、 playbook中的条件判断、 playbook中的handlers、playbook实战-nginx安装、管理配置文件
一.Ansible介绍 不需要安装客户端,通过sshd去通信 基于模块工作,模块可以由任何语言开发 不仅支持命令行使用模块,也支持编写yaml格式的playbook,易于编写和阅读 安装十分简单,ce ...
- Linux远程无密码登陆并远程执行脚本
假设 A (192.168.20.59)为客户机器,B(192.168.20.60)为目标机: 要达到的目的: A机器ssh登录B机器无需输入密码: 加密方式选 rsa|dsa均可以,默认dsa ss ...
- SSH非交互式密码授权远程执行脚本
公司有上百台服务器,需要为每台服务器都执行一个脚本,因为所有服务器的账号密码都是一样的,所以可以不用搭建ansible等自动化运维工具,我们直接通过SSH远程执行即可完成. 本文以三台服务器为例,系统 ...
- SSH 无密码远程执行脚本
ssh无密码登录及远程执行脚本要使用公钥与私钥.linux下可以用用ssh-keygen生成公钥/私钥对,下面我以CentOS7为例. 测试环境:机器A(10.0.224.80):机器B(192.16 ...
- jenkins远程执行脚本时报Bad version number in .class file
这几天在学习jenkins的持续集成和部署,到了最后一步启动服务的时候,遇到了一个这个Bad version number in .class file的报错(如下图). 这个报错在最开始手工部署的时 ...
- JSch远程执行脚本
JSch远程执行脚本 2017-02-24 在自动化测试的时候,需要远程操控服务器做一些操作,比如切日.起服务器.执行某些脚本.如何实现? 我们可以利用JSch,远程执行脚本.JSch是Java Se ...
- ansible 远程执行时提示 command not found 问题
问题 最近在学习 ansible ,在使用普通用户远程执行 ip a 命令是发现提示错误:/bin/sh: ip: command not found. 原因 command not found 命令 ...
- Ansible 远程执行命令
写法如下: [root@localhost ~]$ ansible 192.168.119.134 -m command -a 'date' # 对指定的主机远程执行命令,-m 指定使用哪个模块,-a ...
随机推荐
- 【贪心】【堆】Gym - 101128C - Canvas Painting
一些画布,每块有其大小,一开始都是白的,你任意将它们排序,然后一次操作可以选择一段连续的相同颜色的画布,从中任选一个位置,左侧涂上任意一种颜色,右侧涂上另一种.消耗是这一段画布的总的大小.问你要将所有 ...
- ConcurrentHashMap(Java8)源码分析
1. 常量.成员变量 private static final int MAXIMUM_CAPACITY = 1 << 30; // 和HashMap一样 private static f ...
- Codeforces Round #344 (Div. 2) A. Interview 水题
A. Interview 题目连接: http://www.codeforces.com/contest/631/problem/A Description Blake is a CEO of a l ...
- RSA加密破解
1Linux 下安装gmpy2 https://www.cnblogs.com/ESHLkangi/p/8576113.html 2.yafu安装使用方法 https://www.cnblogs.co ...
- (转)DLL中导出函数的两种方式(dllexport与.def文件)
DLL中导出函数的两种方式(dllexport与.def文件)http://www.cnblogs.com/enterBeijingThreetimes/archive/2010/08/04/1792 ...
- virtualbox4.2.18 ubuntu12.04 The system is running in low-graphics mode
参考1:http://askubuntu.com/questions/225090/the-system-is-running-in-low-graphics-mode-error-in-virtua ...
- leetCode(45):Min Stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. pu ...
- [转]Oracle connection strings
本文转自:http://www.connectionstrings.com/oracle/ Standard Data Source=MyOracleDB;Integrated Security=ye ...
- dcmtk dcmmkdir 使用帮助
例子: dcmmkdir --recurse --input-directory C:\TEMP DICOM --output-file C:\TEMP\DCMDIR --recurse 递归 -- ...
- all-oone-data-structure(好)
哈哈,我用了HashMap, 双向链表,还有了HashSet来保存key的集合. 现在这道题目还只有 9.3%的AC率,难度为HardTotal Accepted: 9 Total Submissio ...