Alternatives to using remote-exec in terraform vmware

620 views Asked by At

I'm provisioning servers in a bare metal environment that uses vmware to virtualize the machines. In this scenario I need to use alternatives in the use of remote-exec, this happens because I have restrictions. What is the suggestion for me to be able to install programs inside the vm that is being provisioned?

I want to run replace this code:

###exemplo de comando
provisioner "remote-exec" {
    inline = [
      "id",
      "uname -a",
      "cat /etc/os-release",
      "echo \"machine-id is $(cat /etc/machine-id)\"",
      "lsblk -x KNAME -o KNAME,SIZE,TRAN,SUBSYSTEMS,FSTYPE,UUID,LABEL,MODEL,SERIAL",
      "mount | grep ^/dev",
      "df -h",
    ]
    connection {
      type = "ssh"
      user = "vagrant"
      host = self.default_ip_address
    }
  }
1

There are 1 answers

0
harshavmb On

May be this ssh_resource provider?

resource "ssh_resource" "init" {
  host              = self.default_ip_address
  user              = "vagrant"
  agent             = true
  # An ssh-agent with your SSH private keys should be running
  # Use 'private_key' to set the SSH key otherwise

  timeout = "5m"

  commands = [
    "id",
    "uname -a",
    "cat /etc/os-release",
    "echo \"machine-id is $(cat /etc/machine-id)\"",
    "lsblk -x KNAME -o KNAME,SIZE,TRAN,SUBSYSTEMS,FSTYPE,UUID,LABEL,MODEL,SERIAL",
    "mount | grep ^/dev",
    "df -h"
  ]
}

To let you know this is not a plugin coming from Hashicorp but from a third-party source.