Skip to main content

Jamf Pro - Updating Elastic Deployment Script

· 2 min read
Andrew Barnett
Senior IT Professional II

Change Request 188952 Jamf Pro - Updating Elastic Deployment Script.

Description: Details of maintenance: Update the script used to deploy and update Elastic in our Jamf servers. After tamper prevention got enabled the previous script stopped working and some agents started breaking. This new script deals with the issues cause by the use of tamper prevention for Elastic and fixes agents if they are broken. It also helps keep Elastic updated. Additionally change the scope of the elastic configuration profile to All Computers.

Updates to new Elastic Script:

Uninstall Status Check:

The checkUninstallStatus function now includes a pause for backoffSeconds before checking the status.

Added a check for the Elastic Security application in addition to the Elastic Agent folder and application.

Directory Removal:

A new function checkAndRemoveDir has been added to check if a directory exists, is empty, and remove it if necessary.

Script Exit Logic:

The quitScript function now includes additional conditions for running Jamf Recon and exiting with different status codes based on the value of exitCode.

Elastic Agent Information Check:

The elasticInfoCheck function has been added to check for the presence of the Elastic Agent folder and installed versions.

Get Elastic Agent Version:

The getElasticAgentVersion function has been updated to include additional checks for the Elastic Agent app using both direct path and Spotlight search.

Set Default Values:

A new function checkAndSetDefaults has been added to set default values for forceInstall and forceUninstall.

Check Elastic Version:

The checkElasticVersion function has been updated to include additional logic for handling force install and force uninstall scenarios.

Uninstall Agent:

The uninstallAgent function has been updated to include additional logic for handling uninstall attempts, including fallback methods and directory removal.

Install and Verify Agent:

The installAndVerifyAgent function has been updated to include additional logic for handling retry attempts, elapsed time checks, and exit codes.

Benefit of change: This change updates the deployment script for Elastic to deal with agents breaking after tamper prevention got enabled and the previous script stopped working. The change to the configuration profile will ensure that all devices in the server get the configuration profile regardless of what group they are in, even if they do not fall into a smart group initially.

Impact to customers: None. Happens in the background.