# error configuring grub-pc

**URL:** <https://forum.ansible.com/t/error-configuring-grub-pc/38606>\
**Category:** Ansible Project\
**Created:** [November 28, 2023, 4:42pm UTC](https://forum.ansible.com/t/error-configuring-grub-pc/38606 "2023-11-28T16:42:57Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kathy\_L](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kathy_l/32/2652_2.png) [@Kathy\_L](https://forum.ansible.com/u/Kathy_L)\
**Post date:** [November 28, 2023, 4:42pm UTC](https://forum.ansible.com/t/error-configuring-grub-pc/38606/1 "2023-11-28T16:42:57Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [November 28, 2023, 6:14pm UTC](https://forum.ansible.com/t/error-configuring-grub-pc/38606/2 "2023-11-28T18:14:43Z")

</div>

That variable has a ‘-’ instead of an ‘\_’

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [November 28, 2023, 7:12pm UTC](https://forum.ansible.com/t/error-configuring-grub-pc/38606/3 "2023-11-28T19:12:09Z")

</div>

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](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/dpkg_selections_module.html)

---

<div class="post-metadata">

**Author:** ![Kathy\_L](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kathy_l/32/2652_2.png) [@Kathy\_L](https://forum.ansible.com/u/Kathy_L)\
**Post date:** [December 18, 2023, 12:21pm UTC](https://forum.ansible.com/t/error-configuring-grub-pc/38606/4 "2023-12-18T12:21:10Z")

</div>

Brian,  
Not quite sure I understand. Will holding grub-pc cause other problems in the long-term?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [December 18, 2023, 5:02pm UTC](https://forum.ansible.com/t/error-configuring-grub-pc/38606/5 "2023-12-18T17:02:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [December 18, 2023, 5:04pm UTC](https://forum.ansible.com/t/error-configuring-grub-pc/38606/6 "2023-12-18T17:04:36Z")

</div>

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](https://github.com/bcoca/ansible-oracle_java7-role/blob/master/tasks/main.yml#L17)

---

<div class="post-metadata">

**Author:** ![Kathy\_L](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kathy_l/32/2652_2.png) [@Kathy\_L](https://forum.ansible.com/u/Kathy_L)\
**Post date:** [December 19, 2023, 1:22pm UTC](https://forum.ansible.com/t/error-configuring-grub-pc/38606/7 "2023-12-19T13:22:12Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [December 19, 2023, 3:15pm UTC](https://forum.ansible.com/t/error-configuring-grub-pc/38606/8 "2023-12-19T15:15:19Z")

</div>

that should be good, the other is probably the resolved path from a  
symlink (/dev/ does this a lot)

---

<div class="post-metadata">

**Author:** ![Kathy\_L](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kathy_l/32/2652_2.png) [@Kathy\_L](https://forum.ansible.com/u/Kathy_L)\
**Post date:** [December 20, 2023, 11:45am UTC](https://forum.ansible.com/t/error-configuring-grub-pc/38606/9 "2023-12-20T11:45:05Z")

</div>

![Kathy L's profile photo](https://lh3.googleusercontent.com/a/ACg8ocLDl7Q4-2-XjL6xOGHRRPdPmr3lMecKORoGANOUapTF=s40-c-mo)

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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [December 20, 2023, 2:51pm UTC](https://forum.ansible.com/t/error-configuring-grub-pc/38606/10 "2023-12-20T14:51:16Z")

</div>

The module requires the utils, but the debconf CLI itself does not and should already be installed.

---

<div class="post-metadata">

**Author:** ![Kathy\_L](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kathy_l/32/2652_2.png) [@Kathy\_L](https://forum.ansible.com/u/Kathy_L)\
**Post date:** [April 8, 2024, 11:01am UTC](https://forum.ansible.com/t/error-configuring-grub-pc/38606/11 "2024-04-08T11:01:24Z")

</div>

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
