error configuring grub-pc

291 views
Skip to first unread message

Kathy L

unread,
Nov 28, 2023, 11:42:58 AM11/28/23
to Ansible Project
I have an ansible playbook running against a Debian 10 VM. At the top of my playbook I have this environment variable:
              environment:
                DEBIAN-FRONTEND: noninteractive
             
When I try to install any package, or update all packages I get the following error:
               .....
             Setting up grub-pc..
              /dev/sda does not exist, so cannot grub-install to it!
              You must correct your GRUB install devices before proceeding

               DEBIAN_FRONTEND=dialog dpkg --configure grub-pc
                dpkg --configure -a
               dpkg: error processing package grub-pc
                installed grub-pc package post-installation script subprocess returne error exit status 1
                dpkg: depending problems prevent configuration of grub2:
               grub2 depends on grub-pc (= 2.06-3-deb10u4); however:
               Package grub-pc is not configured yet.

Where is /dev/sda set as the disk to run grub-pc against? (Or is that the default?) Do I have to find the real hard drive and pass it to grub-pc?  I obviously don't want a dialog to pop up as this will be running against multiple machines, some of which I can't ssh into.

Can anyone help me figure out how to get around this?


Dick Visser

unread,
Nov 28, 2023, 1:15:07 PM11/28/23
to ansible...@googlegroups.com


Sent from Gmail Mobile


On Tue, 28 Nov 2023 at 17:43, Kathy L <lyon...@gmail.com> wrote:
I have an ansible playbook running against a Debian 10 VM. At the top of my playbook I have this environment variable:
              environment:
                DEBIAN-FRONTEND: noninteractive


That variable has a '-' instead of an '_'


Brian Coca

unread,
Nov 28, 2023, 2:12:35 PM11/28/23
to ansible...@googlegroups.com
See dpkg_selections module to PRE populate answers/settings for
packages when there are no defaults or (like your case) the defaults
do not work.
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/dpkg_selections_module.html
--
----------
Brian Coca

Kathy L

unread,
Dec 18, 2023, 7:21:10 AM12/18/23
to Ansible Project
Brian,
Not quite sure I understand.  Will holding grub-pc cause other problems in the long-term?

Brian Coca

unread,
Dec 18, 2023, 12:03:11 PM12/18/23
to ansible...@googlegroups.com
Not 'holding' but you pre populate the questions to avoid the
prompting. Sadly `DEBIAN-FRONTEND: noninteractive` is not enough to
avoid prompts when the package requires and answer, so the only way
around this issue is 'answering before they ask', dpkg_selections
allows you to do this.

--
----------
Brian Coca (he/him/yo)

Brian Coca

unread,
Dec 18, 2023, 12:04:59 PM12/18/23
to ansible...@googlegroups.com
Sorry, I meant debconf, not dpkg_selections (not sure why I keep
confusing those), here is an example of me doing the same for
installing java package.

https://github.com/bcoca/ansible-oracle_java7-role/blob/master/tasks/main.yml#L17

Kathy L

unread,
Dec 19, 2023, 8:22:12 AM12/19/23
to Ansible Project
That make sense.  I am trying to upgrade grub-pc which then prompts for the hard drive where / is mounted.  When I type in debconf-show grub-pc I get a number of variables, including "install_devices".  I expect this to be something like /dev/sda or dev/nvme0n1p1, but instead it reads something similar to "/dev/disk/by-id/ata-LITEONIT_LCS256M6S...... 

This is what I expected to do with the debconf module:

ansible.builtin.debconf:
    name: grub-pc
   question:  Grub Install devices
   value: /dev/nvme0n1p1  (or whatever ansible facts gives me)
  vtype: select


Is that correct or do I have to someone figure out the /dev/disk/by-id..... variable?

Brian Coca

unread,
Dec 19, 2023, 10:15:48 AM12/19/23
to ansible...@googlegroups.com
that should be good, the other is probably the resolved path from a
symlink (/dev/ does this a lot)
Message has been deleted

Kathy L

unread,
Dec 20, 2023, 6:45:05 AM12/20/23
to Ansible Project

I took your suggestion to use debconf.  The only issue is that in order to use debconf, I have to install debconf-utils.  And when I try to install that, it tries to install grub-pc and the dialog appears.

I'm not sure where to go from here - I can't update grub-pc or install anything without it trying to update grub-pc and bringing up a dialog box.

In the beginning of my playbook I have this:

  environment:
   DEBIAN_FRONTEND: noninteractive

which doesn't seem to have any effect.  (Someone suggested that it should be debian-frontend, but I did some research and it is indeed debian_frontend.)

Does anyone see how I can get around this issue?

Brian Coca

unread,
Dec 20, 2023, 9:51:42 AM12/20/23
to ansible...@googlegroups.com
The module requires the utils, but the debconf CLI itself does not and should already be installed.
----------
Brian Coca (he/him/yo)

Kathy L

unread,
Apr 8, 2024, 7:01:24 AM4/8/24
to Ansible Project
I'm back.  Now the problem I have has migrated to Debian 11.  I am trying to update packages which gives me the error below. So then I try to install grub-pc by its own which does not work.  Any further ideas?

Here is the code I am using and still I get the error "dpkg: dependency problems prevent configuration of grub2" and my ansible playbook dies.


- name: Get drive
  set_fact:
    drive_name: "{{ ansible_mounts| json_query(query) }}"
  vars:
    query: "[?mount=='/'].device"

- name: Install debconf-utils
  apt:
    name: debconf-utils
state: present

- name: setup grub-pc
  shell: echo "grub-pc grub-pc/install_devices multiselect {{ drive_name }}" | debonf-set-selections
 
- name: setup debconf
  shell" echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections"

- name: Copy debconf selections
  debconf-set-selections | grep grub-pc > /tmp/grubpc.debconf
 
- name: Load new grub-pc config
  shell: debconf-set-selections < /tmp/grubpc.debconf

- name: Install grub
  apt:
    name: "{{ item }}"
state: latest
  environment:
    DEBIAN_FRONTEND: noninteractive
  loop:
    - grub-pc
- grub

Reply all
Reply to author
Forward
0 new messages