大网数据广告活动
服务器运维问答

What is the difference between Cloud-Init and Autoinstall?

· 52CE 我爱测

So I have been trying to essentially install Nixos from the official site with a Cloud-Init for Ubuntu Server 22.04. I want to really understand how to install packages that I potentially might have to compile or other ways of in…

问题原文

原帖链接 · Definity · CC BY-SA 4.0

So I have been trying to essentially install Nixos from the official site with a Cloud-Init for Ubuntu Server 22.04. I want to really understand how to install packages that I potentially might have to compile or other ways of installing packages like with Curl or Wget within in the user-data.yaml file.

So far I have a user-data.yaml in which I am trying to use runcmd: to install Nox via the recommended way from there site.

My whole config is below and at the bottom is the runcmd: which I just can't get to install. The whole file looks like this.

#cloud-config
autoinstall:
  version: 1
  locale: en_GB.UTF-8
  refresh-installer:
    update: true
  keyboard:
    layout: "gb"
  apt:
    geoip: true
  identity:
    hostname: ubuntu-server
    password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0"
    username: ubuntu
  storage:
    layout:
      name: lvm
      match:
        size: largest
  packages:
    - libreoffice
    - sway
    - i3
    - kitty
  snaps:
    - name: firefox
  timezone: geoip
  manage_resolv_conf: true
  resolv_conf:
    nameservers:
      - 1.1.1.3
      - 8.8.8.8
  updates: all
  runcmd:
    - [mkdir, -m, 0755, /nix]
    - [chown, ubuntu, /nix]
    - [wget, "https://nixos.org/nix/install"]
    - [bash, install, --daemon]

If you run the installer via the command line you get prompt if you want to make the dir '/nix' hence the command for it. I'm at my wits end!

I have tried for the past 7 hours to get this package manager installed so I can install Wayland which would be a lot easier to install from here than installing it from source if I was to use RunCmd: the whole time.

Which from what I understand is the way to run bash commands

So far I have tried:

  • Puting it to root so no \s\s before the runcmd: keyword
  • Trying the commands in quotes like "sh -c 'curl ....'"
  • Puting it in brackets like `[sh, -c, curl, "https://nixos.org/down.../install", |, bash]
  • Other configuration of it in brackets like `[bash, -c, 'curl "https://nixos.org/down.../install" | bash'] *So many configurations!!
  • Gone onto GitHub and search for examples of other people using runcmd:
  • Following a DigitalOcean guide on Cloud-Init with runcmd: examples
  • Read the reference for Cloud-init
  • Read the reference for Autoinstall
  • read the reference for Curtin

And I just don't know what to do next...

I'm using Qemu to test these configs with an Ubuntu 22.04 Jammy Server ISO.

How do I just install stuff from a setup file that has an install script from the web?

Thanks :)

已采纳解答

原帖链接 · Anttu · CC BY-SA 4.0

I was struggling with the same thing for hours!

Here's what seems to work (at least for me), so try this;

#cloud-config
autoinstall:
   version: 1
   ...
   user-data:
      runcmd:
        - mkdir -m 0755 /nix
        - chown ubuntu /nix
        - wget "https://nixos.org/nix/install"
        - bash install --daemon

Not sure about the brackets. My command worked without them so try that first for better readability.

https://ubuntu.com/server/docs/install/autoinstall-reference#user-data

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2023-02-11)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。