Skip to content

Commit

Permalink
:try/catch dmesg during grains collection
Browse files Browse the repository at this point in the history
  • Loading branch information
Akm0d committed Dec 3, 2024
1 parent 9d10d69 commit d0bb349
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog/67083.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ubuntu can run salt-master without root
12 changes: 9 additions & 3 deletions salt/grains/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,9 +1105,15 @@ def _virtual(osdata):
if os.path.isdir("/sys/bus/xen/drivers/xenconsole"):
# An actual DomU will have the xenconsole driver
grains["virtual_subtype"] = "Xen PV DomU"
elif "xen:" in __salt__["cmd.run"]("dmesg").lower():
# Fallback to parsing dmesg, might not be successful
grains["virtual_subtype"] = "Xen PV DomU"
else:
try:
if "xen:" in __salt__["cmd.run"]("dmesg").lower():
# Fallback to parsing dmesg, might not be successful
grains["virtual_subtype"] = "Xen PV DomU"
except salt.exceptions.CommandExecutionError as e:
log.debug(
"Could not detect virtual_subtype with dmesg: {}".format(e)
)
# If a Dom0 or DomU was detected, obviously this is xen
if "dom" in grains.get("virtual_subtype", "").lower():
grains["virtual"] = "xen"
Expand Down

0 comments on commit d0bb349

Please sign in to comment.