Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions agent-control/src/opamp/remote_config/validators/regexes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,19 @@ pub(super) mod tests {
fn test_validate() {
let content = r#"
health_port: 18003
config_agent: |+
config_agent:
staging: true
enable_process_metrics: true
status_server_enabled: true
status_server_port: 18003
log:
level: info
license_key: {{NEW_RELIC_LICENSE_KEY}}
license_key: '{{NEW_RELIC_LICENSE_KEY}}'
custom_attributes:
nr_deployed_by: newrelic-cli

config_integrations:
docker-config.yml: |
docker-config.yml:
integrations:
- name: nri-docker
when:
Expand Down Expand Up @@ -214,7 +214,7 @@ pub(super) mod tests {
}

pub static VALID_ONHOST_NRDOT_CONFIG: &str = r#"
config: |
config:

extensions:
health_check:
Expand Down Expand Up @@ -380,7 +380,7 @@ config: |
attributes:
- key: host.display_name
action: upsert
value: {{ display_name }}
value: '{{ display_name }}'

resourcedetection:
detectors: ["env", "system"]
Expand All @@ -403,7 +403,7 @@ config: |
otlp:
endpoint: staging-otlp.nr-data.net:4317
headers:
api-key: {{ nr_license_key_canaries }}
api-key: '{{ nr_license_key_canaries }}'

service:
"#;
Expand Down Expand Up @@ -518,8 +518,8 @@ config: |
################################################

# Configuration for the Infrastructure Agent
config_agent: |
license_key: {{ NEW_RELIC_LICENSE_KEY }}
config_agent:
license_key: '{{ NEW_RELIC_LICENSE_KEY }}'
staging: true
display_name: host-display-name
enable_process_metrics: true
Expand All @@ -529,7 +529,7 @@ config_agent: |

# Configuration for New Relic Integrations
config_integrations:
flex.yml: |
flex.yml:
integrations:
- name: nri-flex
offset: 10s
Expand Down Expand Up @@ -564,8 +564,8 @@ config_integrations:
################################################

# Configuration for the Infrastructure Agent
config_agent: |
license_key: {{ NEW_RELIC_LICENSE_KEY }}
config_agent:
license_key: '{{ NEW_RELIC_LICENSE_KEY }}'
staging: true
display_name: host-display-name
enable_process_metrics: true
Expand Down Expand Up @@ -605,8 +605,8 @@ config_integrations:
################################################

# Configuration for the Infrastructure Agent
config_agent: |
license_key: {{ NEW_RELIC_LICENSE_KEY }}
config_agent:
license_key: '{{ NEW_RELIC_LICENSE_KEY }}'
staging: true
display_name: host-display-name
enable_process_metrics: true
Expand All @@ -616,14 +616,14 @@ config_agent: |

# Configuration for New Relic Integrations
config_integrations:
mysql.yml: |
mysql.yml:
integrations:
- name: nri-mysql
offset: 10s
config:
name: RandomNumbers
exec: an extra command
mysql.yml: |
mysql.yml:
integrations:
- name: nri-mysql
env:
Expand All @@ -646,8 +646,8 @@ config_integrations:
################################################

# Configuration for the Infrastructure Agent
config_agent: |
license_key: {{ NEW_RELIC_LICENSE_KEY }}
config_agent:
license_key: '{{ NEW_RELIC_LICENSE_KEY }}'
staging: true
display_name: host-display-name
enable_process_metrics: true
Expand All @@ -657,7 +657,7 @@ config_agent: |

# Configuration for New Relic Integrations
config_integrations:
apache.yml: |
apache.yml:
- name: nri-apache
env:
INVENTORY: "true"
Expand All @@ -679,8 +679,8 @@ config_integrations:
################################################

# Configuration for the Infrastructure Agent
config_agent: |
license_key: {{ NEW_RELIC_LICENSE_KEY }}
config_agent:
license_key: '{{ NEW_RELIC_LICENSE_KEY }}'
staging: true
display_name: host-display-name
enable_process_metrics: true
Expand All @@ -690,7 +690,7 @@ config_agent: |

# Configuration for New Relic Integrations
config_integrations:
apache.yml: |
apache.yml:
- name: nri-apache
env:
INVENTORY: "true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@
copy:
dest: /etc/newrelic-agent-control/fleet/agents.d/infra/values/values.yaml
content: |
config_agent: |+
staging: {{ infra_staging }}
{% raw %}
config_agent:
staging: {% endraw -%} {{ infra_staging }} {%- raw %}
enable_process_metrics: true
status_server_enabled: true
status_server_port: 18003
license_key: {{'{{'}}NEW_RELIC_LICENSE_KEY{{'}}'}}
license_key: '{{NEW_RELIC_LICENSE_KEY}}'
{% endraw %}

- name: Add license to service
shell: echo 'NEW_RELIC_LICENSE_KEY="{{ nr_license_key }}"' >> {{ agent_control_service_conf }}
Expand Down
6 changes: 4 additions & 2 deletions test/onhost-e2e/ansible/ebpf_agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,12 @@
copy:
dest: /etc/newrelic-agent-control/fleet/agents.d/nr-infra/values/values.yaml
content: |
config_agent: |+
{% raw %}
config_agent:
status_server_enabled: true
status_server_port: 18003
license_key: {{'{{'}}NEW_RELIC_LICENSE_KEY{{'}}'}}
license_key: '{{NEW_RELIC_LICENSE_KEY}}'
{% endraw %}

- name: Restart Agent Control
include_role:
Expand Down
4 changes: 2 additions & 2 deletions test/onhost-e2e/ansible/migration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
status_server_enabled: true
status_server_port: 18003
license_key: {{ nr_license_key }}

- name: Install docker
include_role:
name: caos.ansible_roles.docker_install
Expand Down Expand Up @@ -67,7 +67,7 @@
labels:
test_id: {{ test_id }}
test_installed_agent: infra_agent

- name: Restart Infra Agent
include_role:
name: caos.ansible_roles.service_status
Expand Down
31 changes: 26 additions & 5 deletions test/onhost-e2e/ansible/remote_config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
---
# This test expects to have a created Fleet with an Active deployment containing an infra-agent
# remote configuration containing:
# config_agent: |+
# ```yaml
# config_agent:
# status_server_enabled: true
# status_server_port: 18003
# license_key: {{NEW_RELIC_LICENSE_KEY}}
# license_key: '{{NEW_RELIC_LICENSE_KEY}}'
# custom_attributes:
# config_origin: remote
# test_id: {{TEST_ID}}
# test_id: '{{TEST_ID}}'
# ```
# Remember to pass `{% raw %}` and `{% endraw %}` to escape the quoting and braces.
# This would make that the infra agent reported metrics contain a `config_origin: remote` attribute.

- name: Install AC and assert a remote config is applied.
Expand Down Expand Up @@ -96,13 +99,15 @@
copy:
dest: /etc/newrelic-agent-control/fleet/agents.d/nr-infra/values/values.yaml
content: |
{% raw %}
config_agent:
status_server_enabled: true
status_server_port: 18003
license_key: {{'{{'}}NEW_RELIC_LICENSE_KEY{{'}}'}}
license_key: '{{NEW_RELIC_LICENSE_KEY}}'
custom_attributes:
config_origin: local
test_id: {{'{{'}}TEST_ID{{'}}'}}
test_id: '{{TEST_ID}}'
{% endraw %}

- name: Restart Agent Control
include_role:
Expand Down Expand Up @@ -152,5 +157,21 @@
debug:
var: ac_logs.stdout_lines

- name: Inspect the remote values
shell: cat /var/lib/newrelic-agent-control/fleet/agents.d/nr-infra/values/values.yaml
register: remote_values

- name: Debug remote values
debug:
var: remote_values.stdout_lines

- name: Inspect the rendered config file from remote
shell: cat /var/lib/newrelic-agent-control/auto-generated/nr-infra/config/newrelic-infra.yaml
register: rendered_config

- name: Debug rendered config
debug:
var: rendered_config.stdout_lines

- name: Cleanup
include_tasks: ./tasks/clean_all.yaml
Loading