Skip to content

Instantly share code, notes, and snippets.

@thbkrkr
Last active May 2, 2017 15:54
Show Gist options
  • Save thbkrkr/34db1eeb9570de3121e3 to your computer and use it in GitHub Desktop.
Save thbkrkr/34db1eeb9570de3121e3 to your computer and use it in GitHub Desktop.
Ansible Playbook to install the NewRelic agent
#
# Playbook to install the newrelic agent on a machine
#
# ansible-playbook install-newrelic.yml -e newrelic_license_key=$NEWRELIC_LICENSE_KEY
#
---
- hosts: all
become: yes
gather_facts: false
vars:
os_codename: jessie
tasks:
- name: NewRelic | Add apt sources list
apt_repository:
repo: deb [arch=amd64] http://download.newrelic.com/infrastructure_agent/linux/apt {{ os_codename }} main
state: present
tags: newrelic
- name: NewRelic | Add GPG key to the apt sources keyring
apt_key:
url: https://download.newrelic.com/infrastructure_agent/gpg/newrelic-infra.gpg
state: present
tags: newrelic
- name: NewRelic | Add license key in the config file
lineinfile:
path: /etc/newrelic-infra.yml
regexp: '^license_key: {{ newrelic_license_key }}'
line: 'license_key: {{ newrelic_license_key }}'
state: present
notify: NewRelic | Restart service
tags: [newrelic, newrelic-license]
- name: NewRelic | Run the install command
apt: pkg=newrelic-infra update_cache=yes
tags: newrelic
- name: NewRelic | Check that NewRelic service is started
systemd:
name: newrelic-infra
state: started
enabled: True
tags: newrelic
handlers:
- name: NewRelic | Restart service
systemd:
name: newrelic-infra
state: restarted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment