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

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:

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

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 vào lúc 16:24 Dick Visser <dick.visser@geant.org> đã viết:

You can try 'with_lines.
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

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.

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
         Racke

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: