Hammer how to enter boolean value

Hi,

have a question if it is possible to give a bool parameter with hammer?

hammer os update --id $CENTOS7OPID --os-parameters-attributes="[{“name”:“remote_execution_create_user”, “value”:true}]"

hammer os update --id $CENTOS7OPID --os-parameters-attributes="[{“name”:“remote_execution_create_user”, “value”:0}]"

I tried several methods but its always interpreted as a string…so how to archive this via command-line?

thanks
Thomas

Field parameter-type added into parameters to support same types as smart class parameters. This change was introduced in Foreman 1.22.

yes, it is possible with hammer. You can use either of the below sub-commands:

  1. Using set-parameter sub-command:

hammer os set-parameter --operatingsystem-id $CENTOS7OPID --name "remote_execution_create_user" --value true --parameter-type 'boolean'

  1. Using os update with --os-parameters-attributes:

hammer os update --id $CENTOS7OPID --os-parameters-attributes "[{\"name\":\"remote_execution_create_user\", \"value\":true, \"parameter_type\":\"boolean\"}]"

1 Like

For option --os-parameters-attributes either you can send comma separated list of key-value or valid json string. Default value of parameter_type is string so when you use below command:

hammer os update --id $CENTOS7OPID --os-parameters-attributes "name=remote_execution_create_user\\,value=true"

then it will create parameter but with type string.

1 Like

many thanks for the info!

many thanks for the info!

works great here the complete command only for INFO:

hammer os update --id $CENTOS7OPID --os-parameters-attributes="[{\"name\":\"remote_execution_create_user\", \"value\":true , \"parameter_type\":\"boolean\"}, \
{\"name\":\"remote_execution_ssh_user\", \"value\":\"$CENTOSREMOTEEXECUTIONUSER\"}, \
{\"name\":\"remote_execution_effective_user_method\", \"value\":\"sudo\"}, \
{\"name\":\"keyboard\", \"value\":\"$CENTOSKEYBOARD\"}, \
{\"name\":\"time-zone\", \"value\":\"$CENTOSTIMEZONE\"}]"
1 Like