googlearchive / simian

Simian is an enterprise-class Mac OS X software deployment solution. Google App Engine hosted server, with a client powered by the Munki open-source project.
Apache License 2.0
332 stars 51 forks source link

simianfacter/Facter 4 issue #61

Open arubdesu opened 7 years ago

arubdesu commented 7 years ago

Immediate traceback with cfacter and simianfacter the moment it hits the new structured fact output:

Traceback (most recent call last):
  File "/usr/local/bin/simianfacter", line 102, in <module>
    main()
  File "/usr/local/bin/simianfacter", line 87, in main
    facts = GetFacterFacts()
  File "/usr/local/bin/simianfacter", line 69, in GetFacterFacts
    (key, unused_sep, value) = line.split(' ', 2)

I'm working on a PR, just submitting this in case someone beats me to it with how y'all solved this internally... 😉

arubdesu commented 7 years ago

Closing, more recent commits could have resolved this.

arubdesu commented 6 years ago

Recent commits have not fixed this, and the existing code fails with an error (that gets swallowed and therefore isn't visible on stdout...) related to argparse. This cannot be what you're using internally... anyway, my version is here. Would a PR be good?

maximermilov commented 6 years ago

and the existing code fails with an error

Can you provide traceback?

You can run it directly "/usr/local/bin/simianfacter -j"

Would a PR be good?

of course, but your version can't output json(current default).

arubdesu commented 6 years ago

Hey @maximermilov,

$ sudo /usr/local/munki/simian/bin/python src/simian/util/simianfacter -j
Traceback (most recent call last):
  File "simianfacter_from_", line 114, in <module>
    main()
  File "src/simian/util/simianfacter", line 92, in main
    help='output JSON')
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/argparse.py", line 1294, in add_argument
    action = action_class(**kwargs)
TypeError: __init__() got an unexpected keyword argument 'type'

Pardon that I'm not sure why it needs to output json... my issue trying to integrate any version past 2.4.x last year was that my custom site fact wasn't being picked up. I see it in the json output, but it's not integrated into the managedsoftwareupdate run for whatever reason, so I lose the testing track and don't get site-specific manifest modifications.

maximermilov commented 6 years ago

Seems you have local modification to the script, because https://github.com/google/simian/blob/master/src/simian/util/simianfacter#L92 don't have 'type' argument.

arubdesu commented 6 years ago

😅 Well that was an errant issue that maybe was never in any checkout, but even with that exact file it's definitely something else amiss that's causing a whole bunch of values to be dropped in https://github.com/google/simian/blob/8675db57c78abf7cbbd254e3ff0aa47a1d8134ea/src/simian/mac/client/flight_common.py#L411-L522 if I add a print statement before that ending line of the function, 522, and run it with my simianfacter I get:

    preflight stdout: {'uptime': 6647.569639921188, 'root_disk_free': 25364717568, 'uuid': 'blahuuid', 'user_disk_free': 25364717568, 'track': 'unstable', 'hostname': 'foo_hostname', 'runtype': 'custom', 'site': 'MTV', 'os_version': '10.13.3', 'on_corp': '1', 'owner': 'allister', 'mgmt_enabled': True, 'serial': 'C02T123ABC', 'last_notified_datetime': None, 'client_version': u'3.1.1.3447 simian-2.5', 'config_track': '', 'applesus': 'True'}

notice simiantrack and configtrack are populated. When I switch in master's version of simianfacter, I get NONE and configtrack BROKEN. For background, I'm using all this with facter 3.6.3 (commit 194e2f2f324aba6a1262f37ad02841383ab7f961).

arubdesu commented 6 years ago

What creates /Library/Managed\ Installs/facter.cache? Was that code supposed to have been purged? This is driving me nuts, I've lost all site and track functionality, and when I run in debug mode it magically returns for a few runs before breaking again. simianfacter also throws out results if facter has an error, but that functionally just returns a None for the one desired fact, so it shouldn't matter.