dayglojesus / managedmac

Comprehensive Puppet module for OS X.
http://dayglojesus.github.io/managedmac/
Apache License 2.0
62 stars 21 forks source link

Puppet 4 support #95

Open gerardkok opened 8 years ago

gerardkok commented 8 years ago

This pull request is a first attempt to make the managedmac module compatible with puppet 4. I'm not much of a Ruby or Puppet expert, so this pull request is mostly the result of trial and error. I have tested the result on two macs: one running OS X 10.11.3 with puppet 3.8.6, and one running OS X 10.11.3 with puppet-agent 1.3.5, both against a puppet master running puppetserver 2.2.1. Unfortunately I don't have the resources to test it thoroughly; I couldn't test it against a puppet 3 master, for example.

The pull request tries to solve 3 problems:

  1. "Could not autoload puppet/type/mobileconfig: no such file to load -- puppet/managedmac/common". I fixed this by rewriting the imports to a 'relative' form, like "require File.expand_path(File.join(File.dirname(FILE), '..', 'managedmac', 'common'))". I got this idea from various other puppet modules (puppetlabs/vcsrepo, for example).
  2. "Error 400 on SERVER: no parameter named 'provider' at /etc/puppetlabs/code/environments/production/modules/managedmac/manifests/softwareupdate.pp:189". I fixed this by renaming the 'propertylist' custom typo to 'property_list'. I'll be honest: I don't know what is wrong with the original code (it looks ok to me), and why renaming fixes it, but it does (for me, at least). Maybe the word 'propertylist' is already used somewhere in the puppet code? I've also replaced 'propertylist' wuth 'property_list' in the documentation where applicable.
  3. "Error: Could not autoload puppet/provider/macauthdb/default: cannot load such file -- sqlite3", on the mac running puppet agent 1.3.5. I solved this by running 'sudo /opt/puppetlabs/puppet/bin/gem install sqlite3' (and 'sudo /opt/puppetlabs/puppet/bin/gem install CFPropertyList' for completeness - not sure if this is really needed). On the mac still running puppet 3, just installing the gems with 'sudo gem install' was enough.
henrydobson commented 8 years ago

ENV puppetserver version: 2.4.0 puppet agent version: 4.5.3

TL;DR My contributions (which are very temporary) for puppet 4.5. cfpropertylist added to module dir. removed macauthdb as unable to resolve issues with sqlite3.

https://github.com/henrydobson/managedmac/tree/puppetv4.5


I had a go with your fork Gerard and puppet/type/mobileconfig seemed to load where it had previously failed. I also had no issues with property_list and confirm the softwareupdate manifest performed without error.

The following errors were common:

Could not autoload puppet/type/macgroup: no such file to load -- cfpropertylist at /etc/puppetlabs/code/environments/production/modules/managedmac/manifests/loginwindow.pp:383:3 on node test3
Could not autoload puppet/type/mobileconfig: no such file to load -- cfpropertylist at /etc/puppetlabs/code/environments/production/modules/managedmac/manifests/security.pp:175:3 on node test3

I am (like everyone else I think) still trying to absorb all of the changes from puppet 3 to 4 and because cfpropertylist was not loading I copied it to the module temporarily and referenced it there.

I did find several issues with sqlite3 as well and, despite having the gem installed via puppetserver gem install sqlite3, the module failed to load the file no such file to load -- sqlite3/sqlite3_native. During installation I sometimes saw this error too but after reinstallation the gems it did not crop up again:

ERROR: Error installing sqlite3: ERROR: Failed to build gem native extension. java -jar /opt/puppetlabs/server/apps/puppetserver/puppet-server-release.jar -r ./siteconf20160813-115-eszqtd.rb extconf.rb

It did not recognise the argument -r.

I still found I had to use the workaround of a relative path for the require in the macauthdb.rb file to find sqlite3 but this lead to another error as the sqlite3.rb file requires 'sqlite3/sqlite3_native', which was not present at all. I haven't been able to find a tidy solution but I'm hoping this experience will help everyone else.

Some things I did try were the jdbc-sqlite3 gem: This also required the relative path and so I temporarily placed a copy of the gem in the module but this was still a no go becasue...

 Could not exec SQL: `uninitialized constant Class::SQLite3`

In the end I elected that I could probably live without the macauthdb type for now and removed it from my fork. This allowed the client to build a catalog successfully an has been some form of temporary workaround for me in the last 2 days.

tindoge commented 7 years ago

This does not appear to work for me when it comes to Puppet4, I am getting Failed to load feature test for cfpropertylist: cannot load such file -- CFPropertyList on the server,

even after attempting to install the ruby gem.

Ginja commented 7 years ago

@ltinker just one thought (I'm not a Puppet user anymore), but did you use the gem binary inside /opt/puppetlabs/bin to install cfpropertylist? Or did you use the system's Ruby?

tindoge commented 7 years ago

Hi Ginja, I installed it by running sudo puppetserver gem install CFPropertyList, so it should be installed against the puppet ruby environment.