Sorry for taking so long, but i just tried the above and it generally works. But only as long as i set a non-existent proxy-id.
root@foreman01:/etc/foreman# hammer proxy list
---|-------------------------------------|--------------------------------------------------|--------------------------
ID | NAME | URL | FEATURES
---|-------------------------------------|--------------------------------------------------|--------------------------
2 | salt01.domain.de | https://salt01.domain.de:8443 | Salt
---|-------------------------------------|--------------------------------------------------|--------------------------
I only have on testing proxy defined with the id 2.
I can freely set any proxy-id i like for a minion:
###
curl -k -u admin:password -H Accept: version=2,application/json -H Content-Type: application/json -X PUT -d {"minion": { "salt_proxy_id":3 }} https://foreman01domain.de/salt/api/salt_minions/server01.domain.de
{"architecture_id":null,"build":false,"certname":"server01.domain.de","comment":"","compute_profile_id":null,"compute_resource_id":null,"created_at":"2015-11-05T09:25:25Z","disk":null,"enabled":true,"environment_id":null,"grub_pass":"","hostgroup_id":null,"id":4,"image_file":"","image_id":null,"installed_at":null,"last_compile":null,"last_report":"2015-11-09T14:40:07Z","location_id":null,"managed":true,"medium_id":null,"model_id":null,"name":"server01.domain.de","operatingsystem_id":null,"organization_id":null,"otp":null,"owner_id":3,"owner_type":"User","provision_method":"build","ptable_id":null,"puppet_ca_proxy_id":null,"puppet_proxy_id":null,"puppet_status":8283,"realm_id":null,"root_pass":null,"salt_environment_id":1,"salt_proxy_id":3,"updated_at":"2015-11-10T12:52:35Z","use_image":null,"uuid":null}
###
But if i try to set the actually existing proxy-id 2, it fails.
###
curl -k -u admin:password -H Accept: version=2,application/json -H Content-Type: application/json -X PUT -d {"minion": { "salt_proxy_id":2 }} https://foreman01.domain.de/salt/api/salt_minions/server01.domai.de
{
"error": {"message":"undefined method `build?' for nil:NilClass"}
}###
Full debug.log is attached.
The intended use-case here is to regularly set a minions proxy-id whenever it switches to another master (i.e. another smart-proxy) and to keep the minion-proxy-mapping in foreman up to date. The request to update the proxy-id is done, whenever a minion sends a "start"-event to its master and the master "forwards" this by updating the proxy-id of that minion in foreman. This can also mean, that the same proxy-id as before is sent if the minion just restarted and did not switch masters.