grahampugh / jamf-upload

Scripts for uploading packages to Jamf Cloud
Apache License 2.0
149 stars 37 forks source link

New processor - JamfPackageCleaner #99

Closed cr3ation closed 1 year ago

cr3ation commented 1 year ago

A new processor for cleaning packages. Keeping a set number of latest uploads and deletes oldest (based on package id).

Supported attributes:

input_variables = {
        "JSS_URL": {
            "required": True,
            "description": "URL to a Jamf Pro server that the API user has write access to.",
        },
        "API_USERNAME": {
            "required": True,
            "description": "Username of account with appropriate acces.",
        },
        "API_PASSWORD": {
            "required": True,
            "description": "Password of api user.",
        },
        "pkg_name_match": {
            "required": False,
            "description": "The name at the beginning of the package. This is used as a base for cleaning. The default value is '%NAME%-', e.g. 'Google Chrome-'.",
            "default": "",
        },
        "versions_to_keep": {
            "required": False,
            "description": "The number of pkg_name_match values to keep in Jamf Pro. This is based on the package ID.",
            "default": 5,
        },
        "minimum_name_length": {
            "required": False,
            "description": "The minimum number of characters required in pkg_name_match. This is used as a failsafe.",
            "default": 3,
        },
        "maximum_allowed_packages_to_delete": {
            "required": False,
            "description": "The maximum number of packages that can be deleted. This is used as a failsafe.",
            "default": 20,
        },
    }

pkg_name_mach defaults to %NAME%- if not set. Eg. Google Chrome-.

self.pkg_name_match = self.env.get("pkg_name_match") or f"{self.env.get('NAME')}-"
grahampugh commented 1 year ago

Working great! Nice work with the integration with the existing code. I'll merge it into here and work on the enhancements required for on-prem file shares, before copying it to the autopkg repo.

grahampugh commented 1 year ago

@cr3ation FYI, I have now integrated the ability to delete packages from SMB shares. Feel free to test the code is still working for you - from the main branch of this repo. I'll test on my TST on-prem setup with a few recipes before merging into the grahampugh-recipes repo.