You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.5 KiB
58 lines
1.5 KiB
---
|
|
- name: Install New Relic Agent on Amazon Linux 2
|
|
hosts: localhost
|
|
remote_user: ec2-user
|
|
become: true
|
|
|
|
vars:
|
|
newrelic_license_key: "YOUR_LICENSE_KEY_HERE"
|
|
newrelic_agent_name: "CUSTOM_AGENT_NAME"
|
|
|
|
tasks:
|
|
- name: Add New Relic GPG key
|
|
rpm_key:
|
|
key: https://download.newrelic.com/infrastructure_agent/gpg/newrelic-infra.gpg
|
|
state: present
|
|
|
|
- name: Add New Relic YUM repository
|
|
yum_repository:
|
|
name: newrelic-infra
|
|
description: New Relic Infrastructure
|
|
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: Create New Relic configuration file
|
|
file:
|
|
path: /etc/newrelic-infra.yml
|
|
state: touch
|
|
|
|
- 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
|
|
|