#生成密钥,默认回车即可ssh-keygen#拷贝密钥至主机ssh-copy-id root@192.168.47.135ssh-copy-id root@192.168.47.136cd /root/.SSHcat id_rsa.pub > authorized_keysvi /etc/ansible/hosts[test]192.168.47.134192.168.47.135192.168.47.136yum -y install epel-release.noarchyum -y install treeyum -y install ansible
windows
# 安装pywinrm模块pip install pywinrm#在控制节点上创建或编辑Ansible的主机清单文件(例如 /etc/ansible/hosts):[windows]windows_host ansible_host=<windows_ip>[windows:vars]ansible_user=<your_username>ansible_password=<your_password>ansible_connection=winrmansible_winrm_transport=basicansible_winrm_server_cert_validation=ignore#创建一个简单的Ansible剧本(例如 win_ping.yml),测试连接到Windows主机:---- name: Test connection to Windows hosthosts: windowstasks:- name: Ping the Windows hostwin_ping:#在控制节点上运行Ansible剧本:ansible-playbook win_ping.yml
通过tree查看ansible有哪些文件,当然还有很多文件没有列举出来
tree /etc/ansible//etc/ansible/├── ansible.cfg #配置文件├── hosts #主机清单文件└── roles