Details
-
Bug
-
Status: Resolved
-
Normal
-
Resolution: Fixed
-
FACT 4.0.46
-
None
-
Night's Watch
-
ghost 25.11, ghost-2.12, ghost-9.12
-
Needs Assessment
-
Bug Fix
-
Fixes regression that caused the 'is_virtual' to be string instead of boolean
-
Needs Assessment
Description
In Puppet 6.x, facter reports the is_virtual fact as a boolean:
$ facter --version; facter --json is_virtual
|
3.14.14 (commit e36657bea27254f003c8fc71d8ef57454db643e2)
|
{
|
"is_virtual": false
|
}
|
But in Puppet 7.0.0, facter reports the is_virtual fact as a string:
$ facter --version; facter --json is_virtual
|
4.0.46
|
{
|
"is_virtual": "false"
|
}
|
This is almost certainly a regression, as the 7.0.0 documentation continues to state that the is_virtual fact is a boolean.
This is going to cause major breakage for any code that tests is_virtual as a boolean; e.g.:
if $facts['is_virtual'] {
|
# do stuff for VMs
|
} else {
|
# do stuff for physical hosts
|
}
|
In the above code, the do stuff for VMs block will always be executed, even for physical hosts, because the boolean evaluation of the String class is true if the length of the string is nonzero and false otherwise, and is_virtual will always have a nonzero length (either "true" or "false").
The easiest work-around for now is to test against the virtual fact instead; e.g.:
if $facts['virtual'] != 'physical' {
|
# do stuff for VMs
|
} else {
|
# do stuff for physical hosts
|
}
|
But again, this regression is going to burn people who have any code that tests against is_virtual.
Attachments
Issue Links
- is duplicated by
-
PA-3498 is_virtual retuns an string instant of an boolean
-
- Closed
-