Подключение WinRM заняло много времени, а затем завершилось неудачно при создании экземпляра в GCP - PullRequest
0 голосов
/ 16 октября 2019

Я хочу создать скрипт в gcp и выполнить некоторую команду после его завершения.

Я создал один скрипт terraform для раскрутки экземпляра windows в GCP, создание экземпляра успешно завершено, но его ошибка в встроенной команде, Также попытался выполнить команду с INVOKE-Commands, но это также не удалось.

Terraform script:

// Configure the Google Cloud provider
provider "google" {
 credentials = "${file(*******.json")}"
 project     = "**********"
 region      = "${var.region_name}"
 zone      = "${var.zone_name}"
}

resource "google_compute_instance" "vm_instance" {
  name         = "${var.instance_name}"
  machine_type = "${var.machine_type}"
  tags         = "${var.network_tags}"

  boot_disk {
    initialize_params {
      image = "${var.boot_disk_image}"
        size    = "100"
        type    = "pd-standard"
    }
  }


  network_interface {
    # A default network is created for all GCP projects
#   name          = "${var.instance_name}"
    network       = "${var.instance_network}"
    subnetwork    = "${var.instance_subnetwork}"

    access_config {
    }
  }
  provisioner "remote-exec" {
    connection {
      type  = "winrm"
      user  = "administrator"
      password = "***********"
      host = "${google_compute_instance.vm_instance.network_interface.0.access_config.0.nat_ip}"
      timeout = "1m"
    }
    inline = [
        "powershell -ExecutionPolicy Unrestricted New-Item -ItemType 'file' -Path 'c:\\test.txt'"
    ]
  }
}

Error:
google_compute_instance.vm_instance (remote-exec): Connecting to remote host via WinRM...
google_compute_instance.vm_instance (remote-exec):   Host: ip
google_compute_instance.vm_instance (remote-exec):   Port: 5985
google_compute_instance.vm_instance (remote-exec):   User: administrator
google_compute_instance.vm_instance (remote-exec):   Password: true
google_compute_instance.vm_instance (remote-exec):   HTTPS: false
google_compute_instance.vm_instance (remote-exec):   Insecure: false
google_compute_instance.vm_instance (remote-exec):   NTLM: false
google_compute_instance.vm_instance (remote-exec):   CACert: false

Getting below error, For invoke command,

PS C:\Users\smp0619\Desktop\MyFolder\Terraform\TerraformScripts\gcp_instance> Invoke-Command -ComputerName $private_ip -
ScriptBlock { param($variable) Rename-NetAdapter -Name "Ethernet" -NewName $variable } -ArgumentList $private_ip -creden
tial $VMCredentials
[ip] Connecting to remote server ip failed with the following error message : WinRM cannot
complete the operation. Verify that the specified computer name is valid, that the computer is accessible over the
network, and that a firewall exception for the WinRM service is enabled and allows access from this computer. By
default, the WinRM firewall exception for public profiles limits access to remote computers within the same local
subnet. For more information, see the about_Remote_Troubleshooting Help topic.
    + CategoryInfo          : OpenError: (ip:String) [], PSRemotingTransportException
    + FullyQualifiedErrorId : WinRMOperationTimeout,PSSessionStateBroken
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...