Vagrant 卡在默认状态:等待 cloud init 完成运行。可能是什么问题?

问题描述 投票:0回答:2

我正在尝试在 ubuntu/jammy64 上设置 vagrant 并使用 cloud init 对其进行配置,但它需要很长时间才能启动。这是 vagrant 文件:

Vagrant.configure("2") do |config|
    config.env.enable # enable .env support plugin (it will let us easily enable cloud_init support)
    config.vm.provider "virtualbox" do |v|
      v.memory = 4096
      v.cpus = 2
    end
    config.vm.box = "ubuntu/jammy64"
    config.vm.cloud_init :user_data do |cloud_init|
      cloud_init.content_type = "text/cloud-config"
      cloud_init.path = "cloudinit.yml"
    end
end

这是cloudinit.yml文件:

package_update: true
package_upgrade: true
package_reboot_if_required: true
packages:
   - neofetch
  - htop
  - docker-ce
  - docker-ce-cli
  - docker-compose-plugin
  - openjdk-11-jdk
  - wget
apt:
  sources:
    docker.list:
      source: deb [arch=amd64] https://download.docker.com/linux/ubuntu $RELEASE stable
      keyid: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88

users:
  - name: test_user_unique_name
    groups: sudo
    homedir: /custom/home/dir
    shell: /bin/bash
    sudo: ["ALL=(ALL) NOPASSWD:ALL"]
  - name: Mallory
    groups: docker
    sudo: ALL=(ALL) NOPASSWD:ALL
  - name: Eve
    groups: docker
    sudo: ALL=(ALL) NOPASSWD:ALL
  

#cloud-config
write_files:
  - path: /etc/docker/daemon.json
    content: |
      {"mtu" : 1442}
  - path: /etc/sysctl.conf
    content: |
      vm.max_map_count=262144
      
runcmd:
  - sudo swapoff -a
  - sudo sysctl -p
  - [ wget, "https://raw.githubusercontent.com/opensearch-project/documentation-website/2.6/assets/examples/docker-compose.yml"]

运行 vagrant up --debug 时,它似乎卡在“DEBUG ssh: Sending SSH keep-alive”上

我尝试更改提供商和发行版,但没有成功。我还尝试使用非常有限的 cloudinit.yml 版本运行 vagrant,但没有运气和同样的错误。我对 vagrant 和 cloud init 都很陌生。也许我正在监督一个简单的解决方案?

linux ubuntu vagrant cloud-init
2个回答
0
投票

我对 vagrant 的了解不够多,无法提供帮助(这看起来是您问题的根源),但我可以告诉您,您的云配置无效,因此它可能根本无法运行。

#cloud-config
需要在文件的顶部,
- neofetch
过度缩进,并且 users->sudo 不带列表。这是修复了这些问题的更新版本:

#cloud-config
package_update: true
package_upgrade: true
package_reboot_if_required: true
packages:
  - neofetch
  - htop
  - docker-ce
  - docker-ce-cli
  - docker-compose-plugin
  - openjdk-11-jdk
  - wget
apt:
  sources:
    docker.list:
      source: deb [arch=amd64] https://download.docker.com/linux/ubuntu $RELEASE stable
      keyid: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88

users:
  - name: test_user_unique_name
    groups: sudo
    homedir: /custom/home/dir
    shell: /bin/bash
    sudo: "ALL=(ALL) NOPASSWD:ALL"
  - name: Mallory
    groups: docker
    sudo: ALL=(ALL) NOPASSWD:ALL
  - name: Eve
    groups: docker
    sudo: ALL=(ALL) NOPASSWD:ALL

write_files:
  - path: /etc/docker/daemon.json
    content: |
      {"mtu" : 1442}
  - path: /etc/sysctl.conf
    content: |
      vm.max_map_count=262144

runcmd:
  - sudo swapoff -a
  - sudo sysctl -p
  - [ wget, "https://raw.githubusercontent.com/opensearch-project/documentation-website/2.6/assets/examples/docker-compose.yml"]

0
投票

卡在DEBUG ssh: Sending SSH keep-alive 半小时左右通过了但是报错:

Vagrant 使用的底层 SSH 库发生错误。 错误信息如下所示。在许多情况下,由此产生的错误 库是由 ssh-agent 问题引起的。尝试禁用您的 SSH 代理或删除一些密钥,然后重试。

如果问题仍然存在,请向 net-ssh 项目报告错误。

我的 wget 函数似乎也无法正常工作,因为找不到 compose 文件。

服务器版本协商超时

© www.soinside.com 2019 - 2024. All rights reserved.