如何使用Ansible获取已安装的apt软件包? [英] How to get the installed apt packages with Ansible?
本文介绍了如何使用Ansible获取已安装的apt软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图列出我的Debian 7/8/9机器上所有已安装的软件包.有多种使用apt或dpkg进行处理的简单方法,但我找不到开箱即用的正确方法.
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屋!
查看全文