No api available for attaching ansible roles with a Hostgroup in Foreman v2.1

**Problem: I’m trying to attach a ansible roles with a hostgroup but attach the roles as their is no api availble in Foreman v2.1. I have gone through foreman documentation [Foreman :: API v2] but couldn’t find any api. Where I can find ansible documentation. Any suggestion?

**Expected outcome: Hostgroup should be attached to ansible roles via api

**Foreman and Proxy versions: 2.1 & 2.1.0-rc3

**Foreman and Proxy plugin versions: 2.1 & 2.1.0-rc3

**Distribution and version: CentOS v7.x86_64 & v2.1

This should be possible once you have the foreman_ansible plugin installed. After installing it, browse the local api docs at instead of the official ones that have no plugins enabled.


Thank you so much @evgeni for local documentation link actually I wasn’t aware of this link. I’m able to attach roles with a Hostgroup now. Used below details to attach ansible roles with a Hostgroup:

Url: 'https://10.x.x.x/api/v2/hostgroups/:hostgroup_id/assign_ansible_roles
Request Type: POST
Params: {“ansible_role_ids”:[“10”,“11”]}

Yeah, it’s linked under “Support” on the “About” page of your installation, but probably not prominently enough.

ohh I can see now but I never thought that link will be there…Thanks for your support @evgeni …you made my day.

1 Like

There is an open PR now to include this api into the hostgroup module of the ansible modules: