From c512ec13c6cea1acdabacb1b6f7e34677b5f8e27 Mon Sep 17 00:00:00 2001 From: lavenderguitar Date: Wed, 26 Apr 2023 13:48:10 -0400 Subject: [PATCH] NR Agent local install playbook. --- .../install_newrelic_agent-centos.yml | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 ansible-playbooks/install_newrelic_agent-centos.yml diff --git a/ansible-playbooks/install_newrelic_agent-centos.yml b/ansible-playbooks/install_newrelic_agent-centos.yml new file mode 100644 index 0000000..9f08d2f --- /dev/null +++ b/ansible-playbooks/install_newrelic_agent-centos.yml @@ -0,0 +1,48 @@ +--- +- name: Install New Relic Agent on CentOS + hosts: localhost + remote_user: centos + become: true + + vars: + newrelic_license_key: "YOUR_LICENSE_KEY_HERE" + newrelic_agent_name: "CUSTOM_AGENT_NAME" + + tasks: + - name: Add New Relic yum repository + yum_repository: + name: newrelic + description: New Relic Yum Repository + baseurl: https://download.newrelic.com/infrastructure_agent/linux/yum/el/7/x86_64 + gpgcheck: 1 + gpgkey: https://download.newrelic.com/infrastructure_agent/gpg/newrelic-infra.gpg + enabled: 1 + + - name: Install New Relic agent + yum: + 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 + + - name: Set New Relic agent name + lineinfile: + path: /etc/newrelic-infra.yml + regexp: "^display_name:" + line: "display_name: {{ newrelic_agent_name }}" + state: present + notify: + - restart newrelic-infra + + handlers: + - name: restart newrelic-infra + service: + name: newrelic-infra + state: restarted