> For the complete documentation index, see [llms.txt](https://platform9.com/kb/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://platform9.com/kb/pcd/generic/how-to-manually-apply-roles-on-a-host-using-api-calls.md).

# How To Manually Apply Roles On a Host Using API Calls

## Problem

In normal scenarios, the roles are applied through the PCD UI. However, the following steps can be used to apply the roles manually using API calls.

## Environment

* Private Cloud Director Virtualization - v2026.1 and Higher
* Self-Hosted Private Cloud Director Virtualization - v2026.1 and Higher
* Component - Resource Manager

## Procedure

{% stepper %}
{% step %}
**Retrieve Token**

{% code title="Export RC file and Perform" overflow="wrap" expandable="true" %}

```bash
$ openstack token issue -f value -c id
```

{% endcode %}

**Set necessary variables.**

```bash
$ export OS_TOKEN=<GENERATED_FROM_ABOVE>
$ export DU=<DU_FQDN>
$ export HOST_ID=<HOST_UUID>
```

{% endstep %}

{% step %}
**List the applied roles on the host. \[If applicable]**

{% code title="Sample Output" overflow="wrap" %}

```bash
$ curl -sS -H "x-auth-token: $OS_TOKEN" '$DU/resmgr/v1/hosts/$HOST_ID' | jq '{hostconfig_id, roles, role_status}'
{
  "hostconfig_id": "[HOSTCONFIG_UUID]",
  "roles": [
    "pf9-cindervolume-base",
    "pf9-cindervolume-config",
    "pf9-glance-role",
    "pf9-ha-slave",
    "pf9-neutron-base",
    "pf9-ostackhost-neutron",
    "pf9-support"
  ],
  "role_status": "ok"
}
```

{% endcode %}
{% endstep %}

{% step %}
**APl call to apply the required role**

* **Hypervisor Role**

  <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">$ curl -X PUT -H "x-auth-token: $OS_TOKEN" -H 'content-type: application/json' '$DU/resmgr/v1/hosts/$HOST_ID/roles/pf9-ostackhost-neutron

  $ curl -X PUT -H "x-auth-token: $OS_TOKEN" -H 'content-type: application/json' '$DU/resmgr/v1/hosts/$HOST_ID/roles/pf9-neutron-base

  $ curl -X PUT -H "x-auth-token: $OS_TOKEN" -H 'content-type: application/json' '$DU/resmgr/v1/hosts/$HOST_ID/roles/pf9-neutron-ovn-controller

  $ curl -X PUT -H "x-auth-token: $OS_TOKEN" -H 'content-type: application/json' '$DU/resmgr/v1/hosts/$HOST_ID/roles/pf9-neutron-ovn-metadata-agent

  $ curl -X PUT -H "x-auth-token: $OS_TOKEN" -H 'content-type: application/json' '$DU/resmgr/v1/hosts/$HOST_ID/roles/pf9-ip-discovery
  </code></pre>
* **Persistent Storage**

  <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">$ curl -X PUT -H "x-auth-token: $OS_TOKEN" -H 'content-type: application/json' '$DU/resmgr/v1/hosts/$HOST_ID/roles/pf9-cindervolume-base

  $ curl -X PUT -H "x-auth-token: $OS_TOKEN" -H 'content-type: application/json' '$DU/resmgr/v1/hosts/$HOST_ID/roles/pf9-cindervolume-config
  </code></pre>
* **Image Library**

  <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">$ curl -X PUT -H "x-auth-token: $OS_TOKEN" -H 'content-type: application/json' '$DU/resmgr/v1/hosts/$HOST_ID/roles/pf9-glance-role
  </code></pre>
* **Advanced Remote Support**

  <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">$ curl -X PUT -H "x-auth-token: $OS_TOKEN" -H 'content-type: application/json' '$DU/resmgr/v1/hosts/$HOST_ID/roles/pf9-support
  </code></pre>
* **High Availabilty**

  <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">$ curl -X PUT -H "x-auth-token: $OS_TOKEN" -H 'content-type: application/json' '$DU/resmgr/v1/hosts/$HOST_ID/roles/pf9-ha-slave
  </code></pre>

{% endstep %}

{% step %}
**Observe installation progress**

* Observe the hostagent logs

  <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">$ tail -f /var/log/pf9/hostagent.log
  </code></pre>
* After applying a package wait for converge to complete before applying the next.
  {% endstep %}
  {% endstepper %}

## Validation

* Check the packages that are installed on the host.

  On Ubuntu:

  <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">$ dpkg -l | grep pf9
  </code></pre>

  On Platform9 OS:

  <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">$ rpm -qa | grep pf9
  </code></pre>
* Check the roles applied using:

  <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">$ curl -sS -H "x-auth-token: $OS_TOKEN" '$DU/resmgr/v1/hosts/$HOST_ID' | jq '{hostconfig_id, roles, role_status}'
  </code></pre>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://platform9.com/kb/pcd/generic/how-to-manually-apply-roles-on-a-host-using-api-calls.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
