首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在自动安装过程中使用私有Apt repos时出错

在自动安装过程中使用私有Apt repos时出错
EN

Ask Ubuntu用户
提问于 2022-12-01 22:37:43
回答 1查看 708关注 0票数 1

概述/场景

我已经有了一个完全工作的自动安装配置,它使用默认的apt配置(在云init用户数据中没有apt配置)。源图像使用Ubuntu20.04云图

我的目标是编辑自动安装配置以使用私有Apt repos ( repos已经存在)。我必须确保安装程序不会触及Ubuntu服务器的Apt包,只点击自定义的Apt回复。回购已经建立,并已经工作了很长时间,我只需要让安装程序指向他们。

我已经复习过如何使用Ubuntu自动安装添加apt存储库

这里是我添加到自动安装云init中的内容:

注意:下面提到的/cdrom/apt-key.gpg文件是存在和有效的回购(彻底测试)。

注意: repos是在https上使用私有CA的。因为在配置Apt之前,我还不能在安装过程中安装ca-certificates包,所以我只是强迫它受到信任。trusted=yes没有工作,我还必须添加apt.conf.d/99verify-peer.conf,如下所示才能正常工作。这可能是造成此问题的原因之一,但在安装外壳程序中,它可以手动工作。我有证书,可以将它们注入安装媒体,因此,如果有更好的方法让安装程序实例信任我的CA证书,而不必强制信任,我愿意接受这种更改!

代码语言:javascript
复制
  early-commands:
    - 'mkdir -p /etc/apt'
    - 'cp /cdrom/apt-key.gpg /etc/apt/fresh-ubuntu-key.gpg'
    - 'touch /etc/apt/apt.conf.d/99verify-peer.conf'
    - 'echo >>/etc/apt/apt.conf.d/99verify-peer.conf "Acquire { https::Verify-Peer false }"'
  apt:
    preserve_sources_list: false
    sources_list: |
      deb [trusted=yes signed-by=/etc/apt/fresh-ubuntu-key.gpg] https://repo.internal.example.com/aptly/focal focal-ver221 main
      deb [trusted=yes signed-by=/etc/apt/fresh-ubuntu-key.gpg] https://repo.internal.example.com/aptly/focal focal-security-ver221 main
      deb [trusted=yes signed-by=/etc/apt/fresh-ubuntu-key.gpg] https://repo.internal.example.com/aptly/focal focal-updates-ver221 main
      deb [trusted=yes signed-by=/etc/apt/fresh-ubuntu-key.gpg] https://repo.internal.example.com/aptly/focal focal-backports-ver221 main

问题/

故障排除

当尝试安装时,它会失败,如下所示:

代码语言:javascript
复制
finish: subiquity/Updates/apply_autoinstall_config
start: subiquity/Late/apply_autoinstall_config
finish: subiquity/Late/apply_autoinstall_config
start: subiquity/Shutdown/apply_autoinstall_config
finish: subiquity/Shutdown/apply_autoinstall_config
finish: subiquity/apply_autoinstall_config
start:   subiquity/Install/install/configure_apt: configuring apt
start: subiquity/Meta/status_GET
start: subiquity/Meta/status_GET
start: subiquity/Meta/status_GET
start: subiquity/Meta/status_GET
start: subiquity/Mirror/cmd-apt-config: curtin command apt-config
finish: subiquity/Mirror/cmd-apt-config: curtin command apt-config
start:     subiquity/Install/install/configure_apt/cmd-in-target: curtin command in-target
finish:   subiquity/Install/install/configure_apt: Command '['/snap/subiquity/3119/usr/bin/python3.8', '-m', 'curtin', '--showtrace', '-vvv', '--set', 'json:reporting={"subiquity": {"type": "journald", "identifier": "curtin_event.2752.2"}}', 'in-target', '-t', '/tmp/tmpzyqgk825/mount', '--', 'apt-get', 'update']' returned non-zero exit status 100.
finish: subiquity/Install/install: Command '['/snap/subiquity/3119/usr/bin/python3.8', '-m', 'curtin', '--showtrace', '-vvv', '--set', 'json:reporting={"subiquity": {"type": "journald", "identifier": "curtin_event.2752.2"}}', 'in-target', '-t', '/tmp/tmpzyqgk825/mount', '--', 'apt-get', 'update']' returned non-zero exit status 100.
start:   subiquity/ErrorReporter/1669932701.344982386.install_fail/add_info
finish:     subiquity/Install/install/configure_apt/cmd-in-target: curtin command in-target
finish:   subiquity/ErrorReporter/1669932701.344982386.install_fail/add_info: written to /var/crash/1669932701.344982386.install_fail.crash
An error occurred. Press enter to start a shell

我试着在/var/crash/1669932701.344982386.install_fail.crash中找到任何有意义的东西,但是它是一个很大的文件,很难解析。似乎没有任何额外的失败信息,我可以看到。

重要的注意事项:失败后,我可以进入一个shell,更新/etc/apt/shell. fine手动,apt update工作得很好。因此,我知道安装程序实例可以正确地与我的私有repos通信。因此,在自动安装/云-init过程中,问题似乎必须是特定的。

如果你有任何想法,请帮助,谢谢!

EN

回答 1

Ask Ubuntu用户

回答已采纳

发布于 2022-12-02 23:39:55

tl;

博士

你可以试试

代码语言:javascript
复制
#cloud-config
autoinstall:
  apt:
    preserve_sources_list: false
    sources_list: |
      deb [trusted=yes] https://repo.internal.example.com/aptly/focal focal-ver221 main
      deb [trusted=yes] https://repo.internal.example.com/aptly/focal focal-security-ver221 main
      deb [trusted=yes] https://repo.internal.example.com/aptly/focal focal-updates-ver221 main
      deb [trusted=yes] https://repo.internal.example.com/aptly/focal focal-backports-ver221 main
     conf: |
      Acquire::https::repo.internal.example.com::Verify-Peer "false";
      Acquire::https::repo.internal.example.com::Verify-Host "false";

推理

首先,您的自动安装配置中的early-commands没有执行您认为的操作。这些命令在安装程序环境中配置apt。但是,安装过程中的apt命令通常发生在不同的chroot环境中。你分享的日志显示了这一点。失败的命令是部分in-target -t /tmp/tmpzyqgk825/mount apt-get update

第二个问题是存储库有一个自定义的gpg键。提供我所知道的自定义键的唯一方法是使用您引用的另一个答案中的语法。当然,您也可以添加sources.list选项trusted=yes,以避免从缺少的gpg键中失败,但从长远来看,这可能不是一个好的配置。

第三个问题是,一个私有CA签署了https证书。没有提供信任此私有CA的方法。看起来就像一个窃听器被归档了请求的那样。它看起来也像有一个apt配置选项,可以用来忽略证书问题。同样,从长远来看,这可能不是一个好的配置。

late-commands可能最容易安装自定义gpg密钥和私有CA,并重新配置apt。

更新

正如评论中所指出的那样,这一解决方案不起作用。我在分享我在这里发现的东西。我使用Ubuntu22.04 (subiquity 22.04.2)测试了安装过程。

  • 亚类创建 /var/log/installer/subiquity-curtin-apt.conf.它基本上包含自动安装apt部分(以及潜在的代理信息)。
  • subiquity在配置apt覆盖文件系统中使用/var/log/installer/subiquity-curtin-apt.conf将curtin运行到/tmp/tmpXXX。如果使用上面的自动安装片段,则curtin将创建/tmp/tmpXXX/etc/apt/apt.conf.d/94curtin-config
  • subiquity创建/var/log/installer/subiquity-curtin-install.conf。这不包含apt截面。大概是因为apt已经配置好了。
  • subiquity使用执行安装运行curtin到/var/log/installer/subiquity-curtin-install.conf。这将将/tmp/tmpXXX复制到/target。这将创建/target/etc/apt/apt.conf.d/94curtin-config
  • 在安装过程中的稍后阶段,curtin 配置apt。因为安装配置不包含apt部分,所以curtin实际上会删除94 94curtin配置
  • 需要在94curtin-config中进行apt配置的后续apt命令将失败并导致安装失败。
  • 如果安装没有因为缺少94curtin-config文件而失败,那么subiquity 将复制 /tmp/tmpXXX/etc/apt to /target/etc/apt中的后续步骤将包含94curtin-config

简而言之,不要依赖使用自动安装的apt conf设置。

票数 1
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1443497

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档