ubuntu Ansible apt_repository创建重复条目?

wljmcqd8  于 2023-03-22  发布在  其他
关注(0)|答案(1)|浏览(107)

我一直在尝试通过Ansible添加一个repo。结果是/etc/apt/sources.list.d/中有两个不同的repo文件,名称不同,冲突。这是Ubuntu 20.04的新安装。
这是我的vars yaml:

repos:
  - name: vscode
    repo: deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/vscode stable main
    key: https://packages.microsoft.com/keys/microsoft.asc
    keyring: /etc/apt/trusted.gpg.d/packages.microsoft.gpg

  - name: foliate
    repo: ppa:apandada1/foliate
    keyserver: keyserver.ubuntu.com
    id: 95ACDEBD8BFF99ABE0F26A49A507B2BBA7803E3B

这是我的任务yaml:

- name: Install gpg keys
  apt_key:
    url: "{{ item.key | default(omit) }}"
    keyring: "{{ item.keyring | default(omit) }}"
    id: "{{ item.id | default(omit) }}"
    keyserver: "{{ item.keyserver | default(omit) }}"
  loop: "{{ repos }}"
  become: true

- name: Install repositories
  apt_repository:
    repo: "{{ item.repo }}"
  loop: "{{ repos }}"
  become: true

服务器上的结果如下:

# ls -1 /etc/apt/sources.list.d/
...
packages_microsoft_com_repos_vscode.list
vscode.list

# cat /etc/apt/sources.list.d/packages_microsoft_com_repos_vscode.list 
deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/vscode stable main

# cat /etc/apt/sources.list.d/vscode.list 
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
deb [arch=amd64] http://packages.microsoft.com/repos/vscode stable main

这会导致错误:
“E:为有关源https://packages.microsoft.com/repos/vscode/稳定的选项Signed-By设置的值冲突:/etc/apt/trusted.gpg.d/packages.microsoft.gpg!=“,“E:无法读取源列表。”
那么为什么会有额外的repo文件呢?

sqyvllje

sqyvllje1#

如果你在apt_repository部分下添加filename: vscode,它不会创建一个额外的.list文件。

相关问题