ansible ad-hoc 参考
2024-10-01 00:57:44
# 检查主机连接
# ansible test -m ping
# 执行远程命令
# ansible test -m command -a 'uptime'
# 执行主控端脚本
# ansible test -m script -a '/etc/ansible/script/test.sh'
# 执行远程主机的脚本
# ansible test -m shell -a 'ps aux|grep zabbix'
# 类似shell
# ansible test -m raw -a "ps aux|grep zabbix|awk '{print \$2}'"
# 创建软链接
# ansible test -m file -a "src=/etc/resolv.conf dest=/tmp/resolv.conf state=link"
# 删除软链接
# ansible test -m file -a "path=/tmp/resolv.conf state=absent"
# 复制文件到远程服务器
# ansible test -m copy -a "src=/etc/ansible/ansible.cfg dest=/tmp/ansible.cfg owner=root group=root mode=0644"
# 指定主机
#ansible -i /etc/ansible/hosts all -m copy -a "src=test.conf dest=/etc/test.conf owner=root group=root mode=0644"
#确保一个包已经安装,但是不进行update操作
#ansible webservers -m yum -a "name=acme state=installed"
#查看已经安装了指定版本的软件包
#ansible webservers -m yum -a "name=acme-1.5 state=installed"
#查看安装软件包是否为最新版本
#ansible webservers -m yum -a "name=acme state=latest"
#确保一个软件包是没有安装的
#ansible webservers -m yum -a “name=acme state=removed" #'user'模块可以方便的创建或者操作一个用户帐号,同样的也可以删除一个用户
#ansible all -m user -a "name=test password=<abc>"
#ansible all -m user -a "name=test state=absent"
#确定服务都是开启的
#ansible all -m service -a "name=httpd state=started"
#重启服务
#ansibel all -m service -a "name=httpd state=restarted"
#关闭服务
#ansible all -m service -a "name=httpd state=stoped"
#get_url从服务器上下载一个文件到远程主机指定的目录
#ansible webservers -m get_url -a "url='http://baidu.com dest=/tmp/ba.html" #setup收集远程服务器信息
#ansible all -m setup
最新文章
- KNN算法
- rcnn学习(六):imdb.py学习
- wamp虚拟主机的配置 .
- Android BlueDroid(一):BlueDroid概述 【转】
- HDU 4336:Card Collector(容斥原理)
- excel的常用公式
- java中的IO整理
- oralce 函数 FOR windows 跟踪神器
- Linux操作系统安装Nvidia显卡驱动
- SCJP_104——题目分析(4)
- Jexus下配置多个站点
- ListView列表项
- 巧妙使用Firebug插件,快速监控网站打开缓慢的原因
- Asp.Net+Easyui实现重大CRUD
- v9手机版文章内容不显示
- php-迭代创建级联目录
- [Swift]LeetCode767. 重构字符串 | Reorganize String
- pythonのsimple_tag
- Oracle的条件in包含NULL时的处理
- Qt对`vtable的未定义引用