如何擺脫“[警告]:考慮使用 dnf 模組而不是運行 dnf”?

如何擺脫“[警告]:考慮使用 dnf 模組而不是運行 dnf”?

我的一些 ansible 劇本從安裝python2-dnf所需的軟體包開始dnf要運行的 ansible 模組。

tasks:
- name: Install required dnf python binding
  shell: dnf install -y python2-dnf
  changed_when: False

直接調用dnfin模組導致以下警告

[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

相關內容