使用ssh在windows上运行Terraform remote exec
我已经安装了一个Windows服务器,并使用Chocolate安装了ssh。如果我手动运行此命令,则连接和运行命令时不会出现问题。当我尝试使用Terraform运行命令时,它成功连接,但不运行任何命令 我从使用winrm开始,然后我可以运行命令,但由于在winrm上创建服务结构群集时出现了一些问题,我决定尝试使用ssh,当手动运行时,它工作正常,群集启动。因此,这似乎是前进的方向 我已经安装了一个Linux虚拟机,并通过使用私钥使ssh正常工作。因此,我尝试使用与Windows上Linux虚拟机相同的配置,但它仍然要求我使用密码 为什么能够通过ssh手动运行命令,并且只使用Terraform connect,而不运行任何命令?我正在使用Windows 2016在OpenStack上运行此功能使用ssh在windows上运行Terraform remote exec,ssh,terraform,windows-server,terraform-provider-openstack,Ssh,Terraform,Windows Server,Terraform Provider Openstack,我已经安装了一个Windows服务器,并使用Chocolate安装了ssh。如果我手动运行此命令,则连接和运行命令时不会出现问题。当我尝试使用Terraform运行命令时,它成功连接,但不运行任何命令 我从使用winrm开始,然后我可以运行命令,但由于在winrm上创建服务结构群集时出现了一些问题,我决定尝试使用ssh,当手动运行时,它工作正常,群集启动。因此,这似乎是前进的方向 我已经安装了一个Linux虚拟机,并通过使用私钥使ssh正常工作。因此,我尝试使用与Windows上Linux虚拟机
null_resource.sf_cluster_install (remote-exec): Connecting to remote host via SSH...
null_resource.sf_cluster_install (remote-exec): Host: 1.1.1.1
null_resource.sf_cluster_install (remote-exec): User: Administrator
null_resource.sf_cluster_install (remote-exec): Password: true
null_resource.sf_cluster_install (remote-exec): Private key: false
null_resource.sf_cluster_install (remote-exec): SSH Agent: false
null_resource.sf_cluster_install (remote-exec): Checking Host Key: false
null_resource.sf_cluster_install (remote-exec): Connected!
null_resource.sf_cluster_install: Creation complete after 4s (ID: 5017581117349235118)
以下是im用于运行命令的脚本:
resource "null_resource" "sf_cluster_install" {
# count = "${local.sf_count}"
depends_on = ["null_resource.copy_sf_package"]
# Changes to any instance of the cluster requires re-provisioning
triggers = {
cluster_instance_ids = "${openstack_compute_instance_v2.sf_servers.0.id}"
}
connection = {
type = "ssh"
host = "${openstack_networking_floatingip_v2.sf_floatIP.0.address}"
user = "Administrator"
# private_key = "${file("~/.ssh/id_rsa")}"
password = "${var.admin_pass}"
}
provisioner "remote-exec" {
inline = [
"echo hello",
"powershell.exe Write-Host hello",
"powershell.exe New-Item C:/tmp/hello.txt -type file"
]
}
}
将
连接
块放在供应器
块内:
provisioner "remote-exec" {
connection = {
type = "ssh"
...
}
inline = [
"echo hello",
"powershell.exe Write-Host hello",
"powershell.exe New-Item C:/tmp/hello.txt -type file"
]
}
将
连接
块放在供应器
块内:
provisioner "remote-exec" {
connection = {
type = "ssh"
...
}
inline = [
"echo hello",
"powershell.exe Write-Host hello",
"powershell.exe New-Item C:/tmp/hello.txt -type file"
]
}