This happens when not reading the docs until the end. I was searching for an automated OS Management patch job to patch my Oracle Cloud Infrastructure compute instances. Thanks on Twitter to @svilmune, @dhoogfr and @patrickjoss, who show me the menu in the OCI GUI and yes, there is a scheduler. In the meantime, I wrote a small bash script based on the OCI-CLI and instance principals. Credits to Iterating OCI CLI list data in bash (apextips.blogspot.com).
Script
#!/bin/bash set -e # set compartment comp=ocid1.compartment.oc1..aaaaaaaaoqti273775l2ye4xv4yqi35bcon3o4qb64yqfaxyj2jdagnvtsja # start check echo "" echo "---------------------------------------------------------------------------------" echo "OCI OS Management Update Check $(date)" echo "---------------------------------------------------------------------------------" #list OSMS registered instances managedinstanceList=$(oci os-management managed-instance list -c $comp --auth instance_principal) for i in $(echo "$managedinstanceList" | jq '.data | keys | .[]') do ocid=$(echo $managedinstanceList | jq -r ".data[$i].\"id\"") displayname=$(echo $managedinstanceList | jq -r ".data[$i].\"display-name\"") osfamily=$(echo $managedinstanceList | jq -r ".data[$i].\"os-family\"") updatesavailable=$(echo $managedinstanceList | jq -r ".data[$i].\"updates-available\"") rebootrequired=$(echo $managedinstanceList | jq -r ".data[$i].\"is-reboot-required\"") # show details echo "OCID: $ocid" echo "Display Name: $displayname" echo "OS Family: $osfamily" echo "Updates available: $updatesavailable" echo "Reboot required: $rebootrequired" # verify if update is required or not if [ $updatesavailable -gt 0 ] ; then echo "id do an OS update on $displayname - please verify if an OS reboot is required" oci os-management managed-instance install-all-updates --managed-instance-id $ocid --auth instance_principal else echo "no update for $displayname" fi echo "---------------------------------------------------------------------------------" done echo "---------------------------------------------------------------------------------" echo "OCI OS Management Update Check $(date) DONE" echo "---------------------------------------------------------------------------------" echo ""
Output
[oci@ci-admin-01 management]$ ./osms_update.sh --------------------------------------------------------------------------------- OCI OS Management Update Check Tue Jun 7 15:11:59 CEST 2022 --------------------------------------------------------------------------------- OCID: ocid1.instance.oc1.eu-zurich-1.abcdefgh Display Name: ci-build-02 OS Family: LINUX Updates available: 0 Reboot required: false no update for ci-build-02 --------------------------------------------------------------------------------- OCID: ocid1.instance.oc1.eu-zurich-1.abcdefgh Display Name: ci-build-01 OS Family: LINUX Updates available: 0 Reboot required: false no update for ci-build-01 --------------------------------------------------------------------------------- --------------------------------------------------------------------------------- OCI OS Management Update Check Tue Jun 7 15:12:07 CEST 2022 DONE ---------------------------------------------------------------------------------
Short Summary
Read the manual first 🙂