Custom facts in foreman

Hello everybody,
i’m trying to write a custom fact, which shows the scsi-id for a disk. But Foreman (version 2.0.0) seems to convert the scsi-id string to int (“0:0:1:0” -> 1).
What can i do so that foreman does not convert the string to an int?

The output of facter(version: 3.14.12 ) looks like:

{
  sdb => {
    pci_device_name => "LSI Logic Parallel SCSI Controller",
    pci_device_slot => "",
    scsi_id => "0:0:1:0",
    size_byte => 10737418240,
    size => "10 GiB"
  },
  sda => {
    pci_device_name => "LSI Logic Parallel SCSI Controller",
    pci_device_slot => "",
    scsi_id => "0:0:0:0",
    size_byte => 42949672960,
    size => "40 GiB"
  },
  sdc => {
    pci_device_name => "LSI Logic Parallel SCSI Controller",
    pci_device_slot => "",
    scsi_id => "0:0:2:0",
    size_byte => 32212254720,
    size => "30 GiB"
  }
}

I wonder if this is a problem in the YAML conversion somewhere. If you look what’s in /opt/puppetlabs/server/data/puppetserver/yaml/node, is it quoted?

My theory is that Ruby 2.5 as part of Puppet 6 it uses YAML 1.2 and doesn’t quote it. Then the Foreman ENC script uses Ruby 2.0 which uses an older YAML spec that still support sexagesimal numbers (see https://yaml.org/spec/1.1/#id858600).

We’ve had similar “fun” with mac addresses.

hi,
the output from the puppetserver is not quoted :frowning: Here the output from another server:

sda:
  pci_device_name: PVSCSI SCSI Controller
  pci_device_slot: '192'
  scsi_id: 0:0:0:0
  size_byte: 42949672960
  size: 40 GiB
sdb:
  pci_device_name: PVSCSI SCSI Controller
  pci_device_slot: '192'
  scsi_id: 0:0:1:0
  size_byte: 21474836480
  size: 20 GiB
sdc:
  pci_device_name: PVSCSI SCSI Controller
  pci_device_slot: '192'
  scsi_id: 0:0:2:0
  size_byte: 42949672960
  size: 40 GiB

What did you do to solve the problem with mac addresses?

The SCSI IDs do not match the regex so they’re not replaced. As a workaround you can also change the shebang to a newer Ruby version, like /usr/bin/tfm-ruby or /opt/puppetlabs/puppet/bin/ruby.