Skip to content

Instantly share code, notes, and snippets.

@jlis
Created August 25, 2021 11:06
Show Gist options
  • Save jlis/31c075cab09564369e018e87f6b0bab3 to your computer and use it in GitHub Desktop.
Save jlis/31c075cab09564369e018e87f6b0bab3 to your computer and use it in GitHub Desktop.
Install New Relic PHP Agent via Chef recipe
#
# Cookbook Name:: <INSERT COOKBOOK NAME>
# Recipe:: new_relic_agent
#
# Add apt repo
apt_repository 'newrelic' do
uri 'http://apt.newrelic.com/debian'
key 'https://download.newrelic.com/548C16BF.gpg'
components ['non-free']
distribution 'newrelic'
end
# Preseed application name
execute "preseed application name" do
command "echo 'newrelic-php5 newrelic-php5/application-name <INSERT APPLICATION NAME>' | debconf-set-selections"
action :run
end
# Preseed liense key
execute "preseed license key" do
command "echo 'newrelic-php5 newrelic-php5/license-key string #{node[:custom][:newrelic][:license_key]}' | debconf-set-selections"
action :run
end
# Install the apt package
package 'newrelic-php5'
# Start if not existent + reload php5-fpm
service "php#{node[:custom][:php][:version]}-fpm" do
only_if { ::File.exists?("/etc/init.d/php#{node[:custom][:php][:version]}-fpm") }
ignore_failure true
action [:start, :reload]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment