# Ubuntu - Automate entering GRUB bootloader password after rebooting?

**URL:** <https://forum.ansible.com/t/ubuntu-automate-entering-grub-bootloader-password-after-rebooting/8769>\
**Category:** Get Help\
**Tags:** playbook, ubuntu\
**Created:** [September 25, 2024, 4:39pm UTC](https://forum.ansible.com/t/ubuntu-automate-entering-grub-bootloader-password-after-rebooting/8769 "2024-09-25T16:39:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stipemd](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@stipemd](https://forum.ansible.com/u/stipemd)\
**Post date:** [September 25, 2024, 4:39pm UTC](https://forum.ansible.com/t/ubuntu-automate-entering-grub-bootloader-password-after-rebooting/8769/1 "2024-09-25T16:39:52Z")

</div>

I have some servers that are on Ubuntu 22.04. I’m very much an amateur when it comes to Ansible.

So far (using playbooks found online), I was able to automate the updates and reboots of the servers. But each time they reboot, I need to enter the bootloader password for them to finish rebooting.

Is there any way I can also have Ansible enter the bootloader username and password? Because technically I can’t SSH into the servers as long as the password hasn’t been entered so I don’t see how Ansible would be able to either.

This is the playbook I use if needed at all:

```auto
- name: Update and, if necessary, reboot Ubuntu servers
  hosts: ubuntu
  become: true
  become_user: root

  tasks:
    - name: Ping my hosts
      ansible.builtin.ping:
      tags:
        - ping

    - name: Update apt repo and cache on all Ubuntu boxes
      ansible.builtin.apt:
        update_cache: yes 
        force_apt_get: yes
        cache_valid_time: 3600
    - name: update apt list
      ansible.builtin.apt:
        update_cache: yes
        cache_valid_time: 3600

    - name: Upgrade all packages on servers
      ansible.builtin.apt:
        upgrade: dist
        force_apt_get: yes

    - name: Check if reboot is needed on all servers
      register: reboot_required_file
      ansible.builtin.stat:
        path: /var/run/reboot-required
        get_checksum: false

    - name: Reboot (if required)
      when: reboot_required_file.stat.exists
      ansible.builtin.reboot:
        msg: "Reboot initiated by Ansible for updates"
        connect_timeout: 5
        reboot_timeout: 300
        pre_reboot_delay: 0
        post_reboot_delay: 30
        test_command: uptime

```

---

<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:** [September 25, 2024, 5:11pm UTC](https://forum.ansible.com/t/ubuntu-automate-entering-grub-bootloader-password-after-rebooting/8769/2 "2024-09-25T17:11:29Z")

</div>

This seems like a definite no go (to me).  
If they are VMs then maybe you could do something from the hypervisor level but otherwise it looks like a dead end.

---

<div class="post-metadata">

**Author:** ![stipemd](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@stipemd](https://forum.ansible.com/u/stipemd)\
**Post date:** [September 25, 2024, 5:28pm UTC](https://forum.ansible.com/t/ubuntu-automate-entering-grub-bootloader-password-after-rebooting/8769/3 "2024-09-25T17:28:24Z")

</div>

Yeah they are VMs. Probably won’t mess with the hypervisor given its managed by another team. Thanks for checking if its possible

---

<div class="post-metadata">

**Author:** ![bvitnik](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bvitnik/32/4132_2.png) [@bvitnik](https://forum.ansible.com/u/bvitnik)\
**Post date:** [September 25, 2024, 10:30pm UTC](https://forum.ansible.com/t/ubuntu-automate-entering-grub-bootloader-password-after-rebooting/8769/4 "2024-09-25T22:30:47Z")

</div>

If this is a VM on VMware platform, you can use this Ansible module to send any string or key combination (including bootloader password) to the virtual console of the VM:

[https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware\_guest\_sendkey\_module.html](https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware_guest_sendkey_module.html)

But yes, for this to work, you will need access to vCenter or ESXi.

---

<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:** [October 25, 2024, 10:31pm UTC](https://forum.ansible.com/t/ubuntu-automate-entering-grub-bootloader-password-after-rebooting/8769/5 "2024-10-25T22:31:35Z")

</div>

Closed on October 25, 2024, 10:31pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
