6

When performing and apt-get update; apt-get upgrade -y on a server I encountered the message:

Setting up sudo (1.8.16-0ubuntu1.5) ...

Configuration file '/etc/sudoers'
==> Modified (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
The default action is to keep your current version.
*** sudoers (Y/I/N/O/D/Z) [default=N] ?
Setting up ubuntu-minimal (1.361.1) ...

I know that debconf can be used to configure packages, like MySQL, to answer questions to prompts.

Which Linux Program/Module/Function/etc should I use to prepare an answer to this prompt?

I would really like to know a solution that be performed via Ansilbe if one exists. In addition to a BASH script.

Please note: ALL my distributions are done via IaC and thus automation is critical.

5

There are options you can pass through apt-get to dpkg that will handle the config choices. We usually do something like:

apt-get install -y --no_install_recommends -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' <package_name>

When using ansible you can do:

  apt:
    pkg: "{{ item }}"
    only_upgrade: yes
    install_recommends: no
    force: yes
    dpkg_options: 'force-confdef,force-confold'
    state: latest
  with_items:
    - <package_name>

For further details on the ansible apt module options look here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.