Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHP Warning: Module 'newrelic' already loaded in Unknown on line 0 (Debian) #16

Merged
merged 2 commits into from
Feb 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 14 additions & 19 deletions manifests/agent/php.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@
# Main Configuration directory used for PHP.
# Default: OS dependant - see params.pp (String)
#
# [*purge_files*]
# Any files which should be purged following the installation. This is only
# necessary as the NewRelic installer adds files to every possible location,
# resulting in duplicate configuration.
# Default: OS dependant - see params.pp (Array)
#
# [*package_name*]
# Name of the package to install
# Default: OS dependant - see params.pp (String)
Expand Down Expand Up @@ -48,6 +42,10 @@
# Sockets in RedHat 7. Can be overridden using the daemon_settings parameter.
# Default: OS dependant - see params.pp (Hash)
#
# [*run_installer*]
# Whether to run the newrelic installer.
# Default: OS dependant - see params.pp (Boolean)
#
# [*exec_path*]
# $PATH environment variable to pass to exec resources within this class,
# most noteably the NewRelic installer script. You may wish to override this
Expand Down Expand Up @@ -105,12 +103,12 @@
String $license_key,
Boolean $manage_repo = $::newrelic::params::manage_repo,
String $conf_dir = $::newrelic::params::php_conf_dir,
Array $purge_files = $::newrelic::params::php_purge_files,
String $package_name = $::newrelic::params::php_package_name,
String $daemon_service_name = $::newrelic::params::php_service_name,
Array $extra_packages = $::newrelic::params::php_extra_packages,
Hash $default_ini_settings = $::newrelic::params::php_default_ini_settings,
Hash $default_daemon_settings = $::newrelic::params::php_default_daemon_settings,
Boolean $run_installer = $::newrelic::params::run_installer,
String $exec_path = $facts['path'],
String $package_ensure = 'present',
Enum['agent','external'] $startup_mode = 'agent',
Expand Down Expand Up @@ -146,13 +144,15 @@

# == Initial Installation

exec { 'newrelic install':
command => "/usr/bin/newrelic-install purge; NR_INSTALL_SILENT=yes, NR_INSTALL_KEY=${license_key} /usr/bin/newrelic-install install",
path => $exec_path,
user => 'root',
unless => "/bin/grep -q ${license_key} ${conf_dir}/newrelic.ini",
notify => Exec['newrelic_kill'],
require => Package[$package_name],
if ($run_installer) {
exec { 'newrelic install':
command => "/usr/bin/newrelic-install purge; NR_INSTALL_SILENT=yes, NR_INSTALL_KEY=${license_key} /usr/bin/newrelic-install install",
path => $exec_path,
user => 'root',
unless => "/bin/grep -q ${license_key} ${conf_dir}/newrelic.ini",
notify => Exec['newrelic_kill'],
require => Package[$package_name],
}
}

exec { 'newrelic_kill':
Expand All @@ -164,11 +164,6 @@

# == Configuration

file { $purge_files:
ensure => absent,
require => Exec['newrelic install']
}

$all_ini_settings = deep_merge($default_ini_settings,$ini_settings)

file { "${conf_dir}/newrelic.ini":
Expand Down
5 changes: 2 additions & 3 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
$php_package_name = 'newrelic-php5'
$php_service_name = 'newrelic-daemon'
$php_conf_dir = '/etc/php.d'
$php_purge_files = []
$php_extra_packages = ['php-cli']
$run_installer = true

if $facts['os']['release']['major'] == '7' {
# Abstract socket
Expand All @@ -53,13 +53,12 @@
$php_default_ini_settings = {}
$php_default_daemon_settings = {}
$php_extra_packages = []
$run_installer = false

if $facts['os']['release']['full'] == '16.04' {
$php_conf_dir = '/etc/php/7.0/mods-available'
$php_purge_files = ['/etc/php/7.0/apache2/conf.d/newrelic.ini','/etc/php/7.0/fpm/conf.d/newrelic.ini']
} else {
$php_conf_dir = '/etc/php5/mods-available'
$php_purge_files = ['/etc/php5/apache2/conf.d/newrelic.ini','/etc/php5/fpm/conf.d/newrelic.ini']
}
}

Expand Down