gpt4 book ai didi

Ansible dnf 模块启用 Fedora Copr 存储库

转载 作者:行者123 更新时间:2023-12-04 12:28:45 25 4
gpt4 key购买 nike

我想用 Ansible 启用 Fedora Copr 存储库。更具体地说,我想转换此命令:

dnf copr enable ganto/lxd

使用 Ansible command模块我克服了这个问题,但打破了任务的幂等性(如果再次运行,角色不应进行任何更改)( changed_when: false 不是一个选项)。
- name: Enable Fedora Copr for LXD
command: "dnf copr enable -y ganto/lxd"

另外,我试过这个:
- name: Install LXD
dnf:
name: "{{ item }}"
state: latest
enablerepo: "xxx"
with_items:
- lxd
- lxd-client

我在其中测试了选项 enablerepo 的许多变体没有任何成功。

是否可以使用 dnf Ansible 模块(或其他)?

最佳答案

多亏了https://docs.ansible.com/ansible/latest/collections/community/general/copr_module.html,现在可以实现了
使用 command 的原始片段

- name: Enable Fedora Copr for LXD
command: "dnf copr enable -y ganto/lxd"
可以改为
- name: Enable Fedora Copr for LXD
community.general.copr:
name: ganto/lxd

关于Ansible dnf 模块启用 Fedora Copr 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42651026/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com