# List all installed packages

**URL:** <https://forum.ansible.com/t/list-all-installed-packages/39759>\
**Category:** Get Help\
**Created:** [January 22, 2025, 9:35am UTC](https://forum.ansible.com/t/list-all-installed-packages/39759 "2025-01-22T09:35:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ravindrakal](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@ravindrakal](https://forum.ansible.com/u/ravindrakal)\
**Post date:** [January 22, 2025, 9:35am UTC](https://forum.ansible.com/t/list-all-installed-packages/39759/1 "2025-01-22T09:35:22Z")

</div>

I need help regarding list of all installed packages and same can be saved in .csv file.

---

<div class="post-metadata">

**Author:** ![anon81884396](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@anon81884396](https://forum.ansible.com/u/anon81884396)\
**Post date:** [January 22, 2025, 1:30pm UTC](https://forum.ansible.com/t/list-all-installed-packages/39759/2 "2025-01-22T13:30:15Z")

</div>

A google search of “ansible list packages” yields this [https://docs.ansible.com/ansible/latest/collections/ansible/builtin/package\_facts\_module.html](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/package_facts_module.html) and from my experience, you can use the copy module to save the contents of a variable to a file [Write variable to a file in Ansible - Stack Overflow](https://stackoverflow.com/questions/26638180/write-variable-to-a-file-in-ansible)

So since you gave no other information, you’d combine these two commands into a playbook wherein the variable containing your package info is saved to a csv.

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [January 22, 2025, 5:48pm UTC](https://forum.ansible.com/t/list-all-installed-packages/39759/3 "2025-01-22T17:48:24Z")

</div>

Right, something like this should work:

```yaml
- name: Get the apt package facts
  ansible.builtin.package_facts:
    manager: apt

- name: List installed packages
  ansible.builtin.debug:
    var: ansible_facts.packages.keys()

- name: Write installed packages to a file
  ansible.builtin.copy:
    content: "{{ ansible_facts.packages.keys() }}"
    dest: /tmp/installed_apt_packages.csv

```
