Ask Your Question

extra character output from facter

asked 2017-12-28 02:57:59 -0600

kuro gravatar image

updated 2017-12-29 12:59:26 -0600

stivesso gravatar image


First of all i'm sorry if i missed a similar topic, tried searching but couldnt find it.

I have a facter file that outputs extra characters. If I were to run the query individually i get my desired output, but if i include puppet formats it has extra characters garbage;

My code is as per below, to query via wmi a server's domain role;

Facter.add(:w2k8_systemrole) do
  confine :kernel => :windows
  setcode do
    value = "unknown"
        value = Facter::Core::Execution.exec('C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy remotesigned -Command "& {(Get-WmiObject win32_computersystem).DomainRole}"')
       if value != "*"
         value = value
         value = "DomainRole is not defined for the system."

instead of "2" i get ƒ^cƒ-ƒ"?2. Please help, thanks.

Regards, Kuro

edit retag flag offensive close merge delete


I have no idea, what your command's supposed to do, but it returns a string, which you may value.sub(/x$/, '') where `x` is your extra character (at the end of the string [dollar-sign]). This is more of a quick'n'dirty work-around, though.

Kai Burghardt gravatar imageKai Burghardt ( 2017-12-30 16:10:08 -0600 )edit

1 Answer

Sort by » oldest newest most voted

answered 2018-01-02 22:36:54 -0600

kuro gravatar image

Hi Kai,

Thats a great workaround. I added this line to filter the output:

value.sub(/^\S\S\S/, '')

Will just go with this in the meantime.


edit flag offensive delete link more


You may want to try `value.sub(/\D/, '')` which will replace all non-digits (assuming the answer is always a digit) regardless of any changes in non-printable formatting.

rnelson0 gravatar imagernelson0 ( 2018-01-05 08:40:06 -0600 )edit

No, this is not a quote-unquote great workaround. You update your software, it's output changes, and your fact's value silently breaks.

Kai Burghardt gravatar imageKai Burghardt ( 2018-01-05 09:12:14 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2017-12-28 02:57:59 -0600

Seen: 584 times

Last updated: Jan 02