From 340b132584b809bc89094a56bc96c9f1a846a902 Mon Sep 17 00:00:00 2001 From: Ruben Ruiz de Gauna Date: Mon, 8 Jan 2024 14:29:43 +0100 Subject: [PATCH] NR-164383 feat: role for newrelic-cli --- .../roles/newrelic_cli/README.md | 14 +++++++++++++ .../roles/newrelic_cli/tasks/main.yml | 20 +++++++++++++++++++ .../roles/newrelic_cli/vars/main.yml | 5 +++++ 3 files changed, 39 insertions(+) create mode 100644 caos.ansible_roles/roles/newrelic_cli/README.md create mode 100644 caos.ansible_roles/roles/newrelic_cli/tasks/main.yml create mode 100644 caos.ansible_roles/roles/newrelic_cli/vars/main.yml diff --git a/caos.ansible_roles/roles/newrelic_cli/README.md b/caos.ansible_roles/roles/newrelic_cli/README.md new file mode 100644 index 0000000..0a8fc82 --- /dev/null +++ b/caos.ansible_roles/roles/newrelic_cli/README.md @@ -0,0 +1,14 @@ +Install agents using New Relic CLI + +```yaml +- name: install agent via newrelic-cli + include_role: + name: caos.ansible_roles.newrelic_cli + vars: + repo_endpoint: "https://download.newrelic.com/" + recipe: "newrelic-infra" + region: "STAGING" # US | EU | STAGING + nr_api_key: "user-api-key" + nr_account_id: "nr-account-id" + +``` diff --git a/caos.ansible_roles/roles/newrelic_cli/tasks/main.yml b/caos.ansible_roles/roles/newrelic_cli/tasks/main.yml new file mode 100644 index 0000000..543d495 --- /dev/null +++ b/caos.ansible_roles/roles/newrelic_cli/tasks/main.yml @@ -0,0 +1,20 @@ +--- + +# Currently package from production is installed because stg does not have https and nr-cli verifies this +# Until this is fixed we need to clean metadata to avoid error: "Not using downloaded repomd.xml because it is older than what we have" +- name: clean metadata + command: yum clean metadata + when: ansible_pkg_mgr == 'yum' + +- name: Download newrelic-cli installer + get_url: + url: https://raw.githubusercontent.com/newrelic/newrelic-cli/master/scripts/install.sh + dest: /tmp/newrelic-cli-install.sh + mode: '0111' + +- name: Install newrelic-cli + shell: yes | /tmp/newrelic-cli-install.sh + +- name: Install agent via newrelic-cli + no_log: true + shell: NEW_RELIC_DOWNLOAD_URL="{{ repo_endpoint }}" NEW_RELIC_REGION="{{ region }}" NEW_RELIC_API_KEY={{ nr_api_key }} NEW_RELIC_ACCOUNT_ID={{ nr_account_id }} /usr/local/bin/newrelic install -n {{ recipe }} --debug -y diff --git a/caos.ansible_roles/roles/newrelic_cli/vars/main.yml b/caos.ansible_roles/roles/newrelic_cli/vars/main.yml new file mode 100644 index 0000000..d766718 --- /dev/null +++ b/caos.ansible_roles/roles/newrelic_cli/vars/main.yml @@ -0,0 +1,5 @@ +repo_endpoint: "https://nr-downloads-ohai-staging.s3.amazonaws.com/" +recipe: "newrelic-infra" +region: "STAGING" +nr_api_key: "" +nr_account_id: ""