如何使用 Ansible 获取已安装的 apt 软件包? [英] How to get the installed apt packages with Ansible?
本文介绍了如何使用 Ansible 获取已安装的 apt 软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试列出我的 Debian 7/8/9 机器上所有已安装的软件包.有使用 apt 或 dpkg 处理它的简单方法,但我找不到开箱即用的 ansible 正确方法.
I am trying to list all installed packages on my Debian 7/8/9 machines. There are easy ways dealing with it using apt or dpkg but I could not find a proper way to do this with ansible out of the box.
有没有一种很好且流畅的方法来做到这一点?
Is there a nice and smooth way to do this?
对于 RHEL 机器,我发现了这篇文章:如何获取使用 Ansible 安装的 yum 包?
For RHEL machines I found this Post: How to get the installed yum packages with Ansible?
推荐答案
Ansible 似乎没有提供任何支持此功能的模块.您必须使用 shell
或 command
.
It doesn't look like Ansible provides any modules that would support this. You'll have to use shell
or command
.
- name: Get packages
shell: dpkg-query -f '${binary:Package}\n' -W
register: packages
- name: Print packages
debug:
msg: "{{ packages.stdout_lines }}"
这篇关于如何使用 Ansible 获取已安装的 apt 软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文