OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Not able to log into the Compute Engine (GCP) which was created by using Packer image [closed]

  • Thread starter Thread starter theCoderfidato
  • Start date Start date
T

theCoderfidato

Guest
Packer Installation on Local machine:

wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg

echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list

sudo apt update && sudo apt install packer

Ref

Packer version :

packer --version Packer v1.11.0

Packer Template:

Code:
{
  "builders": [
    {
      "type": "googlecompute",
      "project_id": "project_Id",
      "source_image_project_id":"project_id",
      "source_image": "image_name",
      "disk_size": "200",
      "communicator": "ssh",
      "use_os_login": false,
      "tags":"ssh",
      "use_iap": true,
      "ssh_timeout":"10m",
      "iap_tunnel_launch_wait":"90",
      "ssh_username": "packer",
      "zone": "region",
      "subnetwork": "subnet_selflink",
      "omit_external_ip": true,
      "use_internal_ip": true
    }
  ],
  "provisioners": [
    {
      "type": "file",
      "source": "local_file_namet",
      "destination": "destination_path"
    }
  ]
}

The above packer template, is able to create a vm using the specified image, in the specified project, But it is failing to ssh into the created vm. It is showing connection timeout error.

Things tried:

  • Increased the SSH timeout to 10 minutes, but still getting the same error.
  • Added the network tag in the Packer template to enable SSH, but it didn't resolve the issue.
  • Tried to SSH using the IAP tunnel, but it still didn't work.
  • Executed the same Packer template by creating a VM and modified the template to create a VM in the same subnet as the VM, but still encountering a timeout error.

Error Screenshot

Have added the iap_tunnel_launch_wait to 90 but its not helping, referred the below article for the troubleshooting

https://developer.hashicorp.com/pac.../builder/googlecompute#iap_tunnel_launch_wait

https://github.com/hashicorp/packer/issues/12169

Please let me know if i am missing something here
<p><strong>Packer Installation on Local machine</strong>:</p>
<p>wget -O- <a href="https://apt.releases.hashicorp.com/gpg" rel="nofollow noreferrer">https://apt.releases.hashicorp.com/gpg</a> | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg</p>
<p>echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] <a href="https://apt.releases.hashicorp.com" rel="nofollow noreferrer">https://apt.releases.hashicorp.com</a> $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list</p>
<p>sudo apt update && sudo apt install packer</p>
<p>Ref</p>
<p><strong>Packer version</strong> :</p>
<p>packer --version
Packer v1.11.0</p>
<p><strong>Packer Template:</strong></p>
<pre><code>{
"builders": [
{
"type": "googlecompute",
"project_id": "project_Id",
"source_image_project_id":"project_id",
"source_image": "image_name",
"disk_size": "200",
"communicator": "ssh",
"use_os_login": false,
"tags":"ssh",
"use_iap": true,
"ssh_timeout":"10m",
"iap_tunnel_launch_wait":"90",
"ssh_username": "packer",
"zone": "region",
"subnetwork": "subnet_selflink",
"omit_external_ip": true,
"use_internal_ip": true
}
],
"provisioners": [
{
"type": "file",
"source": "local_file_namet",
"destination": "destination_path"
}
]
}

</code></pre>
<p>The above packer template, is able to create a vm using the specified image, in the specified project, But it is failing to ssh into the created vm. It is showing connection timeout error.</p>
<p><strong>Things tried:</strong></p>
<ul>
<li>Increased the SSH timeout to 10 minutes, but still getting the same error.</li>
<li>Added the network tag in the Packer template to enable SSH, but it didn't resolve the issue.</li>
<li>Tried to SSH using the IAP tunnel, but it still didn't work.</li>
<li>Executed the same Packer template by creating a VM and modified the template to create a VM in the same subnet as the VM, but still encountering a timeout error.</li>
</ul>
<p><a href="https://i.sstatic.net/6pw1dDBM.jpg" rel="nofollow noreferrer">Error Screenshot</a></p>
<p>Have added the iap_tunnel_launch_wait to 90 but its not helping, referred the below article for the troubleshooting</p>
<p><a href="https://developer.hashicorp.com/pac.../builder/googlecompute#iap_tunnel_launch_wait" rel="nofollow noreferrer">https://developer.hashicorp.com/pac.../builder/googlecompute#iap_tunnel_launch_wait</a></p>
<p><a href="https://github.com/hashicorp/packer/issues/12169" rel="nofollow noreferrer">https://github.com/hashicorp/packer/issues/12169</a></p>
<p><strong>Please let me know if i am missing something here</strong></p>
Continue reading...
 

Latest posts

M
Replies
0
Views
1
Meliodas Dragon
M
Top