Bug 1587954

Summary: Os-prober invoked from grub2-mkconfig through Ansible fails because the command blkid is not found
Product: [Fedora] Fedora Reporter: Marc van der Wijst <mvanderwijst>
Component: os-proberAssignee: Hedayat Vatankhah <hedayatv>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 28CC: agk, hedayatv
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-06-08 20:03:33 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Simple playbook to prove the bug none

Description Marc van der Wijst 2018-06-06 10:31:30 UTC
Description of problem:
If "/usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg" is executed through Ansible, it fails to run os-prober. This is the stderr output:
        "Generating grub configuration file ...", 
        "Found theme: /boot/grub2/themes/system/theme.txt", 
        "Found linux image: /boot/vmlinuz-4.16.12-300.fc28.x86_64", 
        "Found initrd image: /boot/initramfs-4.16.12-300.fc28.x86_64.img", 
        "Found linux image: /boot/vmlinuz-4.16.3-301.fc28.x86_64", 
        "Found initrd image: /boot/initramfs-4.16.3-301.fc28.x86_64.img", 
        "Found linux image: /boot/vmlinuz-0-rescue-e16e9a0dd466434eae3e21c4b681a172", 
        "Found initrd image: /boot/initramfs-0-rescue-e16e9a0dd466434eae3e21c4b681a172.img", 
        "/usr/bin/os-prober: line 91: blkid: command not found", 
        "/usr/bin/os-prober: line 172: blkid: command not found", 
        "/usr/bin/os-prober: line 172: blkid: command not found", 
        "/usr/bin/os-prober: line 172: blkid: command not found", 
        "/usr/bin/os-prober: line 172: blkid: command not found", 
        "/usr/bin/os-prober: line 172: blkid: command not found", 
        "done"

The program blkid is invoked in os-prober without a full path. It lives is /usr/sbin/blkid.

The actual result is that other OSes cannot be found when building a new grub.cfg.


Version-Release number of selected component (if applicable):
os-prober.x86_64 1.74-6.fc28


How reproducible:
Create a simple Ansible playbook that executes
  name: Build grub.cfg
  command: /usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg
Run it with -vvvv to get detailed logging.


Actual results:
The program blkid cannot be found by os-prober. Probably because the full path is not used. As a result other OSes cannot be found when building a new grub.cfg.


Expected results:
The build of grub.cfg succeeds without errors.


Additional info:
Using a direct command works fine.
ansible hostname -m command -a "/usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg" -b -K -vvvv

Comment 1 Marc van der Wijst 2018-06-06 11:24:31 UTC
Created attachment 1448291 [details]
Simple playbook to prove the bug

Content of bug-1587954.yml

# Simple Ansible script to prove bug 1587954
#
# Preparation:
# Install ansible: dnf install ansible
# Replace hostname by actual hostname below
# Add hostname to /etc/ansible/hosts
# Execute playbook: ansible-playbook ./bug-1587954.yml -b -K -vvvv

---
- hosts: hostname
  become: yes
  become_method: su
  gather_facts: False
  tasks:
  - name: Build grub.cfg
    command: /usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg

Comment 2 Hedayat Vatankhah 2018-06-06 20:46:40 UTC
Hi,
Thank you for your feedback. However, I don't see how is it considered an os-prober bug; and I wonder why it works when it is called directly (not in a playbook). 
Anyway, if os-prober expects binaries to be found in current PATH, I guess it is a fair expectation. Calling just blkid with full PATH is not justified. Either os-prober should call everything with full PATH, or not. 

Anyway, as /usr/sbin is in Fedora default PATH, I wonder why ansible doesn't provide it. Maybe it is a bug in Ansible? Although, I still cannot understand why it works when called directly rather than in a play-book. Does ansible behave differently?

Hey... maybe it is because of disabling fact gathering?

Comment 3 Marc van der Wijst 2018-06-08 20:02:48 UTC
Hi Hedayat,

Thank you for your answer. I don't know how why the PATH variable is not respected by Ansible and what the difference is. Did a search on it but found no leads. It is fair to say that Ansible should be able to find binaries in /usr/sbin. So just close this one off, as this seems to be one for Ansible.


Kind regards,
Marc

Comment 4 Hedayat Vatankhah 2018-06-08 20:36:42 UTC
Thanks :)