试图在Ansible Playbook中替换APT_KEY

发布于 2025-02-12 07:40:13 字数 1396 浏览 3 评论 0原文

我有一本工作的剧本来创建一个Ubuntu 20.04 VP,然后安装包括Docker在内的软件。

我正在尝试将其用于Ubuntu 22.04 vps。

它确实有效,但是当使用APT时,我会警告说“密钥存储在Legacy trusted.gpg键环中”,因为我正在使用不弃用的apt-key。

我的旧剧本包含:

- name: Add docker signing key
  apt_key:
    url: https://download.docker.com/linux/ubuntu/gpg
    state: present
- name: Add docker repository
  apt_repository:
    repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu jammy stable
    state: present

经过一番研究,我认为我可以用以下内容替换以下内容:

- name: Add docker signing key (new GPG method)
  get_url:
    url: https://download.docker.com/linux/ubuntu/gpg
    dest: /etc/apt/keyrings/docker.gpg
    mode: '0644'
    force: true 
- name: Add docker repository
  apt_repository:
    repo: deb [signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu jammy stable
    state: present

一个键存储在/etc/apt/keyrings/docker.gpg中,但是,我会收到以下错误:

    TASK [Add docker repository] *********
    fatal: [node1]: FAILED! => changed=false
 msg: 'Failed to update apt cache: W:GPG error: https://download.docker.com/linux/ubuntu jammy InRelease: The following signatures couldn''t be verified because the public key is not available: NO_PUBKEY 7EA0A9C3F273FCD8, E:The repository ''https://download.docker.com/linux/ubuntu jammy InRelease'' is not signed.

我不知道什么我做错了。

I have a working playbook to create a Ubuntu 20.04 VPS and then install a load of software including Docker.

I am trying to use it for a Ubuntu 22.04 VPS.

It does work, but when using APT, I get warnings that "Key is stored in legacy trusted.gpg keyring" because I am using the deprecated apt-key.

My old playbook contains :

- name: Add docker signing key
  apt_key:
    url: https://download.docker.com/linux/ubuntu/gpg
    state: present
- name: Add docker repository
  apt_repository:
    repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu jammy stable
    state: present

After some research, I thought I could replace the above with the following :

- name: Add docker signing key (new GPG method)
  get_url:
    url: https://download.docker.com/linux/ubuntu/gpg
    dest: /etc/apt/keyrings/docker.gpg
    mode: '0644'
    force: true 
- name: Add docker repository
  apt_repository:
    repo: deb [signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu jammy stable
    state: present

A key is being stored in /etc/apt/keyrings/docker.gpg, however, I get the following error :

    TASK [Add docker repository] *********
    fatal: [node1]: FAILED! => changed=false
 msg: 'Failed to update apt cache: W:GPG error: https://download.docker.com/linux/ubuntu jammy InRelease: The following signatures couldn''t be verified because the public key is not available: NO_PUBKEY 7EA0A9C3F273FCD8, E:The repository ''https://download.docker.com/linux/ubuntu jammy InRelease'' is not signed.

I do not know what I am doing wrong.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

亢潮 2025-02-19 07:40:13

解决了。
我只需要将密钥文件的扩展名从 .gpg 更改为 .ASC ,然后效果很好。

Solved it.
I just had to change the extension of the key file from .gpg to .asc and then it worked fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文