Running update grub-pc in noninteractive mode

152 views
Skip to first unread message

Kathy L

unread,
Oct 23, 2023, 6:14:33 AM10/23/23
to Ansible Project
We are trying to update packages on several AWS servers via ansible. In the beginning of our playbook we have the environment to noninteractive like this:
    environment:
       DEBIAN_FRONTEND: noninteractive

When I run an update (or try to install anything, I get the error stating "/dev/sda does not exist". That is because for example, when provisioning AWS nodes, the disk type is not /dev/sda but something else.  

My question is how do i run update grub-pc with a specific disk?  I'm assuming I would get the disk "name" from ansible_facts (devices), grab the first disk, then run something similar to  "apt install grub-pc /dev/nvme01"

Is there a way to do this?  I tried the line above and it failed and I'm out of ideas. 

Thanh Nguyen Duc

unread,
Oct 23, 2023, 6:36:18 AM10/23/23
to ansible...@googlegroups.com
You may try to gather fact, register the fact then execute the command in the next task. For me i usually  use shell to query what i need before proceeding next step, save a bit of time.

--- Example:
---
- name: Set location
  hosts: localhost
  connection: local
  gather_facts: false
  tasks:
  - name: Output disk information
    shell: fdisk -l /dev/sda | grep '^/dev' | cut -d' ' -f1
    register: myoutput
  - name: install
    shell: echo "{{myoutput.stdout_lines}}"





Vào Th 2, 23 thg 10, 2023 vào lúc 18:14 Kathy L <lyon...@gmail.com> đã viết:
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/2d19e75c-e914-48ce-af23-7d5ec79c2872n%40googlegroups.com.

Kathy Lyons

unread,
Oct 23, 2023, 6:46:00 AM10/23/23
to ansible...@googlegroups.com
The only issue is that I don't know what the name of the disk is - /dev/sda, dev/nvme0n1p1, etc.

You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/7EUtcfIe23E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CA%2BnV635dwsmrtjGWE0bwSDmaq4_0a0A3GXS1oM2XikYJ03823A%40mail.gmail.com.

Thanh Nguyen Duc

unread,
Oct 23, 2023, 6:59:31 AM10/23/23
to ansible...@googlegroups.com
Example if you know your command only need to execute from the first disk

fdisk -l | grep "^/dev/" | cut -d' ' -f1

You may need to custom abit then.

Vào Th 2, 23 thg 10, 2023 vào lúc 18:45 Kathy Lyons <lyon...@gmail.com> đã viết:

Dick Visser

unread,
Oct 23, 2023, 7:15:44 AM10/23/23
to ansible...@googlegroups.com
What exactly do you mean by 'update packages'?
We're using Debian EC2 instances and never had to bother with manually selecting disks/devices...



--

Kathy Lyons

unread,
Oct 23, 2023, 7:31:53 AM10/23/23
to ansible...@googlegroups.com
That's great - thank you!

Now, does anyone know how I can do an "update grub-pc" with that particular hard drive so it doesn't prompt me for the disk drive?

You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/7EUtcfIe23E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAF8BbLaxPOjwSUUMLshJyZ4k9mv05TEMjV5Ud-T2dHv-6jifZg%40mail.gmail.com.

Kathy Lyons

unread,
Oct 23, 2023, 7:34:30 AM10/23/23
to ansible...@googlegroups.com
Dick - just this morning I went to update packages on an AWS instance and it failed because the disk was not /dev/sda.  I had to logon to the box, issue apt update -y, then a dialog popped up asking me for the drive to install grub-pc on.

Dick Visser

unread,
Oct 23, 2023, 8:50:31 AM10/23/23
to ansible...@googlegroups.com

Kathy Lyons

unread,
Oct 23, 2023, 9:09:06 AM10/23/23
to ansible...@googlegroups.com
A generic Deb 11 image - not one we "own". 

Reply all
Reply to author
Forward
0 new messages