我有一个工作手册来创建 Ubuntu 20.04 VPS,然后安装包括 Docker 在内的大量软件。
我正在尝试将它用于 Ubuntu 22.04 VPS。
它确实有效,但在使用 APT 时,我收到警告“密钥存储在旧版 trust.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.
我不知道我做错了什么。
解决了。 我只需要将密钥文件的扩展名从 .gpg 更改为 .asc,然后就可以正常工作了。
我正在尝试使用 Ansible 脚本安装 Kubernetes 集群。 操作系统 Debian12 k8s传送门包:
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
错误: 无法获取 https://pkgs.k8s.io/core:/stable:/v1.28/deb/InRelease 由于公钥不可用,无法验证以下签名:NO_PUBKEY 234654DA9A296436"
原因:URL Repo Release.key 未保存为 keyring.gpg
解决方法:将 .gpg 替换为 .asc/示例:Keyring.asc 这对我有用。
解决方案: Ansible 重新安装并升级到最新版本。 keyring.gpg 问题已解决。 https://www.linuxtechi.com/install-ansible-automation-tool-debian/