# Ansible: configure a host Collector Use this playbook to configure an existing Linux host's OpenTelemetry Collector. An instrumented application on that host sends OTLP/HTTP to loopback; the Collector batches and exports to Corridora over HTTPS. The playbook manages configuration, a restricted service account, and a systemd unit. It requires a verified Collector binary already installed. It does not discover or instrument your application automatically. ## Prerequisites - A Linux systemd host with Python available for Ansible, SSH access, and privilege escalation for the deployment user. - A supported `ansible-core` installation on the control machine and permission to administer the target hosts. - A pinned OpenTelemetry Collector Contrib binary at `/usr/local/bin/otelcol-contrib`, or an overridden `collector_binary` path. Follow the [host setup guide](../backend/infrastructure/hosts.md) to install and verify a release. - An unused local port 4318 and outbound DNS/HTTPS access to Corridora. - An active backend ingest key for the receiving organization. This configuration uses the `otlp_http` exporter name supported by Collector Contrib 0.160.0. Validate against the exact binary you deploy before upgrading or substituting another distribution. ## Copy the files Copy the following into one directory on the control machine: - [playbook.yml](examples/ansible/playbook.yml) - [inventory.ini.example](examples/ansible/inventory.ini.example), renamed to `inventory.ini` - [collector.yaml.j2](examples/ansible/collector.yaml.j2) - [collector.env.j2](examples/ansible/collector.env.j2) - [corridora-otel.service.j2](examples/ansible/corridora-otel.service.j2) Replace the inventory hostname and SSH user. Add only the intended application hosts to `telemetry_hosts`. Review existing Collector installations to avoid two services competing for the same listener. ## Supply the key through Vault Create an encrypted variables file: ```bash ansible-vault create secrets.yml ``` In the editor opened by Vault, add: ```yaml corridora_ingest_key: "YOUR_BACKEND_INGEST_KEY" ``` Supply only the key value here; the Collector configuration adds the header name. Keep the Vault password in your organization's secret workflow, separate from the encrypted file. Vault encrypts the source file; it does not mean the running Collector can use an encrypted key without decryption. The playbook writes a root-owned `0600` environment file on the target. systemd reads it before starting the restricted service process. Secret-writing and validation tasks suppress output and diffs; do not add debug tasks that print the variables or environment. ## Validate and apply From the copied example directory: ```bash ansible-playbook -i inventory.ini playbook.yml \ --syntax-check --extra-vars @secrets.yml --ask-vault-pass ansible-playbook -i inventory.ini playbook.yml \ --check --extra-vars @secrets.yml --ask-vault-pass ansible-playbook -i inventory.ini playbook.yml \ --extra-vars @secrets.yml --ask-vault-pass ``` Supply your usual SSH and privilege-escalation options if required. Review check-mode output before applying; check mode predicts supported changes but does not start or validate the service. Initial check-mode runs can be limited by accounts/directories that do not exist until application. The actual run validates the rendered Collector configuration with the installed binary before service startup. Changes to configuration or secrets notify a restart handler. Reapplying unchanged configuration should leave a running service unchanged. ## Point applications at the listener Configure an instrumented application running in the **same host network namespace**: ```dotenv OTEL_SERVICE_NAME=shop-api OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4318 OTEL_TRACES_EXPORTER=otlp OTEL_METRICS_EXPORTER=none OTEL_LOGS_EXPORTER=none OTEL_PROPAGATORS=tracecontext,baggage ``` The application does not need the Corridora key for this local listener. Remove direct-export credential and signal-specific endpoint overrides when changing its destination. Continue setting release/environment resource attributes in the application. The receiver binds only to loopback and has no remote authentication. A container's `127.0.0.1` is usually its own namespace, not the host; use the [Docker topology](../backend/infrastructure/docker.md) rather than copying this endpoint into an isolated container. Do not open the listener to the internet to make it reachable. The configuration accepts traces, metrics, and logs that applications actually emit. It does not read arbitrary host log files, scrape host metrics, or persist the sending queue to disk. See the [Collector guide](../../collector.md) for pipeline extensions and delivery tradeoffs. ## Verify and rotate On a target host, check `systemctl status corridora-otel` and recent `journalctl -u corridora-otel` messages without printing the secret environment. Then generate a real application request and confirm its span in Corridora. Install [RUM](../../browser-rum.md) in the frontend and run [deployment verification](../verification.md) to check browser/server trace IDs. The Collector forwards existing context; it does not create missing parent spans or repair a removed header. For key rotation, update the encrypted variable with `ansible-vault edit secrets.yml`, apply the playbook, and confirm new exports. The restart refreshes the Collector's environment. Deploy a replacement key before revoking the previous credential when continuity matters.