Last active
May 2, 2017 15:54
-
-
Save thbkrkr/34db1eeb9570de3121e3 to your computer and use it in GitHub Desktop.
Ansible Playbook to install the NewRelic agent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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