Question about "Site" and "Location" variables in the settings.cfg file

89 views
Skip to first unread message

Victor Moroz

unread,
May 17, 2013, 9:10:11 AM5/17/13
to simian-...@googlegroups.com
I have my Simian server running and two clients attached in my testing network. I now have a question about the "Site" and "Location" variables in the settings.cfg file.

I have one client (running 10.6.8) that is shown on the website with its hostname/user correct, but a "None" in the "Site" category, and the "Office" category (which I am assuming is the corresponding item to "Location").
I have one other client (10.8.3) that has the hostname as "foohost" and the owner as "foouser" and the default values for "Site"/"Office" (ie. MTV and US-MTV-FOO).

The 10.6.8 has Facter on it, and the 10.8.3 does not, so I know why the hostname/owner are not correct.

My questions: 

1- On the 10.6.8 machine, Facter is used to get the hostname/owner, but as for the "Site"/"Office" information: where is that being pulled (to show as "None")? It is not coming from the default values in settings.cfg. Is there a setting I can set on the machine so that Facter will pull a "Site"/"Location"? If there isn't, how can I set that information properly?

2- On the 10.8.3 machine (no Facter) if I now go into it's /etc/simian/settings.cfg file and update the hostname/owner/site/location default values, and then restart it, will those values update on the server?

Thanks for your time!


Justin McWilliams

unread,
May 17, 2013, 11:26:28 AM5/17/13
to simian-...@googlegroups.com
Victor,

If you have Facter installed and you use other means to dynamically
set these, that takes prescendence, otherwise site and Location are
optional settings.cfg configurations:
https://code.google.com/p/simian/wiki/Configuration

You can set these values to anything you wish. We use them to group
(and target) computers in the same building (Location) and on the same
campus (Site).

- Justin
> --
> 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/groups/opt_out.
>
>

Victor Moroz

unread,
May 17, 2013, 2:14:34 PM5/17/13
to simian-...@googlegroups.com
Victor, i'm not sure if I'm making myself clear. I understand that Facter information takes precedence over the default values for the settings.cfg. I'm confused by the results in my case.

On the 10.8.3, without Facter installed the Site/Location show up with the default values on the server:


But on the 10.6.8, with Facter installed, the hostname/owner are right, but the Site/Location are "None":

So, is that Facter saying that the Site/Location names are "None?" If so, can you tell me what Facter is looking at, so I can update that information from "None" to the actual site/company names I need? 

Or is there a way to have values set in the settings.cfg for Site/Location override what Facter is telling Simian? So if Facter tells Simian that the Site/Location name is "None" Simian can then pull a value from the settings fie instead.

Thanks for your time!

Justin McWilliams

unread,
May 17, 2013, 2:21:54 PM5/17/13
to simian-...@googlegroups.com
Simian executes a wrapped script which combines settings.cfg configs and facter output, called simianfacter: https://code.google.com/p/simian/source/browse/trunk/src/simian/util/simianfacter

Looking at line 90, settings.cfg values do not overwrite facter, but instead are only added if the same name doesn't already exist in facter output.

So, running "sudo facter -p" might be helpful, to see what site/location are set.  If they're outputting None or are present with no value, perhaps we could detect that in simianfacter and prefer the settings.cfg value as well.  Or you could remove them from facter, or update facter to output a value of your choosing.  Finally, you could remove the conditional on like 90 to have settings.cfg always overwrite any conflcting facter key names. 

Does this help?

- Justin

Victor Moroz

unread,
May 20, 2013, 8:15:06 AM5/20/13
to simian-...@googlegroups.com
Yes that does thanks! I'll go look at the settings and see whats what. 

Victor Moroz

unread,
May 28, 2013, 9:23:55 AM5/28/13
to simian-...@googlegroups.com
OK so I'm coming back to this again. So far I have not been able to get the Site/Location to update to anything other than "None" with Facter installed. I am still confused as to when/where Facter is getting its information.

I did find that I could set an environmental variable that Facter can "see" by using the 'export KEY=value' from the command line. If I do that Facter lists the item if I run it manually (key => value) but just doing it that way does not last past a reboot. 

To solve the reboot issue I created a '.profile' file under the user's home directory that has the export command, so whenever the user logs in, the environmental variable is set up. Facter can see that past a reboot. 

But still, whenever I install the client on a new machine (I install facter, then the simian.dmg client in one script), when the client shows up on the Simian webpage it has "Site" as "None." 

Justin: 

I don't know enough (meaning barely anything) about python so I'm not confident in editing the "simianfacter" wrapper. I can see on line 90 where the wrapper is set to use the settings.cfg (SETTINGS_FACTER method) to put in the 'name' value. Can I replicate that "for" function and use "site" rather than "name" and have the wrapper use the settings.cfg value properly? As I'm reading it right now "name" seems to be the only value that gets treated that way. 

So where it says:

for name in SETTINGS_FACTER:
   if name not in facts:
      facts[name] = SETTINGS_FACTER[name]

Can I add:

for site in SETTINGS_FACTER:
  if site not in facts:
     facts[site] = SETTINGS_FACTER[site]

...?
Will that update the "Site" value on the webserver when the client connects?

Thanks in advance!

Justin McWilliams

unread,
May 28, 2013, 9:45:30 AM5/28/13
to simian-...@googlegroups.com
To have your settings.cfg override facter output for *every* value, simple remove the "if foo in bar:" line, so it looks like this:

  for name in SETTINGS_FACTER:
    facts[name] = SETTINGS_FACTER[name]

You'll want to do this in your working directory, so when you build/deploy new clients the change will remain.  That said, if you have no reason to use Facter, perhaps just uninstall it?  I'm not sure what else you're using it for.  Ideally, you'd simply remove the "site" and "location" facts from Facter itself, so the Simian code remains unaltered and uses the settings.cfg value simply because Facter doesn't have the same fact name.

Lastly, Simian caches Facter output, since certain facts are generated very slowly.  It expires every 3 hours by default, so changes to settings.cfg and/or Facter itself may take that long to take effect.  Alternatively, you can delete the cache file: https://code.google.com/p/simian/source/browse/trunk/src/simian/munki/flight_common.py#70 (/Library/Managed Installs/facter.cache).

Let me know if this helps.

- Justin

Victor Moroz

unread,
May 28, 2013, 10:02:22 AM5/28/13
to simian-...@googlegroups.com
Justin, thanks again for your time and patience.

So if I add:

for site in SETTINGS_FACTER:
  facts[site] = SETTINGS_FACTER[site]

to the 'simianfacter' wrapper, that will override whatever Facter reports for "site," but just for "site?" I like that Facter gives me the host-name/owner and such and do not want to lose that functionality. 

This is my last hurdle. Once I get this licked I can start deploying this handy software to clients, so I am thankful you are taking the time to help!

Justin McWilliams

unread,
May 28, 2013, 10:05:02 AM5/28/13
to simian-...@googlegroups.com
If you _only_ want to override site and location, you'll need this:

  for name in SETTINGS_FACTER:
    if name not in facts or name == 'site' or name == 'location':
      facts[name] = SETTINGS_FACTER[name]


the variable name in "for foo in bar:" is irrelevant, but the "or" parts of the conditional here now always override site and location.

Victor Moroz

unread,
May 28, 2013, 10:15:28 AM5/28/13
to simian-...@googlegroups.com
ok, so in this code "name" is just a variable name, and doesn't refer to an actual name (like name => bill). Thanks! I will try this code and see how it goes.

Victor Moroz

unread,
May 29, 2013, 11:06:35 AM5/29/13
to simian-...@googlegroups.com
Well, that didn't quite work either. As in, not at all, haha.

I edited the 'simianfacter' wrapper in the source files and added:

for name in SETTINGS_FACTER:
  if name not in facts or name == 'site':
    facts[name] = SETTINGS_FACTER[name]

...and then generated a new installer, new certs. I installed them on a new computer to avoid any caching on the server side. I checked that the new 'simianfacter' edits had made it into the new installer and were in the correct location on the new client (/usr/local/bin/simianfacter - yes?).

Still, after the hour+ wait, when the client showed up on the website it still shows "None" for the Site value. 

What am I doing wrong? I will happily attach/post/email all my generating scripts if you think that will help.

Justin McWilliams

unread,
May 29, 2013, 12:43:13 PM5/29/13
to simian-...@googlegroups.com
"Still, after the hour+ wait" ... remember, I mentioned the 3 hour
facter cache: https://code.google.com/p/simian/source/browse/trunk/src/simian/munki/flight_common.py#70
(/Library/Managed Installs/facter.cache)

What does the output of executing "simianfacter" in Terminal say?
Does it have the expected site?

- Justin

Victor Moroz

unread,
May 29, 2013, 12:52:32 PM5/29/13
to simian-...@googlegroups.com
The computer in question just left the office to go on-site. I'll check when he gets back.

Victor Moroz

unread,
May 30, 2013, 11:37:51 AM5/30/13
to simian-...@googlegroups.com
The new install from yesterday didn't make it back to the office until this morning. I ran the simianfacter command and got the following output:

--------------------------------------
$ simianfacter 
/usr/local/munki/simian/lib/python2.6/site-packages/tlslite-0.3.8-py2.6.egg/tlslite/utils/cryptomath.py:9: DeprecationWarning: the sha module is deprecated; use the hashlib module instead 

Traceback (most recent call last): 
  File "/usr/local/bin/simianfacter", line 81, in <module> 'location': settings.LOCATION, 
  File "/usr/local/munki/simian/lib/python2.6/site-packages/simian-2.1-py2.6.egg/simian/settings.py", line 401, in __getattr__ return self._Get(str(K).lower()) 
  File "/usr/local/munki/simian/lib/python2.6/site-packages/simian-2.1-py2.6.egg/simian/settings.py", line 791, in _Get v = self._GetExternalValue(K)
  File "/usr/local/munki/simian/lib/python2.6/site-packages/simian-2.1-py2.6.egg/simian/settings.py", line 772, in _GetExternalValue raise AttributeError(K)
  AttributeError: location 
--------------------------------------------------------------------------------------------------

I then ran the same command on one of the other computers and got the same output. I then edited the /etc/simian/settings.cfg file and added a "location" section. After that, running simianfacter actually puts out the list properly and does not error.

So now I guess I will wait the three hours and see if it updates on the server? Is there anyway to change that time frame?

Justin McWilliams

unread,
May 30, 2013, 11:39:05 AM5/30/13
to simian-...@googlegroups.com
on the effected client(s): rm -rf /Library/Managed\ Installs/facter.cache

then manually execute the client, via MSU GUI or managedsoftwareupdate
client, and Simian server should reflect the change immediately.

Justin McWilliams

unread,
May 30, 2013, 11:42:07 AM5/30/13
to simian-...@googlegroups.com
Also, I'm guessing you accidentally deleted the location setting in
settings.cfg, as it's in the source:
https://code.google.com/p/simian/source/browse/trunk/etc/simian/settings.cfg

We should probably handle such cases more gracefully, though.

Victor Moroz

unread,
May 30, 2013, 12:26:20 PM5/30/13
to simian-...@googlegroups.com
Hmm. I don't have a facter.cache in that location on either of my computers.  I did run the GUI MSU and it pulled an update, but nothing changed on the server for the record of the computer from which it ran.

I also looked into the Cache/ directory and there is no facter.cache there either.

Is it possible its somewhere else? Or is there a setting that should be looked at?

Justin McWilliams

unread,
May 30, 2013, 12:29:34 PM5/30/13
to simian-...@googlegroups.com
Executing "simianfacter" manually shows the correct site and location?

Would you mind pasting, so I can see if format is off or something?
(feel free to sanitize sensitive data in facts, or just send
privately to me instead of the list)

Victor Moroz

unread,
May 30, 2013, 1:50:21 PM5/30/13
to simian-...@googlegroups.com
This is the 'simianfacter' output, after I added the 'location' back into the settings.cfg:

<comp>$ simianfacter
/usr/local/munki/simian/lib/python2.6/site-packages/tlslite-0.3.8-py2.6.egg/tlslite/utils/cryptomath.py:9: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
certname => foo-cert-name
primary_user => foouser
sp_local_host_name => <correct hostname>
configtrack => stable
simiantrack => stable
site => <correct site name>
location => <correct location name>
applesus => True
<comp>$ 


--------
I just checked the simian.appspot site and the Site/Location have finally updated. The manual update didn't show, but sometime since my last post I guess there was a check-in(?) and the data is updated correctly.

I will be updating my generation scripts to update the 'location' value as well as the 'site' value.

Can you tell me what setting controls the time between updates on the server side? Is it a varible I can manipulate on the clients, or is it set when the server side is built?

Justin McWilliams

unread,
May 30, 2013, 1:54:28 PM5/30/13
to simian-...@googlegroups.com
If you're asking about the main page, it updates every 30 minutes per:
https://code.google.com/p/simian/source/browse/trunk/src/simian/mac/cron.yaml#26

If you're looking at a specific host, though, then it pulls the data
from Datastore in real-time.

Perhaps the client was updating correctly, and you were just looking
at the (cached) summary page?

Victor Moroz

unread,
May 30, 2013, 2:03:41 PM5/30/13
to simian-...@googlegroups.com
That's very possible. I might also have been suffering under my "Mr. Impatient" hat again. It happens. 

I'm going to update all my test clients' settings.cfg files and see that they go through properly. 

Thanks for all the help with this! 

Justin McWilliams

unread,
May 30, 2013, 2:05:36 PM5/30/13
to simian-...@googlegroups.com
No problem! Glad to see everything is working now.

FYI, I just released updated source which adds some features (mostly
server-side): https://code.google.com/p/simian/source/detail?r=217
Reply all
Reply to author
Forward
0 new messages