Uploaded image for project: 'Facter'
  1. Facter
  2. FACT-2869

Puppet 7.0.0 facter changes is_virtual fact to string (from boolean)

    XMLWordPrintable

    Details

    • Template:
    • Team:
      Night's Watch
    • Sub-team:
    • Sprint:
      ghost 25.11, ghost-2.12, ghost-9.12
    • Method Found:
      Needs Assessment
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Fixes regression that caused the 'is_virtual' to be string instead of boolean
    • QA Risk Assessment:
      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

            Activity

              People

              Assignee:
              oana.tanasoiu Oana Tanasoiu
              Reporter:
              ralston James Ralston
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support