如何使用 Ansible 获取已安装的 apt 包? [英] How to get the installed apt packages with Ansible?

查看:39
本文介绍了如何使用 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 没有提供任何支持此功能的模块.您必须使用 shellcommand.

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}
' -W
  register: packages

- name: Print packages
  debug:
    msg: "{{ packages.stdout_lines }}" 

这篇关于如何使用 Ansible 获取已安装的 apt 包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆