5.8. Modifying a Smart Class Parameter Using an External File
Using external files simplifies working with JSON data. Using an editor with syntax highlighting can help you avoid and locate mistakes.
Modifying a Smart Class Parameter Using an External File
This example uses a MOTD Puppet manifest.
Search for the Puppet Class by name,
motd
in this case.Example request:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" \ --request GET --user sat_user:sat_password --insecure \ https://satellite.example.com/api/smart_class_parameters?search=puppetclass_name=motd \ | python -m json.tool
Examine the following output. Each Smart Class Parameter has an ID that is global for the same Satellite instance. The
content
parameter of themotd
class hasid=3
in this Satellite Server. Do not confuse this with the Puppet Class ID that displays before the Puppet Class name.Example response:
{ "avoid_duplicates": false, "created_at": "2017-02-06 12:37:48 UTC", # Remove this line. "default_value": "", # Add a new value here. "description": "", "hidden_value": "", "hidden_value?": false, "id": 3, "merge_default": false, "merge_overrides": false, "override": false, # Set the override value to
true
. "override_value_order": "fqdn\nhostgroup\nos\ndomain", "override_values": [], # Remove this line. "override_values_count": 0, "parameter": "content", "parameter_type": "string", "puppetclass_id": 3, "puppetclass_name": "motd", "required": false, "updated_at": "2017-02-07 11:56:55 UTC", # Remove this line. "use_puppet_default": false, "validator_rule": null, "validator_type": "" }Use the parameter ID
3
to get the information specific to themotd
parameter and redirect the output to a file, for example, output_file.json.Example request:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" --request GET \ --user sat_user:sat_password --insecure \` https://satellite.example.com/api/smart_class_parameters/3 \ | python -m json.tool > output_file.json
Copy the file created in the previous step to a new file for editing, for example,
changed_file.json
:$ cp output_file.json changed_file.json
Modify the required values in the file. In this example, change the content parameter of the
motd
module, which requires changing theoverride
option fromfalse
totrue
:{ "avoid_duplicates": false, "created_at": "2017-02-06 12:37:48 UTC", # Remove this line. "default_value": "", # Add a new value here. "description": "", "hidden_value": "", "hidden_value?": false, "id": 3, "merge_default": false, "merge_overrides": false, "override": false, # Set the override value to
true
. "override_value_order": "fqdn\nhostgroup\nos\ndomain", "override_values": [], # Remove this line. "override_values_count": 0, "parameter": "content", "parameter_type": "string", "puppetclass_id": 3, "puppetclass_name": "motd", "required": false, "updated_at": "2017-02-07 11:56:55 UTC", # Remove this line. "use_puppet_default": false, "validator_rule": null, "validator_type": "" }After editing the file, verify that it looks as follows and then save the changes:
{ "avoid_duplicates": false, "default_value": "No Unauthorized Access Allowed", "description": "", "hidden_value": "", "hidden_value?": false, "id": 3, "merge_default": false, "merge_overrides": false, "override": true, "override_value_order": "fqdn\nhostgroup\nos\ndomain", "override_values_count": 0, "parameter": "content", "parameter_type": "string", "puppetclass_id": 3, "puppetclass_name": "motd", "required": false, "use_puppet_default": false, "validator_rule": null, "validator_type": "" }
Apply the changes to Satellite Server:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" \ --request PUT --user sat_username:sat_password --insecure \ --data @changed_file.json \ https://satellite.example.com/api/smart_class_parameters/3