Ansible常用命令--运维工作记录

yum install -y python-setuptools python-setuptools-devel

easy_install pip

pip install ansible
  • 测试连通性

    ansible web -m ping -o
  • 执行shell语句

    ansible web -m shell -a "hostname"
  • 下发文件

    ansible web -m copy -a 'src=a.test dest=/root/a.test owner=root group=root mode=644 backup=yes'
  • 包和服务管理

    ansible web -m yum -a 'name=httpd state=latest' -f 5 -o
  • 用户管理

echo ansible | openssl passwd -1 stdin
[root@console ~]# $1$LT8KCvCG$meIJy2/Ns2KAGmD5IZfkW0


ansible web -m user -a 'name=shencan password="$1$LT8KCvCG$meIJy2/Ns2KAGmD5IZfkW0"' -f 5 -o
ssh < IP > -l shencan
添加新评论