标签:ice 重启 service 目录 主机名 name 删除 latest art
1、/etc/ansible/hosts 文件配置如下:
[group01] //ubuntu16 jumper ansible_ssh_port=6666 ansible_ssh_host=172.16.1.206 172.16.1.207 [group01] //centos7 172.16.1.201
2、远程重启服务
sudo ansible group01 –m service –a “name=ssh state=restarted”
3、查看远程主机名
sudo ansible group01 –m command –a “hostname”
4、复制文件
sudo ansible group01 -m copy –a “src=/home/test.txt dest=/tmp owner=root group=root mode=0755”
5、下载文件到远程主机的指定目录
sudo ansible group01 –m get_url –a “url=http://www.baidu.com dest=/tmp mode=0440 force=yes”
6、linux平台安装软件
sudo ansible group01 –m apt –a “pkg=tree state=latest” //ubuntu安装 sudo ansible group02 –m yum –a “name=tree state=latest” //centos安装
7、cron模块
sudo ansible group01 –m cron –a ”name=’check dirs’ hour=’5,2’ job=’ls -al’”
8、mount模块:远程主机挂载硬盘
sudo ansible group01 –m mount –a “name=/mnt/data src=/dev/sd0 fstype=ext4 opts=ro state=present”
9、user模块
# 添加用户
sudo ansible group01 –m user –a “name=jeff comment=’Jefflee’”
# 删除用户
sudo ansible group01 –m user –a “name=jeff state=absent remove=yes”
标签:ice 重启 service 目录 主机名 name 删除 latest art
原文地址:http://www.cnblogs.com/jefflee168/p/7340631.html