--- - name: Configure a host-local OpenTelemetry Collector hosts: telemetry_hosts become: true gather_facts: true vars: collector_binary: /usr/local/bin/otelcol-contrib corridora_endpoint: https://ingest.corridora.ai tasks: - name: Require a Linux systemd host ansible.builtin.assert: that: - ansible_facts.system == "Linux" - ansible_facts.service_mgr == "systemd" - name: Require an ingest key supplied through Vault ansible.builtin.assert: that: - corridora_ingest_key is defined - corridora_ingest_key | length > 0 no_log: true - name: Inspect the preinstalled verified Collector binary ansible.builtin.stat: path: "{{ collector_binary }}" register: collector_executable - name: Require an executable Collector installation ansible.builtin.assert: that: - collector_executable.stat.exists - collector_executable.stat.executable - name: Create the service group ansible.builtin.group: name: corridora-otel system: true - name: Create the service account ansible.builtin.user: name: corridora-otel group: corridora-otel system: true create_home: false shell: /usr/sbin/nologin - name: Create the configuration directory ansible.builtin.file: path: /etc/corridora-otel state: directory owner: root group: corridora-otel mode: "0750" - name: Write the Collector configuration ansible.builtin.template: src: collector.yaml.j2 dest: /etc/corridora-otel/collector.yaml owner: root group: corridora-otel mode: "0640" notify: Restart Collector - name: Write the secret environment file ansible.builtin.template: src: collector.env.j2 dest: /etc/corridora-otel/collector.env owner: root group: root mode: "0600" no_log: true diff: false notify: Restart Collector - name: Validate the installed Collector configuration ansible.builtin.command: argv: - "{{ collector_binary }}" - validate - --config=/etc/corridora-otel/collector.yaml environment: CORRIDORA_INGEST_KEY: "{{ corridora_ingest_key }}" changed_when: false no_log: true when: not ansible_check_mode - name: Install the service unit ansible.builtin.template: src: corridora-otel.service.j2 dest: /etc/systemd/system/corridora-otel.service owner: root group: root mode: "0644" notify: Restart Collector - name: Enable and start the Collector ansible.builtin.systemd_service: name: corridora-otel daemon_reload: true enabled: true state: started when: not ansible_check_mode handlers: - name: Restart Collector ansible.builtin.systemd_service: name: corridora-otel daemon_reload: true state: restarted when: not ansible_check_mode