Not pulling facter facts

32 views
Skip to first unread message

Michael Holt

unread,
Aug 5, 2015, 2:40:17 PM8/5/15
to Simian Discuss
For some reason it seems like Simian refuses to pull any facts from facter.  I have puppet, facter, and hiera installed.  It also doesn't seem to be listening to settings.cfg

EX:
Hostname is being set to foohost
running "facter" returns "hostname => MacBook-Pro"
I modified settings.cfg to "hostname = foohost25" (originally was set to foohost)

No matter how many times I run preflight/postflight scripts or managedsoftwareupdate it still returns hostname as foohost in the simian backend

Justin McWilliams

unread,
Aug 5, 2015, 3:18:10 PM8/5/15
to Simian Discuss

How long have you waited after facter was available and exposing those values?  Simian will cache facter output for 3 hours, due to (likely legacy) issues with facter hanging for long periods of time.

https://github.com/google/simian/blob/master/src/simian/mac/client/flight_common.py#L68

We can probably remove this cache now, as I believe facter has been considerably faster than 5 years back when this was created, and it has since added it's own caching mechanism as well.

Perhaps delete the cache file referenced above, and run "simianfacter" to compare it's output.

// mobile

--
You received this message because you are subscribed to the Google Groups "Simian Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simian-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Holt

unread,
Aug 5, 2015, 3:57:45 PM8/5/15
to Simian Discuss
ok that did the trick.  It's not loading my custom facts though for configtrack, site, and office.  They show up when i run facter -p but don't show up in simian.  Here's my custom fact that gets deployed through puppet:

Facter.add('configtrack') do
    setcode do
      'staff'
    end
end
Facter.add('site') do
    setcode do
      'site'
    end
end
Facter.add('location') do
    setcode do
      'location'
    end
end

and this is what I see when I run facter -p

location => location
site => site
configtrack => staff

I am running Facter v2.4.4

Michael Holt

unread,
Aug 5, 2015, 6:23:33 PM8/5/15
to Simian Discuss
I've done some debugging and it appears as if the issue is somewhere within the GetMachineInfoFromFacter and CacheFacterContents.
For testing purposes I grabbed the GetFacterFacts function from simianfacter and tweaked it as shown below and put it inside flight_common.py.

def GetFacterFacts():
  """Returns a dictionary of facter facts."""
  return_code, stdout, unused_stderr = Exec(['facter', '-p'], timeout=300, waitfor=0.5)

  # If execution of factor was successful build the client identifier
  if return_code != 0:
    return {}

  facts = {}

  # Iterate over the facter output and create a dictionary of the output
  lines = stdout.splitlines()
  for line in lines:
    (key, unused_sep, value) = line.split(' ', 2)
    value = value.strip()
    facts[key] = value
  return facts

I then changed line 461 from

facts = GetMachineInfoFromFacter()

to

facts = GetFacterFacts()

With these changes it is now pulling the facter facts

Michael Holt

unread,
Aug 5, 2015, 7:28:09 PM8/5/15
to Simian Discuss
posted as an issue in github

Reply all
Reply to author
Forward
0 new messages