简体   繁体   English

如何使用 Ansible 连接到 Windows EC2 实例?

[英]How to connect to a Windows EC2 instance using Ansible?

From reading the Connect to your Windows instance AWS EC2 docs page, my understanding is that it is not possible to SSH to Windows EC2 instances.通过阅读连接到您的 Windows 实例AWS EC2 文档页面,我的理解是无法通过 SSH 连接到 Windows EC2 实例。

The typical procedure to connect to a Windows EC2 instance manually is to download the remote desktop file, get the password for the instance, and then use the Remote Desktop Connection tool to RDP to the instance (more detail is in the docs page above).手动连接到 Windows EC2 实例的典型过程是下载远程桌面文件,获取实例的密码,然后使用远程桌面连接工具 RDP 到实例(更多详细信息在上面的文档页面中)。

If I am correct that Windows EC2 instances do not support connecting via SSH, how can you connect to a Windows EC2 in an Ansible playbook?如果我认为 Windows EC2 实例不支持通过 SSH 连接是正确的,那么如何在 Ansible playbook 中连接到 Windows EC2?

I would prefer to be able to do this without installing any software on the Windows EC2 instance beforehand, but if that is necessary, I can do that.我希望能够在不事先在 Windows EC2 实例上安装任何软件的情况下执行此操作,但如果有必要,我可以这样做。

I have found you need to do the following to connect to a Windows EC2 instance using Ansible:我发现您需要执行以下操作才能使用 Ansible 连接到 Windows EC2 实例:

  • You need to configure the EC2 to allow connections from Ansible using the ConfigureRemotingForAnsible.ps1 script .您需要使用ConfigureRemotingForAnsible.ps1脚本将 EC2 配置为允许来自 Ansible 的连接。 This can be done either by setting this as the user data when you create the EC2, or by running this script after the EC2 is created.这可以通过在创建 EC2 时将其设置为用户数据来完成,或者通过在创建 EC2 后运行此脚本来完成。
  • You need add a security group, or configure a security group already added to the EC2 to allow the following incoming requests to the EC2 from the host(s) that the Ansible playbook will be running on:您需要添加一个安全组,或配置一个已添加到 EC2 的安全组,以允许从运行 Ansible playbook 的主机向 EC2 发出以下传入请求:
    • WinRM WinRM
    • TCP requests to whatever you configure as the Ansible port对您配置为 Ansible 端口的任何内容的 TCP 请求
  • You need to install pywinrm>=0.3.0 so Ansible can use WinRM to connect to the EC2.您需要安装 pywinrm>=0.3.0 以便 Ansible 可以使用 WinRM 连接到 EC2。
  • You need to run the Ansible playbook with ansible_connection variable set to winrm , and the ansible_winrm_scheme variable set to http .您需要运行 Ansible playbook, ansible_connection变量设置为winrm ,并将ansible_winrm_scheme变量设置为http This can be done with --extra-args or any other way that variables are set.这可以通过--extra-args或任何其他设置变量的方式来完成。
  • You need to provide the public IP address of the Windows EC2 host, either under hosts in the playbook, or in a host file passed to ansible-playbook with -i .您需要提供 Windows EC2 主机的公共 IP 地址,或者在 playbook 中的hosts下,或者在使用-i传递给ansible-playbook的主机文件中。
  • You need to get or set the EC2's Administrator password, and then provide this password with the ansible_password variable for the EC2.您需要获取或设置 EC2 的管理员密码,然后将此密码与 EC2 的ansible_password变量一起提供。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法连接到升级的EC2 Windows实例 - Unable to connect to an upgraded EC2 windows instance 如何在Windows EC2实例上运行Minikube? - How to run Minikube on Windows EC2 Instance? 无法使用Ansible Playbook连接到Windows实例 - Unable to connect to a Windows Instance using Ansible Playbook 无法使用 Putty 从 Windows ssh 到 EC2 实例 - Cannot ssh into EC2 instance from Windows using Putty 使用 Z2F2D399F0EA88448339FE5514B304 为 Windows EC2 实例配置 static IP 地址 - Configuring static IP address for Windows EC2 instance using powershell 使用Chef Solo配置Windows EC2实例并引导它 - Using Chef Solo to provision a Windows EC2 instance and bootstrap it 如何使用 Python 在 AWS EC2 实例上将文件/目录从 linux 远程复制到 windows? - How to copy files/directories remotely from linux to windows on AWS EC2 instance using Python? 在Windows 8上拒绝使用SSH连接到Amazon EC2的权限 - Permission denied to connect to Amazon EC2 using SSH at Windows 8 如何通过堡垒主机从我的 Windows OS 客户端机器连接到私有子网中的 EC2 实例。 - How to connect to EC2 instance which is in Private subnet from my Windows OS client machine through Bastion host.? 如何为Windows EC2实例替换/添加密钥对 - How to replace/add key pair for a Windows EC2 instance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM