0

I'm kind of stuck here, not sure exactly what is wrong can someone help me.

Problem: When running below resource in Openstack using terraform, the user "aditya" gets created intermittently. I need the user to be created every-time.

Not sure if it's error in code or problem of vm's.

  resource "openstack_compute_instance_v2" "test-machine" {
  region              = "zxy"
  availability_zone   = "zcy"
  name                = "test-machine"
  security_groups     = []
  user_data           = templatefile("/some/path",{ 
                
      admin_username  = "aditya"})

  connection {
    host              = someip
    type              = "ssh"
    user              = "aditya"
    private_key       = test_pem
    timeout           = "20m"
  }

  provisioner "remote-exec" {
    inline = [
      "/bin/bash -c \"while [ ! -f /tmp/done-user-data ]; do sleep 2; done\"",
    ] 
  }
}
Aditya
  • 1,740
  • 13
  • 22
  • You would need to check `cloud-init` logs (/var/log/cloud-init*.log) on the machine whether it ran python scripts to create user on the VM. Of course, you cannot logon with `aditya` user as it's not in there but you can setup root password to debug this issue. Also, how does your cloud-init config `/etc/cloud/cloud. cfg` file look like? – harshavmb Mar 04 '22 at 12:22

0 Answers0