自定义和部署的 Ubuntu 18.04 模板上的 NIC 断开连接

自定义和部署的 Ubuntu 18.04 模板上的 NIC 断开连接

在我的 vSphere 6.7 U3 环境中,我有一个由打包程序生成的 Ubuntu 18.04 模板,然后我使用 Terraform 部署了它的两个副本。我遇到一个问题,即部署的虚拟机的 NIC 断开连接,导致 Terraform 无法完成部署。

我已遵循 vmware 的以下 KB:https://kb.vmware.com/s/article/56409虽然有人提到这个问题应该在我运行的 vSphere 和 open-vm-tools 版本中得到修复。我在 packer 生成的模板中找到了 KB 中概述的修复方法。

To resolve this issue, follow below provided steps and do not skip the steps.

    Open the tmp.conf under /usr/lib/tmpfiles.d/tmp.conf file.

Go to the line 11 and add the prefix # .

For example
#D /tmp 1777 root root -

    If you have open-vm-tools installed, open the /lib/systemd/system/open-vm-tools.service file.

         In certain version path may be different the use find command locate the file 
               #find  /  -iname  open-vm-tools.service
 
Add this line “After=dbus.service” under [Unit]

有其他人遇到过这种情况吗?我没有使用 cloud-init 自定义方法。这是我在 /var/log/vmware-imc/toolsDeployPkg.log 文件中看到的唯一错误:

[2020-07-17T18:17:57.140Z] [   error] Customization command failed with exitcode: 2, stderr: 'Can't locate File/stat.pm in @INC (you may need to install the File::stat module) (@INC contains: /var/run/.vmware-imgcust-dk2xFAt/scripts /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /var/run/.vmware-imgcust-dk2xFAt/scripts/Utils.pm line 26.
BEGIN failed--compilation aborted at /var/run/.vmware-imgcust-dk2xFAt/scripts/Utils.pm line 26.
Compilation failed in require at /var/run/.vmware-imgcust-dk2xFAt/scripts/Customize.pl line 24.
BEGIN failed--compilation aborted at /var/run/.vmware-imgcust-dk2xFAt/scripts/Customize.pl line 24.

答案1

问题在于:

[2020-07-17T18:17:57.140Z] [   error] Customization command failed with exitcode: 2, stderr: 'Can't locate File/stat.pm in @INC (you may need to install the File::stat module) (@INC contains: /var/run/.vmware-imgcust-dk2xFAt/scripts /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /var/run/.vmware-imgcust-dk2xFAt/scripts/Utils.pm line 26.

open-vm-tools需要包含 的软件包File/stat.pm,在 Ubuntu 18.04 LTS 上为perl-modules-5.26。确保已安装此软件包。

相关内容