newrelic.newrelic-infra
Ansible Role for the New Relic Infrastructure Agent
Ansible is a tool that helps automate software installations and configurations. This document describes how to use Ansible to manage the New Relic Infrastructure Agent.
New Solution
New Relic now provides an Ansible solution that makes it easier to scale your observability efforts.
Installation
To install the New Relic role, run this command:
ansible-galaxy install newrelic.newrelic-infra
Getting Started
To use the role in your playbook, include the following code in your YAML file:
# myplaybook.yml
---
- hosts: webservers
roles:
- role: newrelic.newrelic-infra
vars:
nrinfragent_config:
license_key: 12345
To set up newrelic.newrelic-infra
as a dependency for your role, add this to your meta/main.yml
file:
# roles/myapp/meta/main.yml
---
dependencies:
- role: newrelic.newrelic-infra
Usage
This role can perform the following tasks:
- Install the agent using the OS package manager
- Install the agent using a tarball (Linux only)
- Install integrations via the OS package manager
- Configure the agent
- Set up the agent's service on the OS
By default, the role installs the agent and integrations using the OS package manager, configures the agent, and sets up the service. You can also use specific tags to perform other actions.
Basic Example
To install the agent and configure it, use this playbook snippet:
---
- hosts: ap_ne_1
roles:
- name: newrelic.newrelic-infra
vars:
log_file: /opt/logs/newrelic-infra.log
verbose: 0
nrinfragent_config:
license_key: 12345
custom_attributes:
environment: dev
Tarball Installation (Linux Only)
To install using a tarball, set the nrinfragent_tarball_version
variable:
- hosts: ap_ne_1
roles:
- name: newrelic.newrelic-infra
vars:
nrinfragent_tarball_version: 1.18.0
nrinfragent_tarball_download_dir: /opt/newrelic/
nrinfragent_config:
log_file: /opt/logs/newrelic-infra.log
verbose: 0
license_key: 12345
custom_attributes:
environment: dev
To use a local tarball, specify the local file path:
- hosts: ap_ne_1
roles:
- name: newrelic.newrelic-infra
vars:
nrinfragent_tarball_local_file_path: /path/to/local/tarball
Configure Only
If you want to configure an already installed agent, use the following snippet:
- hosts: ap_ne_1
tasks:
- name: Configure the New Relic Infrastructure Agent
include_role:
name: newrelic.newrelic-infra
vars:
nrinfragent_config:
license_key: 12345
log_file: /opt/logs/newrelic-infra.log
verbose: 0
custom_attributes:
environment: dev
tags:
- nria_configure
Role Configuration
Important Variables
nrinfragent_state
: Determines whether to install or uninstall packages.nrinfragent_service_state
: Indicates whether thenewrelic-infra
service should start after installation.nrinfragent_service_enabled
: Indicates if the service should start at boot.nrinfragent_config
: Required for setting up the agent. Must include alicense_key
.
Test the Role
The role uses Molecule for testing. You can run tests using the command:
molecule test
Release to Ansible Galaxy
When releasing a new version, update the CHANGELOG.md
, create a new GitHub release, and monitor the build.
Compatibility
This role is compatible with various operating systems, including:
- RHEL/CentOS
- Ubuntu
- Debian
- SUSE
- Windows
Support and Contributions
For help, you can visit the New Relic Community. Contributions are welcome; please review the guidelines.
License
This project is licensed under the Apache 2.0 License.
Role to install New Relic Infrastructure agent
ansible-galaxy install newrelic.newrelic-infra