Skip to content

Commit

Permalink
Moved new relic java installation to a separate task as this role is …
Browse files Browse the repository at this point in the history
…going to support more new relic agents
  • Loading branch information
Lars Blumberg committed Feb 13, 2015
1 parent f277a74 commit 051c8c2
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 88 deletions.
48 changes: 16 additions & 32 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,21 @@
---
# defaults file for yetu.newrelic-jvm
# defaults file for ansible-newrelic-agent

# New relic installation settings
newrelic_license_key : False
newrelic_jar_version : "3.13.0"
newrelic_jar_app_name : "Witwe Bolte"
newrelic_jar_dir : "/tmp/newrelic"
newrelic_jar_user : root
newrelic_jar_group : root
newrelic_app_name : "Witwe Bolte"
newrelic_license_key : False
newrelic_java_install_agent : False
newrelic_nodejs_install_agent : False

# New relic run configuration
newrelic_jar_high_security : false
newrelic_jar_enable_auto_app_naming : false
newrelic_jar_enable_auto_transaction_naming : true
newrelic_jar_log_level : info
newrelic_jar_audit_mode : false
newrelic_jar_log_file_count : 1
newrelic_jar_log_limit_in_kbytes : 0
newrelic_jar_log_daily : false
newrelic_jar_log_file_name : newrelic_agent.log
newrelic_jar_ssl : true
newrelic_jar_max_stack_trace_lines : 30

#TODO: Provide these attributes here
#newrelic_jar_attributes :
# enabled: yes
# auto_instrument: true
#newrelic_transaction_tracer_*

newrelic_jar_base_url : "http://download.newrelic.com/newrelic/java-agent/newrelic-agent"
newrelic_jar_filename : "newrelic-agent-{{ newrelic_jar_version }}.jar"
newrelic_jar_url : "{{ newrelic_jar_base_url }}/{{ newrelic_jar_version }}/{{ newrelic_jar_filename }}"
newrelic_jar_config_file : "{{ newrelic_jar_dir }}/newrelic.yml"

#TODO: This line is to be removed as soon as we have accomplished the base role
#/home/apphome/workspace/home-services/bin/home-services -Dhttp.port=8085 -Dconfig.file=/home/apphome/workspace/home-services/conf/application-dev.conf -J-javaagent:/tmp/newrelic/newrelic-agent-3.13.0.jar -J-Dnewrelic.environment=dev
newrelic_high_security : false
newrelic_enable_auto_app_naming : false
newrelic_enable_auto_transaction_naming : true
newrelic_log_level : info
newrelic_audit_mode : false
newrelic_log_file_count : 1
newrelic_log_limit_in_kbytes : 0
newrelic_log_daily : false
newrelic_log_file_name : newrelic_agent.log
newrelic_ssl : true
newrelic_max_stack_trace_lines : 30
14 changes: 14 additions & 0 deletions defaults/newrelic_java.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
# defaults file for ansible-newrelic-agent

# Newrelic java installation settings
newrelic_java_version : "3.13.0"
newrelic_java_dir : "/tmp/newrelic"
newrelic_java_user : root
newrelic_java_group : root

# Dynamic installation properties, don't need to be overwritten
newrelic_java_base_url : "http://download.newrelic.com/newrelic/java-agent/newrelic-agent"
newrelic_java_filename : "newrelic-agent-{{ newrelic_java_version }}.jar"
newrelic_java_url : "{{ newrelic_java_base_url }}/{{ newrelic_java_version }}/{{ newrelic_java_filename }}"
newrelic_java_config_file : "{{ newrelic_java_dir }}/newrelic.yml"
2 changes: 1 addition & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
# handlers file for yetu.newrelic-jvm
# handlers file for ansible-newrelic-agent
42 changes: 3 additions & 39 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,5 @@
---
- name: Check for newrelic_license_key
fail:
msg: "newrelic_license_key has not been defined"
when: newrelic_license_key|default(False) == False

- name: main | Debug
debug:
var=newrelic_jar_url

- name: main | Create newrelic-jar target directory
file:
path="{{ newrelic_jar_dir }}"
state=directory
owner="{{ newrelic_jar_user }}"
group="{{ newrelic_jar_group }}"
mode=0755

- name: main | Download newrelic.jar
get_url:
url="{{ newrelic_jar_url }}"
dest="{{ newrelic_jar_dir }}"
owner="{{ newrelic_jar_user }}"
group="{{ newrelic_jar_group }}"
mode=0644

- name: main | Create version-less symbolic link for newrelic.jar file
file:
src="{{ newrelic_jar_dir }}/{{ newrelic_jar_filename }}"
dest="{{ newrelic_jar_dir }}/newrelic-agent.jar"
owner="{{ newrelic_jar_user }}"
group="{{ newrelic_jar_group }}"
state=link

- name: main | Configure new relic
template:
src=newrelic.yml.j2
dest="{{ newrelic_jar_config_file }}"
owner="{{ newrelic_jar_user }}"
group="{{ newrelic_jar_group }}"
mode=0644
- name: main | Execute newrelic java role
include: "newrelic_java.yml"
when: newrelic_java_install_agent|default(False) == True
44 changes: 44 additions & 0 deletions tasks/newrelic_java.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---

- include_vars: ../defaults/newrelic_java.yml

- name: Check for newrelic_license_key
fail:
msg: "newrelic_license_key has not been defined"
when: newrelic_license_key|default(False) == False

- name: main | Debug
debug:
var=newrelic_java_url

- name: main | Create newrelic-jar target directory
file:
path="{{ newrelic_java_dir }}"
state=directory
owner="{{ newrelic_java_user }}"
group="{{ newrelic_java_group }}"
mode=0755

- name: main | Download newrelic.jar
get_url:
url="{{ newrelic_java_url }}"
dest="{{ newrelic_java_dir }}"
owner="{{ newrelic_java_user }}"
group="{{ newrelic_java_group }}"
mode=0644

- name: main | Create version-less symbolic link for newrelic.jar file
file:
src="{{ newrelic_java_dir }}/{{ newrelic_java_filename }}"
dest="{{ newrelic_java_dir }}/newrelic-agent.jar"
owner="{{ newrelic_java_user }}"
group="{{ newrelic_java_group }}"
state=link

- name: main | Configure new relic
template:
src=newrelic_java.yml.j2
dest="{{ newrelic_java_config_file }}"
owner="{{ newrelic_java_user }}"
group="{{ newrelic_java_group }}"
mode=0644
32 changes: 16 additions & 16 deletions templates/newrelic.yml.j2 → templates/newrelic_java.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -27,55 +27,55 @@ common: &default_settings
# For example, to report data to "My Application" and "My Application 2" use this:
# app_name: My Application;My Application 2
# This setting is required.
app_name: {{ newrelic_jar_app_name }}
app_name: {{ newrelic_app_name }}

# To enable high security, set this property to true. When in high
# security mode, the agent will use SSL and obfuscated SQL. Additionally,
# request parameters and message parameters will not be sent to New Relic.
high_security: {{ newrelic_jar_high_security }}
high_security: {{ newrelic_high_security }}

# Set to true to enable support for auto app naming.
# The name of each web app is detected automatically
# and the agent reports data separately for each one.
# This provides a finer-grained performance breakdown for
# web apps in New Relic.
# Default is false.
enable_auto_app_naming: {{ newrelic_jar_enable_auto_app_naming }}
enable_auto_app_naming: {{ newrelic_enable_auto_app_naming }}

# Set to true to enable component-based transaction naming.
# Set to false to use the URI of a web request as the name of the transaction.
# Default is true.
enable_auto_transaction_naming: {{ newrelic_jar_enable_auto_transaction_naming }}
enable_auto_transaction_naming: {{ newrelic_enable_auto_transaction_naming }}

# The agent uses its own log file to keep its logging
# separate from that of your application. Specify the log level here.
# This setting is dynamic, so changes do not require restarting your application.
# The levels in increasing order of verboseness are:
# off, severe, warning, info, fine, finer, finest
# Default is info.
log_level: {{ newrelic_jar_log_level }}
log_level: {{ newrelic_log_level }}

# Log all data sent to and from New Relic in plain text.
# This setting is dynamic, so changes do not require restarting your application.
# Default is false.
audit_mode: {{ newrelic_jar_audit_mode }}
audit_mode: {{ newrelic_audit_mode }}

# The number of backup log files to save.
# Default is 1.
log_file_count: {{ newrelic_jar_log_file_count }}
log_file_count: {{ newrelic_log_file_count }}

# The maximum number of kbytes to write to any one log file.
# The log_file_count must be set greater than 1.
# Default is 0 (no limit).
log_limit_in_kbytes: {{ newrelic_jar_log_limit_in_kbytes }}
log_limit_in_kbytes: {{ newrelic_log_limit_in_kbytes }}

# Override other log rolling configuration and roll the logs daily.
# Default is false.
log_daily: {{ newrelic_jar_log_daily }}
log_daily: {{ newrelic_log_daily }}

# The name of the log file.
# Default is newrelic_agent.log.
log_file_name: {{ newrelic_jar_log_file_name }}
log_file_name: {{ newrelic_log_file_name }}

# The log file directory.
# Default is the logs directory in the newrelic.jar parent directory.
Expand All @@ -88,7 +88,7 @@ common: &default_settings
# application code, so response times will not be directly affected
# by this change.
# Default is true.
ssl: {{ newrelic_jar_ssl }}
ssl: {{ newrelic_ssl }}

# Proxy settings for connecting to the New Relic server:
# If a proxy is used, the host setting is required. Other settings
Expand All @@ -102,7 +102,7 @@ common: &default_settings

# Limits the number of lines to capture for each stack trace.
# Default is 30
max_stack_trace_lines: {{ newrelic_jar_max_stack_trace_lines }}
max_stack_trace_lines: {{ newrelic_max_stack_trace_lines }}

# Provides the ability to configure the attributes sent to New Relic. These
# attributes can be found in transaction traces, traced errors, Insight's
Expand Down Expand Up @@ -262,16 +262,16 @@ common: &default_settings

dev:
<<: *default_settings
app_name: {{ newrelic_jar_app_name }} (Development)
app_name: {{ newrelic_app_name }} (Development)

test:
<<: *default_settings
app_name: {{ newrelic_jar_app_name }} (Test)
app_name: {{ newrelic_app_name }} (Test)

prod:
<<: *default_settings
app_name: {{ newrelic_jar_app_name }} (Production)
app_name: {{ newrelic_app_name }} (Production)

staging:
<<: *default_settings
app_name: {{ newrelic_jar_app_name }} (Staging)
app_name: {{ newrelic_app_name }} (Staging)

0 comments on commit 051c8c2

Please sign in to comment.