Hide Forgot
Document URL: https://access.redhat.com/documentation/en/red-hat-satellite/6.2/single/hammer-cli-guide/#chap-CLI_Guide-Managing_Errata Section Number and Name: Example 8.2. Applying All Available Errata to a Host Describe the issue: 1) The script is taking the wrong column: ~~~ HOST="auth01.example.com" for i in $(hammer --csv host errata list --host $HOST | grep -vi '^ID' | awk -F, {'print $1'}) do hammer host errata apply --host $HOST --errata-ids $i done ~~~ 2) script is not taking into account blank lines: # hammer --csv host errata list --host ktordeur-errata.sysmgmt.lan | grep -vi '^ID' | awk -F, {'print $2'} ~~~ RHBA-2016:1503 RHBA-2016:1276 RHBA-2016:0205 RHBA-2016:1052 RHBA-2016:1254 RHBA-2016:1522 RHBA-2016:1028 RHSA-2016:0685 RHBA-2016:1545 RHBA-2016:1027 ~~~ Suggestions for improvement: 1) ~~~ HOST="auth01.example.com" for i in $(hammer --csv host errata list --host $HOST | grep -vi '^ID' | awk -F, {'print $2'}) do hammer host errata apply --host $HOST --errata-ids $i done ~~~ 2) Remove the blank lines with: # hammer --csv host errata list --host ktordeur-errata.sysmgmt.lan | grep -vi '^ID' | awk -F, {'print $2'} | grep -v '^$' Additional information: 1) # hammer --csv host errata list --host ktordeur-errata.sysmgmt.lan | grep -vi '^ID' | awk -F, {'print $1'} | head ~~~ 639cd72b-e706-4945-aee2-024a1f51ccc8 fc5d1201-248e-4a72-9751-9d53e5a0e76a f69adca2-8b43-4702-ad06-cd2083a83a71 f45a3c15-93c5-4240-a410-057a95c22858 efcd3189-5b8c-4285-a3ef-299c2248dc25 ea13bc68-4ed4-45f2-ae09-5118b76f2782 e7c5ea83-4da1-44c3-bdfb-f278ff6c0be3 e5e93ace-0802-4cb8-a924-fea13c27aaaf e58f2c31-4309-478d-83b2-ee754f6146d8 e076700d-e1df-4429-aed5-a7b44c88efef ~~~ #hammer --csv host errata list --host ktordeur-errata.sysmgmt.lan | grep -vi '^ID' | awk -F, {'print $2'} | head ~~~ RHBA-2016:1503 RHBA-2016:1276 RHBA-2016:0205 RHBA-2016:1052 RHBA-2016:1254 RHEA-2016:1388 RHBA-2016:1349 RHBA-2016:1029 RHBA-2016:1444 RHBA-2016:1534 ~~~
Hello See also Bug 1393550 – Error in awk script: 'print $1' should be 'print $2'
Hello We can close BZ#1393550 as duplicate because this bug is proposing an enhancement to remove blank lines with the extra: | grep -v '^$'
*** Bug 1393550 has been marked as a duplicate of this bug. ***
Why: The previous script would apply 1 advisory at a time Time it took to finish almost 1 hour: # time ./apply_all_errata_to_content_host.sh ~~~ Please enter the hostname of the content host ktordeur-errata.sysmgmt.lan [....................................................................................................................................................................................................................................] [100%] libtasn1-3.8-3.el7.x86_64 ... ... real 58m0.007s user 3m30.053s sys 0m32.915s ~~~ It seems it's applied to the content host one errata at a time: # yum history ~~~ Loaded plugins: package_upload, product-id, search-disabled-repos, subscription-manager ID | Login user | Date and time | Action(s) | Altered ------------------------------------------------------------------------------- 68 | System <unset> | 2016-11-09 17:12 | Update | 1 67 | System <unset> | 2016-11-09 17:08 | Update | 1 66 | System <unset> | 2016-11-09 17:07 | Update | 1 65 | System <unset> | 2016-11-09 17:06 | Update | 1 64 | System <unset> | 2016-11-09 17:06 | Update | 1 63 | System <unset> | 2016-11-09 17:05 | Update | 1 62 | System <unset> | 2016-11-09 17:04 | Update | 1 61 | System <unset> | 2016-11-09 17:04 | Update | 2 60 | System <unset> | 2016-11-09 17:03 | Update | 1 59 | System <unset> | 2016-11-09 17:03 | Update | 1 58 | System <unset> | 2016-11-09 17:00 | Update | 2 57 | System <unset> | 2016-11-09 16:59 | Update | 1 56 | System <unset> | 2016-11-09 16:57 | Update | 3 55 | System <unset> | 2016-11-09 16:55 | Update | 2 54 | System <unset> | 2016-11-09 16:55 | Update | 1 53 | System <unset> | 2016-11-09 16:54 | Update | 1 52 | System <unset> | 2016-11-09 16:53 | Update | 1 51 | System <unset> | 2016-11-09 16:52 | Update | 1 50 | System <unset> | 2016-11-09 16:51 | Update | 2 49 | System <unset> | 2016-11-09 16:49 | Update | 1 ... ~~~ Another improvement would be to apply all errata with 1 command like for example: ~~~ #!/bin/bash echo -n "Please enter the hostname of the content host: " read HOST hammer --csv host errata list --host $HOST | grep -vi '^ID' | awk -F, {'print $2'} | grep -v '^$' > /tmp/errata_list hammer host errata apply --host $HOST --errata-ids `awk -vORS=, '{ print $1 }' /tmp/errata_list | sed 's/,$/\n/'` ~~~ 25min improvement when applying all errata in 1 go: # time hammer host errata apply --host ktordeur-errata.sysmgmt.lan --errata-ids RHBA-2016:1503,RHBA-2016:1276,RHBA-2016:0205,RHBA-2016:1052,RHBA-2016:1254,RHEA-2016:1388,RHBA-2016:1349,RHBA-2016:1029,RHBA-2016:1444,RHBA-2016:1534,RHBA-2016:0002,RHBA-2016:1030,RHBA-2016:1279,RHSA-2016:0722,RHSA-2016:1292,RHBA-2016:1266,RHBA-2016:0544,RHBA-2016:1259,RHBA-2016:0181,RHBA-2016:1524,RHBA-2016:1523,RHSA-2016:1086,RHBA-2016:1522,RHBA-2016:1028,RHSA-2016:0685,RHBA-2016:1545,RHBA-2016:1027,RHSA-2015:2172,RHBA-2016:1285,RHBA-2016:1026,RHBA-2016:1252,RHBA-2016:1253,RHBA-2016:0551,RHEA-2016:0683,RHBA-2016:0213,RHSA-2016:0176,RHBA-2016:1525,RHBA-2016:0183,RHBA-2016:2096,RHBA-2016:1449,RHBA-2015:1958,RHBA-2016:0529,RHBA-2016:1251,RHBA-2016:1046,RHSA-2016:2098,RHSA-2016:2047,RHEA-2016:1982,RHSA-2016:1944,RHSA-2016:1940,RHBA-2016:1843,RHBA-2016:1834,RHSA-2016:1847,RHBA-2016:1833,RHBA-2016:1873,RHBA-2016:1835,RHBA-2016:1863,RHBA-2016:1832,RHBA-2016:1846,RHBA-2016:1848,RHSA-2016:1633,RHSA-2016:1626,RHSA-2016:1602,RHSA-2016:1539,RHSA-2016:1277,RHSA-2016:1141,RHSA-2016:1033,RHSA-2016:1025,RHSA-2016:0532,RHSA-2016:0534,RHBA-2016:0547,RHBA-2016:0530,RHBA-2016:0545,RHBA-2016:0548,RHBA-2016:0535,RHBA-2016:0526,RHBA-2016:0533,RHEA-2016:0517,RHSA-2016:0465,RHEA-2016:0463,RHSA-2016:22677,RHSA-2016:22610,RHSA-2016:0459,RHSA-2016:0428,RHSA-2016:0370,RHSA-2016:0301,RHSA-2016:0189,RHSA-2015:2623,RHSA-2016:0043,RHSA-2016:0064,RHSA-2015:2550,RHSA-2016:0185,RHSA-2015:2552,RHEA-2016:0182,RHBA-2016:0177,RHBA-2016:0003,RHBA-2016:0191,RHBA-2016:0186,RHBA-2016:0178,RHBA-2015:2570,RHBA-2015:2573,RHBA-2015:2478,RHBA-2015:2543,RHBA-2016:0179,RHBA-2016:0214,RHBA-2016:0199,RHBA-2016:0180,RHSA-2015:2655,RHSA-2016:0007,RHSA-2016:0073,RHSA-2016:0008,RHSA-2016:0063,RHSA-2015:2617,RHSA-2016:0012,RHEA-2016:0154 [....................................................................................................................................................................................................................................] [100%] 32:bind-license-9.9.4-29.el7_2.4.noarch dnsmasq-2.66-14.el7_2.1.x86_64 iproute-3.10.0-54.el7_2.1.x86_64 sudo-1.8.6p7-17.el7_2.x86_64 nspr-4.11.0-1.el7_2.x86_64 libtasn1-3.8-3.el7.x86_64 ... real 33m51.351s user 0m12.605s sys 0m6.162s
Assigning to Charles for review.
The content is now live on the customer portal. https://access.redhat.com/documentation/en/red-hat-satellite/6.2/paged/hammer-cli-guide/82-applying-errata-to-a-host
Looks good to me; moving to VERIFIED.