# Turn Labeled GitHub Issues Into Pull Requests for an Ansible Role

Yes. When a maintainer labels an issue on your Ansible role, an agent reads it, changes the tasks or variables it names, proves it with Molecule and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/github-issue-to-pr/ansible/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads the issue that arrives after the prompt and then the whole role, which for a role is small enough to do properly. In a role shaped like geerlingguy/ansible-role-docker, `tasks/main.yml` loads `vars/<distribution>.yml`, `vars/<os_family>.yml` or `vars/main.yml` through `first_found`, includes `setup-RedHat.yml`, `setup-Suse.yml` or `setup-Debian.yml` by `ansible_facts.os_family`, installs `docker_packages` (with `allow_downgrade` on RedHat and Debian), installs the compose plugin, writes `/etc/docker/daemon.json` from `docker_daemon_options`, patches the service's `ExecStart` when `docker_service_start_command` is set, starts the service, flushes handlers, and adds `docker_users` to the `docker` group through `docker-users.yml`. `defaults/main.yml` is the public interface: `docker_edition`, `docker_packages`, `docker_obsolete_packages`, `docker_service_manage`, `docker_install_compose_plugin`, `docker_compose_version` (`v2.32.1`), `docker_add_repo`, `docker_repo_url`, `docker_apt_release_channel`, `docker_apt_gpg_key` and the rest, each documented again in `README.md` under Role Variables.

Most issues on a role like this ask for one of three things, and the agent maps the issue to the file before it edits: a new variable (an apt suite other than `ansible_facts.distribution_release`, which `setup-Debian.yml` passes to `deb822_repository` as `suites`), a behaviour on one OS family (`setup-RedHat.yml` fetches the repo file into `/etc/yum.repos.d` and has a RHEL 8 block for `containerd.io`; `setup-Suse.yml` builds its zypper URL from the release mapping in `vars/Suse.yml`), or a bug in a condition (`when:` clauses that compare `ansible_version.full` or check `docker_daemon_options.keys() | length`). A new variable gets a default in `defaults/main.yml`, a use in the one task that needs it, and a paragraph in `README.md`; the agent does not rename or reorder existing variables, because every playbook that uses the role depends on them, and `meta/main.yml` says the role supports Ansible from `2.15.1`, so it uses no newer module argument.

Then it proves the change the way the repository does. `molecule/default/molecule.yml` uses the Docker driver with the image `geerlingguy/docker-${MOLECULE_DISTRO:-rockylinux9}-ansible:latest`, privileged with `cgroupns_mode: host` so systemd runs; `converge.yml` applies the role after waiting for `systemctl is-system-running`, and `verify.yml` runs `docker version`, checks `systemctl is-active docker` and pulls `hello-world`. In its sandbox the agent installs `ansible`, `molecule`, `molecule-plugins[docker]` and `docker`, exactly as `.github/workflows/ci.yml` does, and runs `MOLECULE_DISTRO=<distro> molecule test` for one distro from each OS family its change touches: `ubuntu2404` for a Debian-family change, `rockylinux10` for RedHat, `opensuseleap15` for Suse. A change that adds a variable gets a second converge with that variable set, through `MOLECULE_PLAYBOOK` or an extra vars file, so the new path is the one that ran.

It lints as the `lint` job does, `yamllint .` under the repository's `.yamllint` (default rules with a line-length warning at 200), and runs `ansible-lint` while respecting the `skip_list` in `.ansible-lint` (`yaml`, `risky-shell-pipe`, `role-name`) rather than reformatting tasks the maintainer left alone. The pull request names the issue with `Closes #<n>`, quotes the issue's request in one sentence, explains which file carries the change and why, and pastes the `molecule test` and `yamllint` output for each distro it ran. It changes neither the seven-distro matrix in `ci.yml` nor the weekly `0 7 * * 0` schedule.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Implement the labelled GitHub issue that follows this prompt in this Ansible role and open a pull request. Read the issue and its comments first; if it does not say what behaviour or variable is wanted, stop and report what is missing instead of guessing. Then read tasks/main.yml, every setup-*.yml and the other task files, defaults/main.yml, vars/, handlers/main.yml, meta/main.yml, README.md, molecule/default/molecule.yml, converge.yml and verify.yml, .github/workflows/ci.yml, .yamllint and .ansible-lint. Make the smallest change that resolves the issue: a new variable gets a default in defaults/main.yml, one use in the task that needs it and a README entry under Role Variables; do not rename or reorder existing variables, and use no module argument newer than the min_ansible_version in meta/main.yml. Install ansible, molecule, molecule-plugins[docker] and docker as ci.yml does, and run MOLECULE_DISTRO=<distro> molecule test for one distro from each OS family your change touches, plus a converge with any new variable set. Run yamllint . and ansible-lint, keeping the existing skip list. Open a pull request with Closes #<issue number>, one paragraph on the cause and the change, and the molecule and lint output. Do not merge it.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request on a branch of its own that closes the issue by number. For a variable request the diff is three places: a line in `defaults/main.yml`, a use in one task under `tasks/`, and a block in `README.md`; for a bug it is a `when:` or a module argument in one `setup-*.yml` file or in `tasks/main.yml`. The body pastes `molecule test` output per distro, the converge with the new variable set, and the `yamllint` and `ansible-lint` output.

The repository's `ci.yml` then runs on the pull request: `yamllint` in the `lint` job and `molecule test` across `rockylinux10`, `ubuntu2404`, `ubuntu2204`, `debian13`, `debian12`, `fedora43` and `opensuseleap15`. The agent ran one distro per family it touched; the matrix runs all seven, including the families it did not change, which is the check that the change is confined to where the issue pointed.

A reviewer reads the issue against the diff, checks that the new default keeps today's behaviour for every playbook that does not set it, and confirms the README entry matches the variable's name and default. A change that touched `molecule.yml` or the CI matrix needs its own explanation, because the issue asked for a role change, not a test-infrastructure one.

## Run it on every GitHub issue labelled for the agent

Add an automation to the Project that holds the role with this prompt and a `github` trigger on `issues.labeled`, with the label you reserve for the agent in its `labels`. Only a label applied by an owner, member or collaborator fires it, so a stranger's label starts nothing; the trigger appends the issue to the prompt as data, and each labelled issue starts one run on its own branch. `max_runs_per_hour` on the automation caps a triage session that labels ten issues at once.

From your own server instead, a handler for GitHub's `issues` webhook with `action: labeled` and your label sends `POST /o/{org}/sessions` with this prompt, the issue's number, title, body and comments appended to `input`, the repository in `resources`, and a `request_id` that is a UUID v5 of the issue number so a redelivery returns the same run. A `webhook_url` on the key receives `run.completed` with `data.session_url` to read the pull request from.

## Why run it on Rush?

A role change is cheap to write and expensive to prove: the proof is a privileged systemd container per distribution, the right Ansible and Molecule versions, and ten minutes of converge and verify for each one. On a laptop that is why a small issue waits for a weekend. In a Rush sandbox the agent has its own Docker daemon, installs what `ci.yml` installs, and every `molecule` command with its Ansible output stays in the transcript.

Each labelled issue gets its own run, its own branch and its own pull request, so three requests on the same day do not step on each other, and the full seven-distro matrix on the pull request is the check a reviewer trusts. The agent's job is the file-level change and the per-family proof; the matrix and the maintainer decide.

## Frequently asked questions

### Does the agent run all seven distributions?

No. It runs `molecule test` for one distro from each OS family its change touches, because each run builds and converges a systemd container. The matrix in `ci.yml` runs all seven on the pull request, and that is the check that counts.

### What if the issue is vague?

The prompt tells it to stop and report what is missing rather than guess at a variable name or a behaviour. Add the detail to the issue and label it again; the new label starts a new run with the fuller text.

### Will it change variables my playbooks already use?

No. It adds defaults and uses them; it does not rename or reorder what is in `defaults/main.yml`, and a new default is chosen so a playbook that does not set it keeps today's behaviour. The pull request says which default it chose and why.

### Can it loosen the lint rules to get green?

The prompt forbids it. `.ansible-lint` has a short skip list and `.yamllint` extends the defaults with a long-line warning; the agent runs both on its own change and fixes its own lines rather than adding to the skip list.

## More Ansible jobs

- [Migrate an Ansible Role to Fully Qualified Collection Names](https://getrush.ai/run/migrate-to-fqcn/ansible/)
- [Review Pull Requests on an Ansible Role](https://getrush.ai/run/review-pull-requests/ansible/)
- [Upgrade Ansible Collections and Fix Lint](https://getrush.ai/run/upgrade-ansible-collections/ansible/)

## The same job on other stacks

- [Turn Labeled GitHub Issues Into Pull Requests for a Django App](https://getrush.ai/run/github-issue-to-pr/django/)
- [Turn Labeled GitHub Issues Into Pull Requests for an Express API](https://getrush.ai/run/github-issue-to-pr/express/)
- [Turn Labeled GitHub Issues Into Pull Requests for a FastAPI App](https://getrush.ai/run/github-issue-to-pr/fastapi/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
