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

相關文章
相關標籤/搜索