How to list errata for multiple hosts using Hammer CLI on Red Hat Satellite 6?

Solution Verified - Updated -

Environment

  • Red Hat Satellite 6.x

Issue

  • How to list errata for multiple hosts?
  • Query a Host Collection to list errata for the hosts.

Resolution

  • To list installable errata for multiple hosts, run the below command on the Satellite CLI,

    # for i in `hammer host list| sed -e '1,3d'|sed -e '$d'|cut -d' ' -f 1`; do echo -e "Errata details for:\n" `hammer host info --id $i|sed '2!d'`;hammer host errata list --host-id $i; done
    

    The output is of the below format,

    Errata details for:  
    Name: Host1
    2812 | RHSA-2018:1453 | security    | Critical: dhcp security update                                               | true       
    1264 | RHSA-2017:1100 | security    | Critical: nss and nss-util security update                                   | true       
    652  | RHSA-2017:2836 | security    | Critical: dnsmasq security update                                            | true       
    Errata details for:  
    Name: Host2
    Errata details for:  
    Name: Host3
    

    If there is no errata applicable, the the hostname is simply listed and it moves on to the next one.

  • The below script will list errata for hosts that are a part of a particular Host Collection by querying it as follows,

    # hammer host-collection list                        || Note the ID 
    # for i in `hammer host-collection hosts --id <Host-Collection ID>| sed -e '1,3d'|sed -e '$d'|cut -d' ' -f 1`; do echo "Errata details for: " `hammer host info --id $i|sed '2!d'`;hammer host errata list --host-id $i;done
    

    Note: Replace <Host-Collection ID> with the noted ID.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments