# APT module to target only OS & not Application repo

**URL:** <https://forum.ansible.com/t/apt-module-to-target-only-os-not-application-repo/34663>\
**Category:** Ansible Project\
**Created:** [February 21, 2021, 9:40pm UTC](https://forum.ansible.com/t/apt-module-to-target-only-os-not-application-repo/34663 "2021-02-21T21:40:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kiran\_Kumar](https://avatars.discourse-cdn.com/v4/letter/k/f475e1/32.png) [@Kiran\_Kumar](https://forum.ansible.com/u/Kiran_Kumar)\
**Post date:** [February 21, 2021, 9:40pm UTC](https://forum.ansible.com/t/apt-module-to-target-only-os-not-application-repo/34663/1 "2021-02-21T21:40:52Z")

</div>

Hello  
Is there any way to target only primary OS related packages ?

- name: Update all packages to their latest version

apt:

name: “\*”

state: latest

At times 3rd Party packages are added to /etc/apt/sources.list

So what is best way to just patch the OS & not the app…

Any suggestions to handle this on scale …

Thanks

---

<div class="post-metadata">

**Author:** ![Kiran\_Kumar](https://avatars.discourse-cdn.com/v4/letter/k/f475e1/32.png) [@Kiran\_Kumar](https://forum.ansible.com/u/Kiran_Kumar)\
**Post date:** [February 21, 2021, 9:49pm UTC](https://forum.ansible.com/t/apt-module-to-target-only-os-not-application-repo/34663/2 "2021-02-21T21:49:34Z")

</div>

I am thinking like below

cat /etc/apt/sources.list |grep -v “#”

deb [http://us.archive.ubuntu.com/ubuntu/](http://us.archive.ubuntu.com/ubuntu/) bionic main restricted

deb [http://us.archive.ubuntu.com/ubuntu/](http://us.archive.ubuntu.com/ubuntu/) bionic-updates main restricted

deb [http://us.archive.ubuntu.com/ubuntu/](http://us.archive.ubuntu.com/ubuntu/) bionic universe  
deb [http://us.archive.ubuntu.com/ubuntu/](http://us.archive.ubuntu.com/ubuntu/) bionic-updates universe

deb [http://us.archive.ubuntu.com/ubuntu/](http://us.archive.ubuntu.com/ubuntu/) bionic multiverse  
deb [http://us.archive.ubuntu.com/ubuntu/](http://us.archive.ubuntu.com/ubuntu/) bionic-updates multiverse

deb [http://us.archive.ubuntu.com/ubuntu/](http://us.archive.ubuntu.com/ubuntu/) bionic-backports main restricted universe multiverse

---

<div class="post-metadata">

**Author:** ![Nuno\_Jordao](https://avatars.discourse-cdn.com/v4/letter/n/a4c791/32.png) [@Nuno\_Jordao](https://forum.ansible.com/u/Nuno_Jordao)\
**Post date:** [February 23, 2021, 4:42pm UTC](https://forum.ansible.com/t/apt-module-to-target-only-os-not-application-repo/34663/3 "2021-02-23T16:42:57Z")

</div>

Hello,

If you are trying to avoid certain known packages to be upgraded, you could try to pin them:

[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/dpkg\_selections\_module.html](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/dpkg_selections_module.html)

Nuno Jordão
