# Ansible with SDM

1. Install the SDM ssh aliases by adding the output of `sdm ssh alias` to your `.bashrc` file or running directly on the command line.
2. Create an Ansible inventory file with the following format:

   ```ini
   [group_name]
   sdm_server_name ansible_port=sdm_ssh_port ansible_host=127.0.0.1
   ```

   For example, if you have the following SSH servers configured...

   ... then your inventory file should look like this.

   ```ini
   [sdm]
   bastion01 ansible_port=60672 ansible_host=127.0.0.1
   bastion02 ansible_port=61300 ansible_host=127.0.0.1
   deployment04 ansible_port=60834 ansible_host=127.0.0.1
   ```
3. Connect to the servers you want to access using sdm: either click on each one in the UI and ensure the green lightning bolt icon is visible next to each, or run `sdm connect sdm_server_name` for each (or `sdm connect --all`).
4. Run Ansible using that inventory file.

   ```bash
   $ ansible -i ansibleinventory sdm -a "echo hello"
   deployment04 | SUCCESS | rc=0 >>
   hello

   bastion01 | SUCCESS | rc=0 >>
   hello

   bastion02 | SUCCESS | rc=0 >>
   hello
   ```


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.strongdm.com/admin/deployment/scenarios/ansible.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
