Ansible运维手册

模块应用

远程命令模块

ansible dbserver -m command -a "ls /"
ansible dbserver -m script -a "ats.sh start"
ansible dbserver -m shell -a "ats.sh"

复制模块

ansible dbserver -m copy -a "src=/1.txt dest=/data/  owner=root  group=root  mode=777"

查看文件状态模块

ansible dbserver -m stat -a "path=/data/1.txt"

URL下载模块

ansible dbserver -m get_url -a "url=http://letong.me   dest=/data/  mode=777  force=yes"

yum模块

ansible dbserver -m yum -a "name=git state=latest"

service模块

ansible dbserver -m service -a "name=httpd state=restarted"

user模块

ansible dbserver -m user -a "name=letong comment='Hello letong' "
ansible dbserver -m user -a "name=letong state=absent  remove=yes"

mount模块

ansible dbserver -m mount -a "name=/data  src=/dev/sdb1  fstype=ext4  opts=ro  state=present"

cron模块

ansible ts -m cron -a "name='ls dir'  hour='5,2'  job='ls -l'"