yum -y install epel-release
yum -y install ansible
ssh-keygen -t rsa -f /root/.ssh/id_rsa -N ''
ls /root/.ssh
id_rsa id_rsa.pub
ssh-copy-id 81.68.100.55
ls /root/.ssh
ssh 81.68.100.55
vim /etc/ansible/hosts
ansible 81.68.100.55 -m ping
ntpdate time1.aliyun.com
yum -y install ntpdate
yum -y install ntpdate
crontab -l
ansible 81.68.100.55 -m cron -a 'name="test cron1" job="ntpdate time1.aliyun.com" minute=0 hour=*/'
ansible 81.68.100.55 -m cron -a 'name="test cron1" job="ntpdate time1.aliyun.com" minute=0 hour=*/1'
crontab -l
crontab -l
cat /etc/ansible/hosts
vi /etc/hosts
cat /etc/hosts
ansible 81.68.100.55 -m copy -a 'src=/etc/hosts dest=/etc/hosts
ansible all --list-hosts
1、下载文件到指定目录:
ansible all -m get_url -a "url=http://www.guojinbao.com dest=/tmp/guojinbao mode=0440 force=yes"
需要添加登录名密码的网站,使用url_password、url_username参数来定义
2、解压ansible管理机上的压缩文件到远程主机:
ansible all -m unarchive -a "src=/tmp/install/zabbix-3.0.4.tar.gz dest=/tmp/ mode=0755 copy=yes"
3、解压远程主机上的文件到目录:
ansible all -m unarchive -a "src=/tmp/install/zabbix-3.0.4.tar.gz dest=/tmp/ mode=0755 copy=no"