Skip to content

Commit

Permalink
Merge pull request #900 from mkllnk/new-relic
Browse files Browse the repository at this point in the history
Install New Relic infrastructure agent
  • Loading branch information
dacook authored Oct 10, 2023
2 parents 0646623 + d7c0398 commit a50f9d5
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 5 deletions.
18 changes: 13 additions & 5 deletions inventory/host_vars/_example.com/secrets.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,16 @@ smtp_password:
#geocoder_service: mapbox
#geocoder_timeout: 7

# New relic settings
# see: https://one.eu.newrelic.com/admin-portal/, Administration > API keys to get the license key
# new_relic_agent_enabled: true
# new_relic_app_name: "Open Food Network"
# new_relic_license_key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
## New Relic settings
#
# See: https://one.eu.newrelic.com/admin-portal/ > API keys
#
# Infrastructure agent:
#new_relic_api_key: "NRAK-XXXXXXXXXXXXXXXXXXXXXXXXXXX"
#new_relic_account_id: "0000000"
#new_relic_region: "EU"
#
# Rails APM:
#new_relic_agent_enabled: true
#new_relic_app_name: "Open Food Network"
#new_relic_license_key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
5 changes: 5 additions & 0 deletions playbooks/provision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@
become: yes
tags: logrotate

- role: newrelic
become: yes
when: new_relic_api_key is defined
tags: newrelic

tasks:
- name: Fix Ruby # noqa 301
command:
Expand Down
4 changes: 4 additions & 0 deletions roles/newrelic/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- name: restart newrelic_infra
service:
name: "newrelic-infra.service"
state: restarted
29 changes: 29 additions & 0 deletions roles/newrelic/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---

- name: Download installer
ansible.builtin.get_url:
url: "https://download.newrelic.com/install/newrelic-cli/scripts/install.sh"
dest: "/tmp/new-relic-install.sh"
mode: "777"

- name: Install New Relic command
ansible.builtin.command: "/tmp/new-relic-install.sh"
args:
creates: /usr/local/bin/newrelic

- name: Install New Relic agent
command: /usr/local/bin/newrelic install -y
environment:
NEW_RELIC_API_KEY: "{{ new_relic_api_key }}"
NEW_RELIC_ACCOUNT_ID: "{{ new_relic_account_id }}"
NEW_RELIC_REGION: "{{ new_relic_region }}"
args:
creates: /usr/bin/newrelic-infra

- name: Use our standard names in dashboard
lineinfile:
name: "/etc/newrelic-infra.yml"
line: "display_name: {{ host_id }}"
regex: "^display_name:"
state: present
notify: restart newrelic_infra

0 comments on commit a50f9d5

Please sign in to comment.