Ansible常用命令


# 检查主机连接
# ansible caoguo -m ping

# 执行远程命令
# ansible caoguo -m command -a 'uptime'

# 执行主控端脚本
# ansible caoguo -m script -a '/etc/ansible/script/test.sh'

# 执行远程主机的脚本
# ansible caoguo -m shell -a 'ps aux|grep zabbix'

# 类似shell
# ansible caoguo -m raw -a "ps aux|grep zabbix|awk '{print \$2}'"

# 创建软链接
# ansible caoguo -m file -a "src=/etc/resolv.conf dest=/tmp/resolv.conf state=link"

# 删除软链接
# ansible caoguo -m file -a "path=/tmp/resolv.conf state=absent"

# 复制文件到远程服务器
# ansible caoguo -m copy -a "src=/etc/ansible/ansible.cfg dest=/tmp/ansible.cfg owner=root group=root mode=0644"


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM