snippetbashModerate
How to keep configuration files automatically during apt-get upgrade or install?
Viewed 0 times
installduringautomaticallykeepaptfilesgethowconfigurationupgrade
Problem
When performing and
I know that
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.
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.
Solution
There are options you can pass through apt-get to dpkg that will handle the config choices. We usually do something like:
When using ansible you can do:
For further details on the ansible apt module options look here
apt-get install -y --no_install_recommends -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' 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:
- For further details on the ansible apt module options look here
Code Snippets
apt:
pkg: "{{ item }}"
only_upgrade: yes
install_recommends: no
force: yes
dpkg_options: 'force-confdef,force-confold'
state: latest
with_items:
- <package_name>Context
StackExchange DevOps Q#4912, answer score: 17
Revisions (0)
No revisions yet.