# Ansilbe apt handling of dpkg\_options

**URL:** <https://forum.ansible.com/t/ansilbe-apt-handling-of-dpkg-options/23216>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [December 9, 2016, 4:41pm UTC](https://forum.ansible.com/t/ansilbe-apt-handling-of-dpkg-options/23216 "2016-12-09T16:41:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adam.frederick](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@adam.frederick](https://forum.ansible.com/u/adam.frederick)\
**Post date:** [December 9, 2016, 4:41pm UTC](https://forum.ansible.com/t/ansilbe-apt-handling-of-dpkg-options/23216/1 "2016-12-09T16:41:54Z")

</div>

I am attempting to perform the follow in order to only upgrade ubuntu security updates…

apt: upgrade=yes update\_cache=yes dpkg\_options=‘Dir::Etc::SourceList=/etc/apt/security.sources.list’

and I receive the following error message…

FAILED! =\> {“changed”: false, “failed”: true, “msg”: “‘/usr/bin/aptitude safe-upgrade’ failed: E: Sub-process /usr/bin/dpkg returned an error code (2)\nFailed to perform requested operation on package. Trying to recover:\n”, “stdout”: "Reading package lists…\nBuilding dependency tree…\nReading state information…\nReading extended state information…\nInitializing package states…\nBuilding tag database…\nThe following packages will be upgraded:\n apport libc-bin libc6 locales multiarch-support python3-apport \n python3-problem-report snapd \n8 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.\nNeed to get 0 B/12.8 MB of archives. After unpacking 623 kB will be freed.\nWriting extended state information…\nPreconfiguring packages …\ndpkg: error: unknown option --Dir::Etc::SourceList=/etc/apt/security.sources.list\r\n\r\nType dpkg

I am trying to replicate this functioning command…

apt update && apt-get upgrade -o Dir::Etc::SourceList=/etc/apt/security.sources.list

Any advice on the best way to handle this or some better examples on dpkg\_options?

Thank you,  
Adam

---

<div class="post-metadata">

**Author:** ![adam.frederick](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@adam.frederick](https://forum.ansible.com/u/adam.frederick)\
**Post date:** [January 13, 2017, 2:44pm UTC](https://forum.ansible.com/t/ansilbe-apt-handling-of-dpkg-options/23216/2 "2017-01-13T14:44:19Z")

</div>

Any help on this? This is still an issue. It appears the module ignores any other source files I have and just uses sources.list. Any suggestions?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [January 13, 2017, 3:28pm UTC](https://forum.ansible.com/t/ansilbe-apt-handling-of-dpkg-options/23216/3 "2017-01-13T15:28:00Z")

</div>

> I am attempting to perform the follow in order to only upgrade ubuntu  
> security updates...
> 
> &nbsp;&nbsp;&nbsp;&nbsp;apt: upgrade=yes update\_cache=yes  
> dpkg\_options='Dir::Etc::SourceList=/etc/apt/security.sources.list'

The dpkg\_options is for the "-o Dpkg::Options::=--\<something\>" where \<something\> is what you add to the dpkg\_options.

> I am trying to replicate this functioning command...
> 
> apt update && apt-get upgrade -o  
> Dir::Etc::SourceList=/etc/apt/security.sources.list
> 
> Any advice on the best way to handle this or some better examples on  
> dpkg\_options?

apt module doesn't support Dir::Etc::SourceList so the shell module is an alternative.

- shell: apt update && apt-get upgrade -o Dir::Etc::SourceList=/etc/apt/security.sources.list

---

<div class="post-metadata">

**Author:** ![adam.frederick](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@adam.frederick](https://forum.ansible.com/u/adam.frederick)\
**Post date:** [January 16, 2017, 3:40pm UTC](https://forum.ansible.com/t/ansilbe-apt-handling-of-dpkg-options/23216/4 "2017-01-16T15:40:30Z")

</div>

Thank you! That did it!
