fixes for the puppet module (#12818)

- Don't cache requests to get profiles, they don't happen in order when
run agains a real Puppet server
- Report resource has changed if the profile was in the host but the new
resource type is absent
This commit is contained in:
Roberto Dip 2023-07-18 14:53:43 -03:00 committed by GitHub
parent 5ea710127c
commit e99f3aeab7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 7 deletions

View file

@ -1,10 +1,10 @@
node default {
fleetdm::profile { 'cis.macOSBenchmark.section2.BluetoothSharing':
fleetdm::profile { 'com.apple.SoftwareUpdate':
template => template('fleetdm/automatic_updates.mobileconfig.erb'),
group => 'base',
}
fleetdm::profile { 'com.apple.SoftwareUpdate':
fleetdm::profile { 'cis.macOSBenchmark.section2.BluetoothSharing':
template => template('fleetdm/disable_bluetooth_file_sharing.mobileconfig.erb'),
group => 'workstations',
}

View file

@ -24,9 +24,8 @@ Puppet::Functions.create_function(:"fleetdm::preassign_profile") do
if host_profiles['error'].empty?
Puppet.info("successfully pre-set profile #{profile_identifier} as #{ensure_profile}")
# if this profile is not in the list of profiles assigned to the host,
# signal that the resource has changed.
unless host_profiles['body']['profiles'].any? { |p| p['checksum'] == base64_checksum }
has_profile = host_profiles['body']['profiles'].any? { |p| p['checksum'] == base64_checksum }
if (has_profile && ensure_profile == 'absent') || (!has_profile && ensure_profile == 'present')
response['resource_changed'] = true
end
end

View file

@ -99,7 +99,7 @@ module Puppet::Util
# @param host_id [Number] Fleet's internal host id.
# @return [Hash] The response status code, headers, and body.
def get_host_profiles(host_id)
req(method: :get, path: "/api/latest/fleet/mdm/hosts/#{host_id}/profiles", cached: true)
req(method: :get, path: "/api/latest/fleet/mdm/hosts/#{host_id}/profiles", cached: false)
end
# Gets host details by host identifier.

View file

@ -1,6 +1,6 @@
{
"name": "fleetdm-fleetdm",
"version": "0.2.0",
"version": "0.2.1",
"author": "Fleet Device Management Inc",
"summary": "MDM management and profile assignment using FleetDM",
"license": "proprietary",