How to change Content Source and OpenSCAP Capsule for a host through REST API?

Solution Verified - Updated

Environment

  • Red Hat Satellite 6.2

Issue

  • How to change Content Source and OpenSCAP Capsule for a host through REST API?

Resolution

  • Following is the curl command to change Content Source and OpenSCAP Capsule for a host.

     # curl -k -X PUT -H 'Accept: application/json' -H 'Content-Type: application/json' -u admin:changeme 'https://satellite.example.com/api/hosts/client.example.com' -d '{"host": {"content_source_id": 1, "openscap_proxy_id": 1}}' | python -mjson.tool
    
  • Many other parameters can also be modified. For a full list of parameters refer to the following command JSON output

    # curl -k -s -u admin:changeme https://satellite.example.com/api/hosts/client.example.com | json_reformat
    

NOTE: Red Hat Satellite 6 requires the use of HTTPS, and by default a certificate for host identification. Follow steps provided in Red Hat Satellite 6 REST API Guide - Using SSL Authentication or use -k (insecure) option to bypass certificate checks.

For user authentication, use -u <username>:<password> or, if password is not included then the command prompts to enter password it. Red Hat recommends that not to include the password as part of the command, because it then becomes part of shell history and might present a security risk. Above examples include the password only for the sake of simplicity.

For more KB articles/solutions related to Red Hat Satellite 6.x OpenSCAP Issues, please refer to the Red Hat Satellite Consolidated Troubleshooting Article for Red Hat Satellite 6.x OpenSCAP Issues

For more KB articles/solutions related to Red Hat Satellite 6.x API Issues, please refer to the Red Hat Satellite Consolidated Troubleshooting Article for Red Hat Satellite 6.x API Issues

SBR
Product(s)
Components
Category

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.