【小提示】消除Ansible执行rpm命令时显示的警告

你好。我是Amazon Web Services团队的Sureing。

最近,我们的麒麟系统存在openssl漏洞,我把它修好了。于是我使用命令对使用rpm包更新后的openssl进行版本检查

当我运行shell模块使用rpm命令时,我收到以下警告:忽略它不会立即导致问题,但它很恶心,因此本文的目的是解决它。

[root@host-Amazon ~]# ansible Sureing -m shell -a 'rpm -qa | grep openssl'
[WARNING]: Consider using the yum, dnf or zypper module rather than running 'rpm'.  If you need to use command because yum, dnf or zypper is insufficient you can add 'warn: false' to this command task or set 'command_warnings=False' in
ansible.cfg to get rid of this message.

127.0.0.1 | CHANGED | rc=0 >>
openssl-1.1.1f-4.p17.ky10.x86_64
openssl-devel-1.1.1f-4.p17.ky10.x86_64
openssl-pkcs11-0.4.10-1.ky10.x86_64
openssl-libs-1.1.1f-4.p17.ky10.x86_64

先说结论
可以看到警告已经提示我们该怎么做了
可以通过将以下设置添加到 Ansible 配置文件 (ansible.cfg) 来解决此问题。

vi /etc/ansible/ansible.cfg
command_warnings=False

顺便说一下,Ansible 的版本是 2.8.8。

$ ansible --version
ansible 2.8.8
posted @ 2024-04-19 10:51  Sureing  阅读(8)  评论(0编辑  收藏  举报