![如何擺脫“[警告]:考慮使用 dnf 模組而不是運行 dnf”?](https://rvso.com/image/1510161/%E5%A6%82%E4%BD%95%E6%93%BA%E8%84%AB%E2%80%9C%5B%E8%AD%A6%E5%91%8A%5D%EF%BC%9A%E8%80%83%E6%85%AE%E4%BD%BF%E7%94%A8%20dnf%20%E6%A8%A1%E7%B5%84%E8%80%8C%E4%B8%8D%E6%98%AF%E9%81%8B%E8%A1%8C%20dnf%E2%80%9D%EF%BC%9F.png)
我的一些 ansible 劇本從安裝python2-dnf
所需的軟體包開始dnf要運行的 ansible 模組。
tasks:
- name: Install required dnf python binding
shell: dnf install -y python2-dnf
changed_when: False
直接調用dnf
in殼模組導致以下警告
[WARNING]: Consider using dnf module rather than running dnf
如何避免此類警告,或確保python2-dnf
安裝軟體包和模組的建議方法是什麼dnf可以用嗎?
答案1
warn=no
可以透過在 shell 命令字串中加入 a 來消除 shell 警告,如下所示:
tasks: - name: Install required dnf python binding shell: dnf install -y python2-dnf warn=no changed_when: False