From 786f48b7ac2ca5e9331b4d81ff46124357ec681c Mon Sep 17 00:00:00 2001 From: lavenderguitar Date: Thu, 27 Apr 2023 15:33:22 -0400 Subject: [PATCH] Add NR agent install playbook for Ubuntu --- .../install_newrelic_agent-ubuntu.yml | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 ansible-playbooks/install_newrelic_agent-ubuntu.yml diff --git a/ansible-playbooks/install_newrelic_agent-ubuntu.yml b/ansible-playbooks/install_newrelic_agent-ubuntu.yml new file mode 100644 index 0000000..bbafec6 --- /dev/null +++ b/ansible-playbooks/install_newrelic_agent-ubuntu.yml @@ -0,0 +1,43 @@ +--- +- name: Install New Relic Agent on Ubuntu 20 + hosts: localhost + remote_user: ubuntu + become: true + + vars: + newrelic_license_key: "YOUR_LICENSE_KEY_HERE" + + tasks: + - name: Add New Relic GPG key + apt_key: + url: https://download.newrelic.com/infrastructure_agent/gpg/newrelic-infra.gpg + state: present + + - name: Add New Relic APT repository + apt_repository: + repo: deb [arch=amd64] https://download.newrelic.com/infrastructure_agent/linux/apt focal main + state: present + + - name: Update APT package cache + apt: + update_cache: yes + + - name: Install New Relic agent + apt: + name: newrelic-infra + state: present + + - name: Configure New Relic agent + lineinfile: + path: /etc/newrelic-infra.yml + regexp: "^license_key:" + line: "license_key: {{ newrelic_license_key }}" + state: present + notify: + - restart newrelic-infra + + handlers: + - name: restart newrelic-infra + service: + name: newrelic-infra + state: restarted