建设一个旅游网站必备的,龙湖镇华南城网站建设,软件开发项目报价模板,河南平价的seo整站优化定制ansible特点#xff1a;不需要安装客户端#xff0c;通过sshd去通信基于模块工作#xff0c;模块可以由任何语言开发不仅支持命令行使用模块#xff0c;也支持编写yaml格式的playbook支持sudo安装#xff1a;yum install -y epel-releaseyum install -y ansible 配置文件不需要安装客户端通过sshd去通信基于模块工作模块可以由任何语言开发不仅支持命令行使用模块也支持编写yaml格式的playbook支持sudo安装yum install -y epel-releaseyum install -y ansible 配置文件vi /etc/ansible/hosts //增加[test]127.0.0.1 ansible_ssh_userroot ansible_ssh_port22 ansible_ssh_pass123456zhan-02 ansible_ssh_userroot ansible_ssh_port22 ansible_ssh_pass123456 ansible执行远程命令cd /etc/ansibleansible test -m command -a who[rootzhan-01 ansible]# ansible test -m command -a whozhan-02 | SUCCESS | rc0 root pts/0 2018-02-03 16:00 (192.168.88.123)root pts/1 2018-02-03 16:19 (192.168.88.123)root pts/2 2018-02-03 17:45 (zhan-01) 127.0.0.1 | SUCCESS | rc0 root pts/0 2018-02-03 16:00 (192.168.88.123)root pts/1 2018-02-03 08:19 (192.168.88.123)root pts/4 2018-02-03 09:45 (localhost) test为主机组名-m后边是模块名字-a后面是命令。当然我们也可以直接写一个ip针对某一台机器来执行命令。 执行单个主机命令ansible 127.0.0.1 -m command -a hostname127.0.0.1 | SUCCESS | rc0 zhan-01 ansible 取消交互去除ssh无交互添加known_hosts配置文件在/etc/ansible/ansible.cfg打开下面注释host_key_checking False 取消ssh的yes和no的交互修改/etc/ssh/ssh_config文件或$HOME/.ssh/config中的配置添加如下两行配置一般为StrictHostKeyChecking ask可改为StrictHostKeyChecking noUserKnownHostsFile /dev/null修改好配置后重新启动sshd服务即可命令为/etc/init.d/sshd restart 或 service sshd restart 转载于:https://www.cnblogs.com/pythonlx/p/8408680.html