Ansible经常使用命令

# 检查主机链接
# ansible caoguo -m pingshell

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

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

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

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

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

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

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

相关文章
相关标签/搜索