> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/rdm/integrations/devops-ci-cd/ansible.md).

# Ansible

Use the Ansible collection for Devolutions Server to authenticate with an application identity, fetch server information, read secrets and write credentials.

Ansible integrates with Devolutions Server, a workspace type of Remote Desktop Manager, through the `devolutions.dvls` Ansible collection, which authenticates with an application identity to fetch server information, vaults and secrets, and to create or update credentials. It does not use a Remote Desktop Manager entry type.

## Prerequisites

* A Devolutions Server instance. See [Devolutions Server](https://docs.devolutions.net/server).
* Ansible 2.18.
* The Python `requests` library.
* A Devolutions Server application identity that can read the vault content: the ***View content*** permission on the vault, and the ***View*** and ***View password*** entry permissions on the secrets to fetch. To create or update credentials with `devolutions.dvls.create_secret`, it also needs the ***Add*** (create) or ***Edit*** (update) entry permission.

## What you can do

* Authenticate with the application ID (the `app_key` parameter) and the application secret of an application identity.
* Fetch server information and the list of vaults with the `devolutions.dvls.fetch_server` module.
* Fetch secrets by name or ID from a vault, or fetch all the secrets of a vault, with the `devolutions.dvls.fetch_secrets` module.
* Create or update a credential entry with the `devolutions.dvls.create_secret` module. Only the Credential type with the Default subtype is supported.
* Retrieve one field of a credential, or the whole credential, with the `devolutions.dvls.secret` and `devolutions.dvls.secret_full` lookup plugins, by name, path or universally unique identifier (UUID).

## Configure Ansible

1. Sign in to the Devolutions Server web interface.
2. Go to Administration – Management – Application identities (`{your-server-url}/administration/applications`) and click ***Add*** (the + button) to create an application identity.
3. Give the application identity access to the vault: in ***Role assignments***, assign a role that includes ***View content*** on the vault, such as ***Vault member***, and give it the entry permissions, for example through its ***User groups***. Note its ***Application ID*** and ***Application Secret***. The collection calls the application ID `app_key`.
4. Install the `devolutions.dvls` collection. See [Installing collections](https://docs.ansible.com/ansible/latest/collections_guide/collections_installing.html).
5. Optionally, set the `DVLS_APP_KEY` and `DVLS_APP_SECRET` environment variables to the application ID and the application secret. Only the lookup plugins read environment variables, and they also read `DVLS_SERVER_BASE_URL` and `DVLS_VAULT_ID`. The modules take `app_key` and `app_secret` as parameters, for example `lookup('env', 'DVLS_APP_KEY')`.

## Use Ansible

1. In a playbook, add a `devolutions.dvls.fetch_secrets` task with `server_base_url`, `app_key`, `app_secret` and `vault_id`.
2. Add a `secrets` list with the `secret_name` or the `secret_id` of each secret to fetch, or omit `secrets` to fetch all the secrets of the vault.
3. Register the result and read a field with `{{ value['name-or-id'].password }}`. Use the field name of the credential type, such as `username` or `password`.
4. To read the server information and the vaults, add a `devolutions.dvls.fetch_server` task with `server_base_url`, `app_key` and `app_secret`.
5. To write a credential, add a `devolutions.dvls.create_secret` task with `vault_id` and a `secret` that has a `secret_name` and a `value`.
6. To read a field inline, use `lookup('devolutions.dvls.secret', 'prod-database', field='username')`. The `field` is `password` when omitted.
7. Run the playbook with [ansible-playbook](https://docs.ansible.com/ansible/latest/cli/ansible-playbook.html).

## Integration level

Ansible is an integration level 2 – Moderate support integration. See [Integration levels](https://docs.devolutions.net/resources/integration-levels).

#### See also

* [Application identities](https://docs.devolutions.net/server/web-interface/administration/user-and-security-management/applications-identities)
* [ansible-dvls on GitHub](https://github.com/Devolutions/ansible-dvls)


---

# 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://docs.devolutions.net/rdm/integrations/devops-ci-cd/ansible.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.
