I need help regarding list of all installed packages and same can be saved in .csv file.
A google search of “ansible list packages” yields this 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
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.
1 Like
Right, something like this should work:
- 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