# apt module with list of packages

**URL:** <https://forum.ansible.com/t/apt-module-with-list-of-packages/15699>\
**Category:** Ansible Project\
**Created:** [July 17, 2014, 8:12pm UTC](https://forum.ansible.com/t/apt-module-with-list-of-packages/15699 "2014-07-17T20:12:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Clark](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@Jason\_Clark](https://forum.ansible.com/u/Jason_Clark)\
**Post date:** [July 17, 2014, 8:12pm UTC](https://forum.ansible.com/t/apt-module-with-list-of-packages/15699/1 "2014-07-17T20:12:53Z")

</div>

Is there a way to have a file i.e system-requirements.txt with a package per line and have the apt module install that? Exactly how pip works…

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 18, 2014, 1:42am UTC](https://forum.ansible.com/t/apt-module-with-list-of-packages/15699/2 "2014-07-18T01:42:24Z")

</div>

apt is not pip, but we have some very nice lookup plugins that are useful.

- apt: name={{ item }} state=installed  
with\_pipe: cat /path/to/file.txt

Note that the file.txt is assumed to be on the control machine.

Alternatively, you could register the result of running ls and loop through “result.stdout\_lines”

---

<div class="post-metadata">

**Author:** ![Jason\_Clark](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@Jason\_Clark](https://forum.ansible.com/u/Jason_Clark)\
**Post date:** [July 18, 2014, 4:33pm UTC](https://forum.ansible.com/t/apt-module-with-list-of-packages/15699/3 "2014-07-18T16:33:56Z")

</div>

Thanks Michael. Yeah I didn’t mean pip == apt but that the apt module in ansible take a file like the pip module does.

Here is what I ended up with in case anyone else needs to do the same thing.

- name: Ensure all base system packages are installed  
sudo: true  
apt: pkg={{ item }} state=installed  
with\_lines: cat …/files/base-packages.txt
