Skip to content

Instantly share code, notes, and snippets.

@xlbruce
Created August 9, 2021 16:59
Show Gist options
  • Save xlbruce/8728c3fd852d58f785f30895896bb96d to your computer and use it in GitHub Desktop.
Save xlbruce/8728c3fd852d58f785f30895896bb96d to your computer and use it in GitHub Desktop.
Install NewRelic Infrastructure "manually"
---
- name: Install NewRelic Infrastructure agent
hosts: newrelic_infra
become: yes
gather_facts: no
vars:
agent_url: "{{ package_url | default('https://download.newrelic.com/infrastructure_agent/binaries/linux/amd64/newrelic-infra_linux_1.19.4_amd64.tar.gz') }}"
package_path: /tmp/newrelic-infra.tar.gz
agent_path: /opt
newrelic_license_key: "{{ vault_newrelic_license_key }}"
tasks:
- name: Create agent directory
ansible.builtin.file:
name: "{{ agent_path }}"
state: directory
- name: Download agent package
get_url:
url: "{{ agent_url }}"
dest: "{{ package_path }}"
mode: '0600'
- name: Extract package
ansible.builtin.unarchive:
src: "{{ package_path }}"
dest: /tmp
remote_src: yes
- name: Setup license key
ansible.builtin.lineinfile:
path: "/tmp/newrelic-infra/config_defaults.sh"
regexp: '^#license_key=""'
state: present
value: "license_key={{ newrelic_license_key }}"
- name: Run installer.sh
ansible.builtin.shell: "./installer.sh"
args:
chdir: /tmp/newrelic-infra
- name: Delete package files
ansible.builtin.file:
name: "{{ item }}"
state: absent
loop:
- /tmp/newrelic-infra
- "{{ package_path }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment