Playbook execution on hostgroup-level and API extensions for triggering playbooks
In some situations, it is necessary to run to run Ansible roles not only for each host separately, but also for all members of a hostgroup in parallel. Therefore, there should be a way to trigger Ansible plays for hostgroups without splitting the playbook execution into subtasks for each host. This is of special interest if a configuration process spans multiple systems at the same time (for example cluster provisions).
In addition to that, playbooks should also be able to be triggered using the v2 API, such that the user does not need to rely on the Foreman UI to trigger Ansible roles.
Proposed new endpoints for the extending the API are:
POST request including expected body
http://<foreman_host>/ansible/api/v2/play_roles_on_host
{
"play_roles":
{
"host_ids": [<comma-separated-host-ids>] # optional
"host_names": [<comma-separated-host-names>] # optional
}
}
POST request including expected body
http://<foreman_host>/ansible/api/v2/play_roles_on_hostgroup
{
"play_roles":
{
"hostgroup_ids": [<comma-separated-hostgroup-ids>] # optional
"hostgroup_names": [<comma-separated-hostgroup-names>] # optional
}
}