# Install packages from a file where list all of packages that need to install to remote server.

**URL:** <https://forum.ansible.com/t/install-packages-from-a-file-where-list-all-of-packages-that-need-to-install-to-remote-server/31746>\
**Category:** Ansible Project\
**Created:** [November 29, 2019, 7:52am UTC](https://forum.ansible.com/t/install-packages-from-a-file-where-list-all-of-packages-that-need-to-install-to-remote-server/31746 "2019-11-29T07:52:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Toan\_Huynh\_Van](https://avatars.discourse-cdn.com/v4/letter/t/a587f6/32.png) [@Toan\_Huynh\_Van](https://forum.ansible.com/u/Toan_Huynh_Van)\
**Post date:** [November 29, 2019, 7:52am UTC](https://forum.ansible.com/t/install-packages-from-a-file-where-list-all-of-packages-that-need-to-install-to-remote-server/31746/1 "2019-11-29T07:52:53Z")

</div>

Hi all,

I would like to install many packages from a file where I collected all of the packages and put them into this file (like a manifest file). But unfortunately, I’m stuck at a shell command “apt-get dselect-upgrade -y”, it’s hung without output, so I don’t know what was going on. I also try with another shell command " dselect install" but the same behavior.

My ansible scripts as below:

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [November 29, 2019, 9:24am UTC](https://forum.ansible.com/t/install-packages-from-a-file-where-list-all-of-packages-that-need-to-install-to-remote-server/31746/2 "2019-11-29T09:24:27Z")

</div>

Why not simply supply the list of packages list to the apt (or package) module?

---

<div class="post-metadata">

**Author:** ![Toan\_Huynh\_Van](https://avatars.discourse-cdn.com/v4/letter/t/a587f6/32.png) [@Toan\_Huynh\_Van](https://forum.ansible.com/u/Toan_Huynh_Van)\
**Post date:** [November 30, 2019, 4:12am UTC](https://forum.ansible.com/t/install-packages-from-a-file-where-list-all-of-packages-that-need-to-install-to-remote-server/31746/3 "2019-11-30T04:12:24Z")

</div>

Thanks Dick,  
because I need to install so many packages, around 400 packages, so I would like to put it into a file and install from that file. Is there any way to install the packages like that?

Vào Th 6, 29 thg 11, 2019 vào lúc 16:24 Dick Visser \<[dick.visser@geant.org](mailto:dick.visser@geant.org)\> đã viết:

---

<div class="post-metadata">

**Author:** ![Michael\_M1](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@Michael\_M1](https://forum.ansible.com/u/Michael_M1)\
**Post date:** [November 30, 2019, 4:29am UTC](https://forum.ansible.com/t/install-packages-from-a-file-where-list-all-of-packages-that-need-to-install-to-remote-server/31746/4 "2019-11-30T04:29:10Z")

</div>

You can try 'with\_lines.  
[https://docs.ansible.com/ansible/latest/plugins/lookup/lines.html?highlight=with\_line](https://docs.ansible.com/ansible/latest/plugins/lookup/lines.html?highlight=with_line)

An example would look something like this. But as Dick suggested, use the module’s functionality. Have only one package name per line in apt.manifest (leave out ‘install’), and specify ‘state: present’ (which is the default) in the task:

- apt:  
name: “{{ item }}”  
state: present  
with\_lines: cat apt.manifest

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [November 30, 2019, 6:39am UTC](https://forum.ansible.com/t/install-packages-from-a-file-where-list-all-of-packages-that-need-to-install-to-remote-server/31746/5 "2019-11-30T06:39:36Z")

</div>

Also if you have that many packages and the length of the list is an issue, you could consider leaving out the packages that are dependencies of other packages.

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [November 30, 2019, 6:46am UTC](https://forum.ansible.com/t/install-packages-from-a-file-where-list-all-of-packages-that-need-to-install-to-remote-server/31746/6 "2019-11-30T06:46:18Z")

</div>

> Also if you have that many packages and the length of the list is an issue, you could consider leaving out the packages  
> that are dependencies of other packages.

I think it would be more efficient to pass all package names to apt instead of running a loop over all these packages.

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Toan\_Huynh\_Van](https://avatars.discourse-cdn.com/v4/letter/t/a587f6/32.png) [@Toan\_Huynh\_Van](https://forum.ansible.com/u/Toan_Huynh_Van)\
**Post date:** [December 2, 2019, 10:03am UTC](https://forum.ansible.com/t/install-packages-from-a-file-where-list-all-of-packages-that-need-to-install-to-remote-server/31746/7 "2019-12-02T10:03:19Z")

</div>

Thanks Michael so much, It worked for me.

Vào 11:30:04 UTC+7 Thứ Bảy, ngày 30 tháng 11 năm 2019, Michael M đã viết:
