Skip to content

Commit

Permalink
fix: Organization and fleet environment variables to install recipe role
Browse files Browse the repository at this point in the history
Fix/organization
  • Loading branch information
Avinash-Sanpala authored Aug 8, 2024
2 parents 5a1eb4b + bed1a75 commit 3a152b7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 32 deletions.
61 changes: 30 additions & 31 deletions test/definitions/super-agent/suse/suse154-super-agent.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
{
"global_tags": {
"owning_team": "virtuoso",
"Environment": "development",
"Department": "product",
"Product": "virtuoso"
},
"global_tags": {
"owning_team": "virtuoso",
"Environment": "development",
"Department": "product",
"Product": "virtuoso"
},
"resources": [
{
"id": "host1",
"provider": "aws",
"type": "ec2",
"size": "t3.nano",
"ami_name": "suse-sles-15-sp4-chost-byos-v????????-hvm-ssd-x86_64"
}
],
"instrumentations": {
"resources": [
{
"id": "host1",
"provider": "aws",
"type": "ec2",
"size": "t3.nano",
"ami_name": "suse-sles-15-sp4-chost-byos-v????????-hvm-ssd-x86_64"
{
"id": "nr_super_agent",
"resource_ids": ["host1"],
"provider": "newrelic",
"source_repository": "https://github.com/newrelic/open-install-library.git",
"deploy_script_path": "test/deploy/linux/newrelic-cli/install-recipe/roles",
"params": {
"recipe_content_url": "https://raw.githubusercontent.com/newrelic/open-install-library/main/recipes/newrelic/infrastructure/super-agent/suse.yml",
"validate_output": "New Relic Super Agent\\s+\\(installed\\)",
"recipe_targeted": "super-agent",
"use_organization_id": true
}
],
"instrumentations": {
"resources": [
{
"id": "nr_super_agent",
"resource_ids": [
"host1"
],
"provider": "newrelic",
"source_repository": "https://github.com/newrelic/open-install-library.git",
"deploy_script_path": "test/deploy/linux/newrelic-cli/install-recipe/roles",
"params": {
"recipe_content_url": "https://raw.githubusercontent.com/newrelic/open-install-library/main/recipes/newrelic/infrastructure/super-agent/suse.yml",
"validate_output": "New Relic Super Agent\\s+\\(installed\\)",
"recipe_targeted": "super-agent"
}
}
]
}
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# newrelic_cli_path: (optional) The newrelic-cli to use instead of using latest published
# command_should_fail: (optional) Should the newrelic install command fail? False by default.
# validate_output: (optional) An array of Strings that must appear in stdout for this test to pass.
# use_organization_id: (optional) A boolean value to control if NEW_RELIC_ORGANIZATION_ID should be added to env_vars. False by default.
# newrelic_organization_id: (optional) The NewRelic Organization ID if use_organization_id is set to True.

- name: Prepare command_should_fail option
when: command_should_fail is not defined
Expand Down Expand Up @@ -57,6 +59,11 @@
- name: Adding sudo user environment variable
set_fact:
env_vars: "{{ env_vars }} SUDO_USER={{ ansible_user }}"

- name: Adding newrelic organization environment variable
set_fact:
env_vars: "{{ env_vars }} NEW_RELIC_ORGANIZATION={{ newrelic_organization_id }}"
when: use_organization_id | bool == True

- name: Get CLI environment variables
shell: "/bin/bash -ic 'env' | grep NR_CLI_"
Expand Down Expand Up @@ -166,4 +173,6 @@
- fail:
msg: "Failed to validate that {{ validate_output }} is in output:{{ output.stdout }}"
when: validate_output is defined and output.stdout is not search(validate_output)
when: command_should_fail == False
when: command_should_fail == False
when: validate_output is defined and output.stdout is not search(validate_output)
when: command_should_fail == False

0 comments on commit 3a152b7

Please sign in to comment.