How can you assign a host to a hostgroup via the command line

On Katello 4.6.0 I am trying the command:
hammer host update --name ${host} --hostgroup-id 5 --content-view ${CCV} --lifecycle-environment ${LE}
and all I get back is:

Could not update the host:
  Error: Too many arguments.
  
  See: 'hammer host update --help'.

So clearly hammer host update is not the way. But what is the correct way? I have already assigned the Content View and Lifecycle via assigning the host to an Activation Key. I just need to set the Host Group and Content Source now.

This usually indicates an error in your parameters, maybe one of your variables was empty or contained an unquoted whitespace?
hammer host update --hostgroup-id and --content-source-id (or their respective equivalents (–content-source and --hostgroup-title) are the correct way to do what you are trying to achieve. I personally have very good experience in finding the correct way to do things with hammer through hammer shell (which is an interactive shell for hammer), since it is more responsive. Maybe that can help you find out whats going wrong.

I have never heard of hammer shell so I will definitely need to give it a
try.

Thanks
Louis

@Louis_Bohm, Hi!
I’d say your command is correct, but my guess is that one or more variables you’re passing to the content view and LCE contain spaces.
can you try to wrap that var reference in double quotes?

# export ccv="Default Organization View"
# hammer host update --name bar.foo.com --hostgroup-id 1 --content-view ${ccv} --organization-id 1
Could not update the host:
  Error: Too many arguments.
  
  See: 'hammer host update --help'.

# hammer host update --name myhost.foo --hostgroup-id 1 --content-view "${ccv}" --organization-id 1
Could not update the host:
  Resource host not found by id '1'