下面的“ansible等效”命令是什么?我已经搜索过了,除了使用shell模块之外,我似乎无法在ansible中找到一种方法来实现它。这可能有效,但不是最好的选择。
"dnf -y copr enable konimex/neofetch"发布于 2020-10-27 18:28:01
Ansible没有内置任何内容来管理Copr repos,所以运行命令是可以的,但是如果回购程序已经安装,您应该通过不运行它来使它成为幂等。
例如:
- name: Install copr repo konimex/neofetch
command:
cmd: dnf -y copr enable konimex/neofetch
creates: /etc/yum.repos.d/_copr:copr.fedorainfracloud.org:konimex:neofetch.repo
when: ansible_pkg_mgr == "dnf"因此,当回购文件已经存在时,命令将不再运行,任务将返回ok而不是changed。
(您还应该尽可能地使用command而不是shell。)
https://serverfault.com/questions/1040270
复制相似问题