5.4. Applying Errata to a Host or Host Collection
You can use the API to apply errata to a host, host group, or host collection. The following is the basic syntax of a PUT request:
curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" --request PUT \ --user sat_username:sat_password --insecure \ --data json-formatted-data https://satellite7.example.com
$ curl --header "Accept:application/json,version=2" \
--header "Content-Type:application/json" --request PUT \
--user sat_username:sat_password --insecure \
--data json-formatted-data https://satellite7.example.com
You can browse the built in API doc to find a URL to use for applying Errata. You can use the Satellite web UI to help discover the format for the search query. Navigate to Hosts > Host Collections and select a host collection. Go to Collection Actions > Errata Installation and notice the search query box contents. For example, for a Host Collection called my-collection, the search box contains host_collection="my-collection"
.
Applying Errata to a Host
This example uses the API URL for bulk actions /katello/api/hosts/bulk/install_content
to show the format required for a simple search.
Example request:
curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" --request PUT \ --user sat_username:sat_password --insecure \ --data "{\"organization_id\":1,\"included\":{\"search\":\"my-host\"},\"content_type\":\"errata\",\"content\":[\"RHBA-2016:1981\"]}" \ https://satellite.example.com/api/v2/hosts/bulk/install_content
$ curl --header "Accept:application/json,version=2" \
--header "Content-Type:application/json" --request PUT \
--user sat_username:sat_password --insecure \
--data "{\"organization_id\":1,\"included\":{\"search\":\"my-host\"},\"content_type\":\"errata\",\"content\":[\"RHBA-2016:1981\"]}" \
https://satellite.example.com/api/v2/hosts/bulk/install_content
Applying Errata to a Host Collection
In this example, notice the level of escaping required to pass the search string host_collection="my-collection"
as seen in the Satellite web UI.
Example request:
curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" --request PUT \ --user sat_username:sat_password --insecure \ --data "{\"organization_id\":1,\"included\":{\"search\":\"host_collection=\\\"my-collection\\\"\"},\"content_type\":\"errata\",\"content\":[\"RHBA-2016:1981\"]}" \ https://satellite.example.com/api/v2/hosts/bulk/install_content
$ curl --header "Accept:application/json,version=2" \
--header "Content-Type:application/json" --request PUT \
--user sat_username:sat_password --insecure \
--data "{\"organization_id\":1,\"included\":{\"search\":\"host_collection=\\\"my-collection\\\"\"},\"content_type\":\"errata\",\"content\":[\"RHBA-2016:1981\"]}" \
https://satellite.example.com/api/v2/hosts/bulk/install_content