jctl

`jctl` uses `python-jamf` to select objects to create, delete, print and update. It allows performing Jamf Pro repetitive tasks quickly and provides options not available in the web GUI. It is similar to SQL statements, but far less complex.

MIT License

Downloads
159
Stars
50
Committers
9

Bot releases are visible (Hide)

jctl - 1.1.21 Latest Release

Published by github-actions[bot] 10 months ago

pkgctl updates multiple policies/groups at once. Example session:

[1 ] VMware Fusion                       PatchPolicies Policies Groups
  VMware Fusion-12.2.4.pkg               2             1
  VMware Fusion-12.2.5.pkg

Enter a number, or e[x]it/[q]uit: 1

VMware Fusion
  VMware Fusion-12.2.4.pkg
      Policies
        [1] Install VMware Fusion 12
      PatchPolicies
        [2] VMware Fusion SS
      PatchPolicies
        [3] VMware Fusion Student Auto
  VMware Fusion-12.2.5.pkg [no patch defined]

Enter one or more numbers, [b]ack, or e[x]it/[q]uit: 1 2 3
Pick the target package:
  [1] VMware Fusion-12.2.4.pkg
  [2] VMware Fusion-12.2.5.pkg
Enter a number, [b]ack, or e[x]it/[q]uit: 2
jctl - 1.1.20

Published by github-actions[bot] 10 months ago

Added

  • Added CHANGELOG
  • jctl and pkgctl: Load config file in a try block to catch errors
  • jctl "-i -" will obtain id's from stdin

Changed

  • Requires python-jamf 0.9.0
  • jctl import jamf.exceptions
  • jctl Rename jamf to python_jamf
  • jctl --create can now take a name or json
  • jctl Changed how -update args are processed
  • jctl Changed how path is printed using json
  • jctl Changed where the hostname is confirmed
  • jctl Split main function into multiple functions for clarity
  • jctl Sped up deleting records
jctl - 1.1.20

Published by magnusviri 10 months ago

Added

  • Added CHANGELOG
  • jctl and pkgctl: Load config file in a try block to catch errors
  • jctl "-i -" will obtain id's from stdin

Changed

  • Requires python-jamf 0.9.0
  • jctl import jamf.exceptions
  • jctl Rename jamf to python_jamf
  • jctl --create can now take a name or json
  • jctl Changed how -update args are processed
  • jctl Changed how path is printed using json
  • jctl Changed where the hostname is confirmed
  • jctl Split main function into multiple functions for clarity
  • jctl Sped up deleting records
jctl - 1.1.19

Published by github-actions[bot] almost 2 years ago

jctl

  • Added ability to create new records with json.
  • Improved error handling, exits, and printing to STDERR.
  • Created new classes that deals with different output formats and simplified the output code.

pkgctl

  • Added ability to define packages for to patch management versions while promoting packages.
  • Simplified by breaking up long methods into multiple methods.
  • Fixed bugs.
jctl - 1.1.18

Published by github-actions[bot] about 2 years ago

Fixed issue #53 , api.url

jctl - 1.1.17

Published by github-actions[bot] about 2 years ago

  • jctl: Changed the json output so it's much easier to parse (with something like jq)
  • jctl: Non-json output prints record name first when printing paths
  • jctl: Added --print-id (when you need to capture the id of a record to use in another command)
  • jctl: Added --debug
  • jctl: -s now can do !=~
  • jctl: -s ~= is deprecated, switching it to =~
  • pre-commit updated to 4.3.0
  • GitHub action updated action names

Example of the new features.

Getting the ID of the Zoom patch software title using jq:

zoomid=`jctl patchsoftwaretitles -r "Zoom Client for Meetings" -p id -j | jq '.[].id | .[] | tonumber'`

Getting the ID of the Zoom patch software title using --print_id:

zoomid=`jctl patchsoftwaretitles -r "Zoom Client for Meetings" -I`

Using the ID

jctl packages -c "Zoom-5.11.11 (10514).pkg"
jctl patchpolicies -c "Zoom 1" $zoomid "5.11.11 (10514)"

Formatting the json output with jq:

jctl computergroups -i 2 -j -l | jq
[
  {
    "id": "2",
    "name": "All Managed Servers",
    "is_smart": "true",
    "site": {
      "id": "-1",
      "name": "None"
    },
    "criteria": {
      "size": "2",
      "criterion": [
        {
          "name": "Operating System",
          "priority": "0",
          "and_or": "and",
          "search_type": "like",
          "value": "server",
          "opening_paren": "false",
          "closing_paren": "false"
        },
        {
          "name": "Application Title",
          "priority": "1",
          "and_or": "or",
          "search_type": "is",
          "value": "Server.app",
          "opening_paren": "false",
          "closing_paren": "false"
        }
      ]
    },
    "computers": {
      "size": "0"
    }
  }
]

Here's what it looks like when you specify paths.

jctl policies -n "Install Zoom" -p package_configuration -p general/name -j | jq
[
  {
    "package_configuration": {
      "packages": {
        "size": "2",
        "package": [
          {
            "id": "1",
            "name": "Zoom-5.11.11 (10514).pkg",
            "action": "Install",
            "fut": "false",
            "feu": "false"
          }
        ]
      }
    },
    "general/name": "Install Zoom"
  }
]

Non-json output shows the record name first (the output is still generated by pprint):

jctl computergroups -i 2 -l
{'All Managed Servers': {'computers': {'size': '0'},
                         'criteria': {'criterion': [{'and_or': 'and',
                                                     'closing_paren': 'false',
                                                     'name': 'Operating System',
                                                     'opening_paren': 'false',
                                                     'priority': '0',
                                                     'search_type': 'like',
                                                     'value': 'server'},
                                                    {'and_or': 'or',
                                                     'closing_paren': 'false',
                                                     'name': 'Application '
                                                             'Title',
                                                     'opening_paren': 'false',
                                                     'priority': '1',
                                                     'search_type': 'is',
                                                     'value': 'Server.app'}],
                                      'size': '2'},
                         'id': '2',
                         'is_smart': 'true',
                         'name': 'All Managed Servers',
                         'site': {'id': '-1', 'name': 'None'}}}

Showing the record name first is very helpful when printing paths:

jctl computergroups -p is_smart
{'All Managed Clients': {'is_smart': 'true'}}
{'All Managed Servers': {'is_smart': 'true'}}
Count: 2

Comparing =~ with !=~:

jctl computergroups -s name=~Cl
All Managed Clients
jctl computergroups -s name!=~Cl
All Managed Servers

Debugging output (yes, this shows the bearer token for my localhost server):

jctl computergroups --debug
2022-10-02 16:55:36,447:    DEBUG: __main__ - main(): Warning, debugging output may contain passwords, tokens, or other sensitive information!
2022-10-02 16:55:36,447:    DEBUG: __main__ - main(): args: Namespace(record='computergroups', create=None, update=None, delete=False, sub_command=None, id=None, name=None, regex=None, searchpath=None, print_id=False, long=False, path=None, json=False, quiet_as_a_mouse=False, config=None, version=False, use_the_force_luke=False, andele_andele=False, debug=True)
2022-10-02 16:55:36,494:    DEBUG: jamf.api.API - _submit_request(): post: http://localhost/api/v1/auth/keep-alive
2022-10-02 16:55:36,759:    DEBUG: jamf.api.API - _submit_request(): response.text: {
  "token" : "eyJhbGciOiJIUzI1NiJ9.eyJhdXRoZW50aWNhdGVkLWFwcCI6IkdFTkVSSUMiLCJhdXRoZW50aWNhdGlvbi10eXBlIjoiSlNTIiwiZ3JvdXBzIjpbXSwic3ViamVjdC10eXBlIjoiSlNTX1VTRVJfSUQiLCJ0b2tlbi11dWlkIjoiNGE0OGEyNzItZjFiZi00NjkwLWE5YjQtYTU4NjZkNDI2MGJlIiwibGRhcC1zZXJ2ZXItaWQiOi0xLCJzdWIiOiIxIiwiZXhwIjoxNjY0NzUzMTM2fQ.FEOy4rUenvZm3Gc_mrXk3qUnpcFmCtzneKKKs_hW-hk",
  "expires" : "2022-10-02T23:25:36.754Z"
}
2022-10-02 16:55:36,832:    DEBUG: jamf.api.API - _submit_request(): get: http://localhost/api/v1/jamf-pro-version
2022-10-02 16:55:36,860:    DEBUG: jamf.api.API - _submit_request(): response.text: {
  "version" : "10.41.0-t1661887915"
}
2022-10-02 16:55:36,861:    DEBUG: jamf.api.API - _submit_request(): get: http://localhost/JSSResource/computergroups
2022-10-02 16:55:36,904:    DEBUG: jamf.api.API - _submit_request(): response.text: <?xml version="1.0" encoding="UTF-8"?><computer_groups><size>2</size><computer_group><id>1</id><name>All Managed Clients</name><is_smart>true</is_smart></computer_group><computer_group><id>2</id><name>All Managed Servers</name><is_smart>true</is_smart></computer_group></computer_groups>
All Managed Clients
All Managed Servers
Count: 2
2022-10-02 16:55:36,922:    DEBUG: jamf.api.API - __del__(): closing session
jctl - 1.1.16

Published by github-actions[bot] about 2 years ago

  • This release includes the xml array fix described here.
  • Fixed pkgctl --config arg
  • Fixed pkgctl --version
  • Formatting changes
jctl - 1.1.14

Published by github-actions[bot] over 2 years ago

jctl - 1.1.15

Published by github-actions[bot] over 2 years ago

  • Added update_asset_tags.py to project as standalone script
  • pkgctl prints warning if it gets an error trying to update data
jctl - 1.1.13

Published by github-actions[bot] almost 3 years ago