- -a 后加模块的参数, 最好使用单引号,因为双引号会有部分命令执行不了
-
ping
ansible all -m ping -
command , 可以省略
ansible all -m command -a "ls /tmp" -
shell
ansible all -m shell -a " ls /tmp" -
script 脚本在本机编写即可
ansible k8s -u root -m script -a './test.sh' -
copy
复制本地文件到远端机器
ansible k8s -u root -m copy -a 'src=./tmp/selinux dest=/etc/selinux/config backup=yes'
拷贝本地文件到远端机器,并设置权限mode 属主owner
ansible k8s -u root -m copy -a 'src=./tmp/test.sh dest=/data/ mode=000 owner=ftp' -
hostname 修改主机名
ansible 172.16.6.190 -u root -m hostname -a 'name=test' -
cron,
设置计划任务
ansible 172.16.6.190 -u root -m cron -a 'minute=* weekday=1,3,5 job="/bin/echo 111" name=test
取消计划任务
ansible 172.16.6.190 -u root -m cron -a 'disabled=true job="/bin/echo 111" name=test'
网友评论