02 Oct 2020 06:52 AM
I have to set a custom property on 5000+ hosts, rather than manually setting the property in hostcustomproperties.conf or executing --set-host-property on each host, is there a way to automate it across all hosts ?
Solved! Go to Solution.
02 Oct 2020 07:42 AM
As far as I know, only tags can be applied to entities via Environment APIs, not properties.
Other solution I think would be to deploy a OneAgent extension (but this still requires pushing the extension to the host by yourself) that will set properties for entities, either host or processes.
02 Oct 2020 07:47 AM
Yeah, this was the other option I considered, but the effort would be more than just executing it on every host...
02 Oct 2020 07:53 AM
Agreed. If you don't want to use tags instead of properties, then the only way is to execute something on the hosts via other means. With 5000 hosts I assume you already have some configuration management tools in place and it should not be that hard.
02 Oct 2020 07:59 AM
@Leon Van Z. do you have any other system/config management tools in place to manage these hosts? e.g. Ansible or Puppet?
When I manage custom properties I used to generate the hostcustomproperties.conf via puppet, based on config settings made in puppet facts. Similar to what you could do with Ansible (e.g. execute oneagentctl).
The oneAgent on a host API unfortunately doesn't allow to set properties 😞
02 Oct 2020 11:02 AM
Yup it can be done with Ansible , but is there a plan to do it via the API?
02 Oct 2020 02:05 PM
If you don't have Puppet or Ansible You can use a CSV template that lists the host name, then you can set the custom meta data via the columns. Say Row One has the following columns, Host | Environment | Team | Application.
Then Row two you put in the data so HOST 1 | PROD | WebDev | Easy Travel
And Row 3 for your other hosts : HOST 2 | DR | AppDev | Easier Travel
And so on for your X amount of hosts.
And then within your script, upon install the CSV gets uploaded and as it deploys to Host 1, it looks at the settings and applies the metadata.
Once that is all said and done, you can then create auto tagging rules that looks at that data and list the values as tags for better sorting and rule capabilities.
19 Sep 2024 05:11 PM
Looks like this is doable now: (you;ll have to replace with your values.
in API Explorer:
{
"entities": [
"HOST-REDACTED"
],
"operations": [
{
"attribute": "hostProperty",
"operation": "set",
"value": "test=test1"
}
]
}
curl -X 'POST' \ 'https://%URL%/e/%ENVIRONMENT_ID%/api/v2/oneagents/remoteConfigurationManagement?restart=false' \ -H 'accept: application/json; charset=utf-8' \ -H 'Authorization: Api-Token %TOKEN%' \ -H 'Content-Type: application/json; charset=utf-8' \ -d '{ "entities": [ "HOST-%ID%" ], "operations": [ { "attribute": "hostProperty", "operation": "set", "value": "test=test1" } ] }'