You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 22.04下Ansible无法识别HashiCorp仓库,Nomad安装失败

Ubuntu 22.04下Ansible安装Nomad提示找不到包的排查方向

以下是可能的原因及对应解决思路:

  • 发行版变量不匹配:{{ ansible_distribution_release }} 在Ubuntu 22.04上返回值为jammy,需确认HashiCorp APT仓库是否支持该发行版。可直接将变量替换为jammy测试,同时检查目标机器架构是否为amd64——如果是arm架构(如Graviton实例),当前仓库架构配置会导致找不到包。
  • APT缓存未及时刷新:虽然安装步骤添加了update_cache: yes,但如果添加仓库后缓存未立即更新,系统仍无法识别新仓库中的包。建议在添加仓库的步骤后,单独执行一次缓存更新任务:
    - name: update apt cache after adding hashicorp repo
      apt:
        update_cache: yes
    
  • 密钥添加方式过时:Ubuntu 22.04已废弃apt-key工具,原任务中用ansible.builtin.apt_key添加密钥可能导致仓库不被信任。改用密钥环方式添加:
    - name: add hashicorp signing key to keyring
      ansible.builtin.get_url:
        url: https://apt.releases.hashicorp.com/gpg
        dest: /usr/share/keyrings/hashicorp-archive-keyring.gpg
        mode: '0644'
    - name: add hashicorp repo with signed-by
      ansible.builtin.apt_repository:
        repo: "deb [arch=amd64 signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com {{ ansible_distribution_release }} main"
        state: present
    
  • 仓库格式不规范:未指定signed-by参数可能导致APT不信任仓库,进而忽略其中的包。按上述修正后的仓库配置格式调整即可。
  • 网络访问限制:目标机器无法连接HashiCorp的APT仓库,检查防火墙规则、代理设置,手动在机器上执行apt update,查看是否能正常拉取仓库索引。

内容的提问来源于stack exchange,提问作者lmonninger

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 17:40:58