首页 > 其他 > 详细

ansible常用命令20条

时间:2021-06-05 18:15:23      阅读:10      评论:0      收藏:0      [点我收藏+]

1.创建目录

ansible update -m file -a ‘path=/tmp/dd state=directory mode=0755‘ 

2.修改文件属性

ansible update -m file -a ‘path=/tmp/dd state=touch mode="u=rw,g=r,o=r"‘

3.创建软连接

ansible update -m file -a ‘src=/tmp/dd dest=/tmp/ddl owner=root group=root state=link force=yes‘

4.修改拥有者

ansible update -m file -a ‘path=/tmp/dd owner=tomcat group=root mode=0644‘

5.创建用户

ansible update -m user -a ‘name=johd‘ -become

6.删除用户

ansible update -m user -a ‘name=johd state=absent‘ -become 

7.创建秘钥

ansible update -m user -a ‘name=johd generate_ssh_key=yes ssh_key_bits=2048‘ -become  

8.创建组  

ansible test -m group -a ‘name=ansible state=present‘ -become

9.删除组 

ansible update -m group -a ‘name=pig state=absent‘ -become

10.下载文件的远程服务器

ansible update -m get_url -a ‘url=http://www.baidu.com dest=/tmp/baidu.txt mode=0777‘

11.增加一个cron任务  

ansible update -m cron -a "backup=yes name=‘test cron‘ minute=*/2 hour=* job=‘ls /tmp >/dev/null‘"

12.安装服务

ansible update -m yum -a ‘name=httpd state=prestent‘ -become

13.停止httpd

ansible update -m service -a ‘name=httpd state=stopped‘

14.重启httpd

ansible update -m service -a ‘name=httpd state=restarted‘

15.修改sysctl文件

ansible update -m sysctl -a ‘name=vm.overcommit_memory value=1‘ -become

16.挂载/dev/vda盘到/mnt/data目录

ansible update -m mount -a ‘name=/mnt/data src=/dev/vda fstype=ext4 state=mounted‘

17.远程查看内存

ansible Client -m command -a "free -m "

18.远程执行脚本 

 ansible Client -m script -a "/home/test.sh"

19.实现主控端向目标主机拷贝文件  

ansible Client -m copy -a "src=/root/rcp dest=/backup/" 

20.yum安装  

ansible Client -m yum -a "name=htop state=latest"

 

ansible常用命令20条

原文:https://www.cnblogs.com/lucktomato/p/14852359.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!