Add Ubuntu Advantage Query to Library (#35680)

Adds the Ubuntu Advantage policy to the policy library that checks to see
if the file exists, and that it is attached, and expiry date has not
passed.

This can be used in combination with a script automation running `pro
attach <tokenID>`, with a tokenID configured in Fleet Variables. E.g:
`pro attach $FLEET_SECRET_UBUNTUPRO` for remediation.

---------

Co-authored-by: Noah Talerman <47070608+noahtalerman@users.noreply.github.com>
This commit is contained in:
Graham Williams 2025-11-17 10:04:16 +00:00 committed by GitHub
parent 1ca8c6ec79
commit 33510dc40c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -184,6 +184,15 @@ spec:
contributors: zwass
---
apiVersion: v1
kind: policy
spec:
name: Get Ubuntu Advantage (Ubuntu Pro) attachment status
platform: linux
description: Checks to see if the Ubuntu Pro status file exists, and ensures attachment and expiry are as expected. Combine with a script automation to run the attach command for remediation.
query: SELECT 1 FROM parse_json WHERE path = '/var/lib/ubuntu-advantage/status.json' AND ((key = 'attached' AND value = 'true') OR (key = 'expires' AND datetime(value) > datetime('now'))) GROUP BY path HAVING SUM(CASE WHEN key = 'attached' AND value = 'true' THEN 1 ELSE 0 END) = 1 AND SUM(CASE WHEN key = 'expires' AND datetime(value) > datetime('now') THEN 1 ELSE 0 END) = 1;
contributors: GrayW
---
apiVersion: v1
kind: query
spec:
name: Get authorized SSH keys