diff --git a/Modulefile b/Modulefile deleted file mode 100644 index 729944c..0000000 --- a/Modulefile +++ /dev/null @@ -1,11 +0,0 @@ -name 'rcoleman-mac_profiles_handler' -version '0.3.0' -source 'git@github.com:ryanycoleman/rcoleman-mac_profiles_handler.git' -author 'ryanycoleman' -license 'Apache' -summary 'Puppet Module for managing OS X Configuration Profiles' -description 'This module provides two resource types for managing configuration profiles.' -project_page 'https://github.com/ryanycoleman/rcoleman-mac_profiles_handler' - -## Add dependencies, if any: -dependency 'puppetlabs/stdlib', '>= 2.3.1' diff --git a/README.md b/README.md index 29c78dd..e592084 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # mac_profiles_handler module for Puppet ## Description -This module provides two resource types for interacting with OS X configuration profiles. +This module provides two resource types for interacting with macOS configuration profiles. The profile_manager resource type is the back-end type that interacts with /usr/bin/profiles for creating, destroying and verifying a resource type. The mac_profiles_handler::manage resource type is user-facing and handles the management of the actual files. diff --git a/lib/puppet/provider/profile_manager/osx.rb b/lib/puppet/provider/profile_manager/macos.rb similarity index 87% rename from lib/puppet/provider/profile_manager/osx.rb rename to lib/puppet/provider/profile_manager/macos.rb index c5a075c..3153b94 100644 --- a/lib/puppet/provider/profile_manager/osx.rb +++ b/lib/puppet/provider/profile_manager/macos.rb @@ -1,7 +1,7 @@ require 'puppet/util/plist' -Puppet::Type.type(:profile_manager).provide :osx do - desc 'Provides management of mobileconfig profiles on OS X.' +Puppet::Type.type(:profile_manager).provide :macos do + desc 'Provides management of mobileconfig profiles on macOS.' confine operatingsystem: :darwin @@ -19,14 +19,15 @@ def destroy end def exists? - installed - end - - def installed # if already installed, check if it is the right one. # if not installed, return false. + # if we are removing, don't care if it is the right one. if Facter.value(:profiles).include? resource[:name] - return current + if resource[:ensure] == :absent + return true + else + return current + end else return false end diff --git a/manifests/manage.pp b/manifests/manage.pp index 7341227..61376d2 100644 --- a/manifests/manage.pp +++ b/manifests/manage.pp @@ -1,47 +1,54 @@ # manage mac profiles define mac_profiles_handler::manage( - $file_source, - $ensure, + $file_source = '', + $ensure = 'present', $type = 'mobileconfig', ) { if $facts['os']['name'] != 'Darwin' { - fail('The mobileconfig::manage resource type is only supported on OS X') + fail('The mobileconfig::manage resource type is only supported on macOS') } - File { - owner => 'root', - group => 'wheel', - mode => '0700', - } - - if ! defined(File["${facts['puppet_vardir']}/mobileconfigs"]) { - file { "${facts['puppet_vardir']}/mobileconfigs": - ensure => directory, - } - } - case $type { - 'template': { - file { "${facts['puppet_vardir']}/mobileconfigs/${name}": - ensure => file, - content => $file_source, + case $ensure { + 'absent': { + profile_manager { $name: + ensure => $ensure, } } default: { - file { "${facts['puppet_vardir']}/mobileconfigs/${name}": - ensure => file, - source => $file_source, + File { + owner => 'root', + group => 'wheel', + mode => '0700', } - } - } - profile_manager { $name: - ensure => $ensure, - profile => "${facts['puppet_vardir']}/mobileconfigs/${name}", - require => File["${facts['puppet_vardir']}/mobileconfigs/${name}"], - subscribe => File["${facts['puppet_vardir']}/mobileconfigs/${name}"], + if ! defined(File["${facts['puppet_vardir']}/mobileconfigs"]) { + file { "${facts['puppet_vardir']}/mobileconfigs": + ensure => directory, + } + } + case $type { + 'template': { + file { "${facts['puppet_vardir']}/mobileconfigs/${name}": + ensure => file, + content => $file_source, + } + } + default: { + file { "${facts['puppet_vardir']}/mobileconfigs/${name}": + ensure => file, + source => $file_source, + } + } + } + profile_manager { $name: + ensure => $ensure, + profile => "${facts['puppet_vardir']}/mobileconfigs/${name}", + require => File["${facts['puppet_vardir']}/mobileconfigs/${name}"], + subscribe => File["${facts['puppet_vardir']}/mobileconfigs/${name}"], + } + } } - } diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..35d12bf --- /dev/null +++ b/metadata.json @@ -0,0 +1,33 @@ +{ + "name": "puppet-mac_profiles_handler", + "author": "", + "license": "", + "version": "2.0.0", + "summary": "Puppet Module for managing macOS Configuration Profiles", + "source": "https://github.com/keeleysam/puppet-mac_profiles_handler", + "project_page": "https://github.com/keeleysam/puppet-mac_profiles_handler", + "issues_url": "https://github.com/keeleysam/puppet-mac_profiles_handler/issues", + "tags": [ + "macOS", + "OS X", + "mobileconfig", + "profiles" + ], + "operatingsystem_support": [ + { + "operatingsystem": "Darwin" + } + ], + "requirements": [ + { + "name": "puppet", + "version_requirement": ">= 4.4.0" + } + ], + "dependencies": [ + { + "name": "puppetlabs/stdlib", + "version_requirement": ">= 2.3.1" + } + ] +}