💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
1.测试连通性 [root@ansible ~]#ansible storm_cluster -m ping 2.批量发布远程命令 [root@ansible ~]#ansible storm_cluster -m command -a 'uptime' 3.复制文件到远程主机 [root@ansible ~]#ansible storm_cluster -m copy -a "src=/etc/ansible/ansible.cfg dest=/tmp/ansible.cfg owner=root group=root mode=0644" src为本地文件路径,dest为目标主机存放路径 4.远程重启服务 [root@ansible ~]#ansiblestorm_cluste -m service -a "name=nginx state=restarted" name是服务名称 state是执行的操作,有: started\stopped\restarted 5.远程执行shell脚本 ##将创建的脚本文件分发到远程 #ansible storm_cluster -m copy -a "src=/tmp/test.sh dest=/tmp/test.sh owner=root group=root mode=0755" ##远程执行 #ansible storm_cluster -m shell -a "/tmp/test.sh" 6、指定主机列表 ansible -i /etc/ansible/root_201_total root_201_total -m copy -a "src=/etc/profile dest=/etc/profile owner=root group=root mode=0644" 7、批量yum安装服务 安装服务: ansible test -m yum -a "name=httpd state=latest" 卸载服务: ansible test -m yum -a "name=httpd state=absent" 安装新版gcc: yum: name={{ item }} state=present with_items: - gcc - redhat-lsb-core - openssh-server - openssh-clients - python-devel - lrzsz - yum-utils