ansible基础 命令
ansible基础命令:
1.远程执行命令
ansible 组名 -m command -a "命令"

2.文件拷贝
ansible ip -m copy -a "src=/etc/passwd dest=/tmp/123"

3.ansible远程执行脚本
cat /tmp/test.sh #!/bin/bash echo `date` > /tmp/ansible_test.txt ansible testhost -m copy -a "src=/tmp/test.sh dest=/tmp/test.sh mode=0755"



4.ansible任务管理计划
ansible testhost -m cron -a "name='test cron' job='/bin/bash /tmp/test.sh' weekday=6"

若要删除该cron只需要加一个字段state=absent。
ansible testhost -m cron -a "name='test cron' state=absent"

5. Ansible安装RPM包/管理服务
ansible testhost -m yum -a "name=包名"


什么才是真正的Think Different?

浙公网安备 33010602011771号