• /
  • EnglishEspañol日本語한국어Português
  • Log inStart now

Configure the infrastructure agent using Ansible

You can use New Relic's Ansible role to help you scale your New Relic Observability efforts using the New Relic CLI and New Relic Open Installation repository. For instructions on how to use Ansible, see the Ansible documentation. This is a community-supported effort.

Want to configure the infrastructure agent using Ansible? Create a New Relic account for free! No credit card required.

Important

This role will always install the latest released version of the New Relic agent and doesn't support installing older versions.

Sample code

New Relic provides configuration management sample code to help you install our infrastructure agent using workflows and tools that are common with many Ops teams. This is a basic Ansible role and is intended to be used as a starting place for creating your own customized workflow.

Configuration depends on your specific setup and standards. To view an Ansible sample role and more integration information, see the Ansible Galaxy documentation.

Compatibility and requirements

The Ansible role with New Relic's infrastructure agent requires a supported operating system.

If you need help with Ansible for Windows OS, take a look at Setting up a Windows Host, from the Ansible Documentation site.

This role is tested with the Ansible Core 2.13 and 2.14 and Python 3.10. Ansible Core versions before 2.10 are not supported.

Set up New Relic with Ansible

Installation

Ansible Galaxy

Link to Galaxy

bash
$
ansible-galaxy install newrelic.newrelic_install

Make sure you have ansible.windows and ansible.utils if they are not already installed:

bash
$
ansible-galaxy collection install ansible.windows ansible.utils

Manual

If you want to use a local copy of the role, clone the repo and run make in the project root to copy this repo to ~/.ansible/roles/newrelic.newrelic_install, enabling the role to behave as though it were installed from Galaxy.

Getting started

To get started using the role newrelic.newrelic_install:

  1. Include the role in your playbook.
  2. Customize the required variables.

After installing, include the newrelic.newrelic_install role in a new or existing playbook. Here is an example of configuring your role to install the infrastructure agent:

---
- name: Install New Relic
hosts: all
roles:
- role: newrelic.newrelic_install
vars:
targets:
- infrastructure
- logs
tags:
foo: bar
environment:
NEW_RELIC_API_KEY: <API key>
NEW_RELIC_ACCOUNT_ID: <Account ID>
NEW_RELIC_REGION: <Region>

Role configuration variables

Here are available variables for configuring the newrelic.newrelic_install role:

Variable

IsRequired

Description

targets

Required

List of targeted installs to run on hosts. Available options are:

  • infrastructure (Linux & Windows)
  • logs (Linux & Windows)
  • apm-php (Linux)
  • apm-nodejs (Linux)
  • apm-dotnet (Linux & Windows)
  • apm-java (Linux)
  • apache (Linux)
  • mssql (Windows)
  • mysql (Linux)
  • nginx (Linux)

tags

Optional

Key-value pairs of tags passed to the installation.

install_timeout_seconds

Optional

Sets timeout for installation task. Overrides the default timeout of 600s.

verbosity

Optional

Verbosity options for the installation (debug or trace) writes verbose output to a log file on the host.

Defaults

Set in defaults/main.yml:

  • cli_install_url
  • cli_install_download_location
  • target_name_map
  • verbosity_on_log_file_path_linux
  • verbosity_on_log_file_path_windows
  • default_install_timeout_seconds

Environment variables

Values are set under the environment keyword in your playbook:

  • NEW_RELIC_API_KEY (required)
  • NEW_RELIC_ACCOUNT_ID (required)
  • NEW_RELIC_REGION (optional: 'US' or 'EU', default 'US')

Additionally, you can set an optional HTTPS_PROXY variable to enable a proxy for your installation.

See ansible's remote environment for more info.

Important Note

  • The logs target requires infrastructure, and an error will be thrown if logs is specified without infrastructure.
  • The apm-nodejs agent installation is supported only for apps managed by PM2. To install the agent using a package manager such as npm or yarn or via other installation paths, please reference our docs.
  • The apm-dotnet agent installation for Windows is supported only for apps hosted by IIS. Linux installations are only supported for .NET applications which run as a systemd service.
  • The apm-java agent installation supports Java running in Tomcat, Wildfly/Jboss, and Jetty (standalone).
  • The following integrations require the infrastructure agent to be installed:
    • apm-java
    • apache
    • mssql
    • mysql
    • nginx

Additional Example Playbook

- name: Install New Relic
hosts: all
roles:
- role: newrelic.newrelic_install
vars:
targets:
- infrastructure
- logs
- apm-php
tags:
foo: bar
install_timeout_seconds: 1000
verbosity: debug
environment:
NEW_RELIC_API_KEY: <API key>
NEW_RELIC_ACCOUNT_ID: <Account ID>
NEW_RELIC_REGION: <Region>
NEW_RELIC_APPLICATION_NAME: "My Application"
HTTPS_PROXY: "http://my.proxy:8888"
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.