|
| 1 | +--- |
| 2 | +- name: Test eBPF Agent |
| 3 | + hosts: 127.0.0.1 |
| 4 | + connection: local |
| 5 | + become: true |
| 6 | + gather_facts: yes |
| 7 | + |
| 8 | + tasks: |
| 9 | + - name: Test eBPF Agent |
| 10 | + block: |
| 11 | + - name: Cleanup |
| 12 | + include_tasks: ./tasks/clean_all.yaml |
| 13 | + |
| 14 | + # Currently eBPF Agent is not embedded in the AC package but installed along side it with the recipe. |
| 15 | + # NEW_RELIC_AGENT_CONTROL=true disables the systemd service so the Agent is controlled by AC. |
| 16 | + - name: Install eBPF Agent |
| 17 | + shell: | |
| 18 | + curl -Ls https://download.newrelic.com/install/newrelic-cli/scripts/install.sh | \ |
| 19 | + bash && sudo \ |
| 20 | + NEW_RELIC_CLI_SKIP_CORE=1 \ |
| 21 | + NEW_RELIC_LICENSE_KEY={{ nr_license_key }} \ |
| 22 | + NEW_RELIC_API_KEY={{ nr_api_key }} \ |
| 23 | + NEW_RELIC_ACCOUNT_ID={{ nr_account_id }} \ |
| 24 | + NEW_RELIC_REGION=US \ |
| 25 | + NEW_RELIC_AGENT_CONTROL=true \ |
| 26 | + /usr/local/bin/newrelic install -n ebpf-agent-installer |
| 27 | + register: out |
| 28 | + - debug: |
| 29 | + var: out.stdout_lines |
| 30 | + |
| 31 | + - name: Install Agent Control |
| 32 | + include_role: |
| 33 | + name: newrelic-agent-control |
| 34 | + |
| 35 | + - name: Register agent control version |
| 36 | + command: "/usr/bin/newrelic-agent-control --version" |
| 37 | + register: version |
| 38 | + |
| 39 | + - name: Assert version |
| 40 | + include_role: |
| 41 | + name: caos.ansible_roles.assert_version |
| 42 | + vars: |
| 43 | + target_versions: |
| 44 | + - exec: "/usr/bin/newrelic-agent-control --version" |
| 45 | + version: "{{ package_version }}" |
| 46 | + when: package_version | length > 0 |
| 47 | + |
| 48 | + - name: Debug agent control version |
| 49 | + debug: |
| 50 | + var: version.stdout |
| 51 | + |
| 52 | + - name: Setup AC config |
| 53 | + include_role: |
| 54 | + name: edit_yaml_config |
| 55 | + vars: |
| 56 | + config_path: "/etc/newrelic-agent-control/config.yaml" |
| 57 | + update_config: |
| 58 | + log: |
| 59 | + format: |
| 60 | + ansi_colors: true |
| 61 | + target: true |
| 62 | + level: debug |
| 63 | + agents: |
| 64 | + nr-infra: |
| 65 | + agent_type: "newrelic/com.newrelic.infrastructure:0.1.0" |
| 66 | + nr-ebpf: |
| 67 | + agent_type: "newrelic/com.newrelic.ebpf:0.1.0" |
| 68 | + |
| 69 | + - name: Add license to service |
| 70 | + shell: echo 'NEW_RELIC_LICENSE_KEY="{{ nr_license_key }}"' >> {{ agent_control_service_conf }} |
| 71 | + |
| 72 | + - name: Set test identifier |
| 73 | + set_fact: |
| 74 | + test_id: "onhost-e2e-ebpf_{{ lookup('pipe', 'date +%Y-%m-%d_%H-%M-%S') }}" |
| 75 | + |
| 76 | + - name: eBPF Agent config folder |
| 77 | + file: |
| 78 | + path: /etc/newrelic-agent-control/fleet/agents.d/nr-ebpf/values/ |
| 79 | + state: directory |
| 80 | + |
| 81 | + - name: eBPF Agent local config |
| 82 | + copy: |
| 83 | + dest: /etc/newrelic-agent-control/fleet/agents.d/nr-ebpf/values/values.yaml |
| 84 | + content: | |
| 85 | + config_agent: |
| 86 | + DEPLOYMENT_NAME: {{ test_id }} |
| 87 | +
|
| 88 | + # The infra-agent is used to generate traffic for ebpf metrics to appear. |
| 89 | + - name: Infra Agent config folder |
| 90 | + file: |
| 91 | + path: /etc/newrelic-agent-control/fleet/agents.d/nr-infra/values/ |
| 92 | + state: directory |
| 93 | + |
| 94 | + - name: Infra Agent local config |
| 95 | + copy: |
| 96 | + dest: /etc/newrelic-agent-control/fleet/agents.d/nr-infra/values/values.yaml |
| 97 | + content: | |
| 98 | + config_agent: |+ |
| 99 | + status_server_enabled: true |
| 100 | + status_server_port: 18003 |
| 101 | + license_key: {{'{{'}}NEW_RELIC_LICENSE_KEY{{'}}'}} |
| 102 | +
|
| 103 | + - name: Restart Agent Control |
| 104 | + include_role: |
| 105 | + name: caos.ansible_roles.service_status |
| 106 | + vars: |
| 107 | + service_name: "newrelic-agent-control" |
| 108 | + action: "restart" |
| 109 | + |
| 110 | + - name: Assert that the eBPF Agent is reporting data |
| 111 | + include_role: |
| 112 | + name: nrql_api_request |
| 113 | + apply: |
| 114 | + become: false |
| 115 | + vars: |
| 116 | + nrql_query: >- |
| 117 | + SELECT * |
| 118 | + FROM Metric |
| 119 | + WHERE metricName = 'ebpf.tcp.connection_duration' |
| 120 | + AND deployment.name = '{{ test_id }}' |
| 121 | + LIMIT 1 |
| 122 | + retries: 60 |
| 123 | + delay: 5 |
| 124 | + |
| 125 | + always: |
| 126 | + - name: AC logs |
| 127 | + shell: journalctl -u newrelic-agent-control --no-pager |
| 128 | + register: ac_logs |
| 129 | + |
| 130 | + - name: Debug AC logs |
| 131 | + debug: |
| 132 | + var: ac_logs.stdout_lines |
| 133 | + |
| 134 | + - name: Cleanup |
| 135 | + include_tasks: ./tasks/clean_all.yaml |
0 commit comments