ansible常用指令
vi /etc/ansible/hosts [rancher-host] 30.93.73.92 30.93.73.93 30.93.73.91 30.93.73.104 30.93.73.102
[kafka] 192.168.163.129 ansible_ssh_user=root ansible_ssh_pass=liumiao
ansible rancher-host -m copy -a "src=/etc/del-dockerlogs.sh dest=/etc/del-dockerlogs.sh" #将本地的文件拷贝到指定hosts的服务器上 ansible rancher-host -m shell -a "chmod +x /etc/del-dockerlogs.sh" #指定hosts机器执行命令 ansible rancher-host -m shell -a 'echo "01 00 * * * root /etc/del-dockerlogs.sh" >> /etc/crontab' #指定文件插入内容 ansible pythonserver -m file -a "path=/tmp/kel state=directory mode=0755" #创建目录 ansible all -m ping -u bruce # 检查所有的远程主机,是否以bruce用户创建了ansible主机可以访问的环境。 |