GithubHelp home page GithubHelp logo

s12v / puppet-blackfire Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 17.0 68 KB

Puppet module for Blackfire profiler

Home Page: https://forge.puppetlabs.com/s12v/blackfire

License: Other

Ruby 11.66% Puppet 88.34%
puppet blackfire-php-profiler beaker

puppet-blackfire's Introduction

Build Status Puppet Forge

blackfire

Table of Contents

  1. Description
  2. Setup - The basics of getting started with blackfire
  3. Usage - Configuration options and additional functionality
  4. Reference - An under-the-hood peek at what the module is doing and how
  5. Limitations - OS compatibility, etc.
  6. Development - Guide for contributing to the module

Description

Puppet module for installing, configuring and managing Blackfire PHP profiler.

Setup

What blackfire affects

  • The module adds blackfire repository and overwrites blackfire configuration file.
  • It does not restart any service, you have to do it manually.

Setup requirements

Make sure blackfire is installed after PHP.

Beginning with blackfire

The module includes a single public class blackfire.

Minimal configuration

You need to provide at least server_id and server_token parameters. Also you might want to subscribe your service to be restarted when configuration has changed:

class { 'blackfire':
	server_id    => 'b54114a9-df8a-563b-8ba3-e5457155010e',
	server_token => '7315b1cf617bf51575ba463e813156ed97c85d8ca5c5691db37bbfe36a622a4f',
    notify => Service['php5-fpm']
}

You can get these parameters on https://blackfire.io/account/credentials.

Usage

If you want to provide additional parameters to Agent or PHP extension:

class { 'blackfire':
	server_id    => 'b54114a9-df8a-563b-8ba3-e5457155010e',
	server_token => '7315b1cf617bf51575ba463e813156ed97c85d8ca5c5691db37bbfe36a622a4f',
	agent => {
		log_level => 2
	},
	php => {
		log_level => 3
	}
}

Reference

Classes

Public classes

  • blackfire: Main class

Private classes

  • blackfire::agent: Manages the Agent
  • blackfire::agent::install: Handles the packages.
  • blackfire::agent::config: Handles the configuration file.
  • blackfire::agent::service: Handles the service.
  • blackfire::php: Manages the PHP extension (Probe)
  • blackfire::php::install: Handles the packages.
  • blackfire::php::config: Handles the configuration file.
  • blackfire::repo: Handles the repository.

Parameters

Available parameters for blackfire class

  • agent - Configuration for Blackfire Agent
    • ca_cert - PEM encoded certicates
    • collector - URL of Blackfire's data collector. Default is https://blackfire.io
    • http_proxy - Http proxy to use
    • https_proxy - Https proxy to use
    • log_file - The path of the log file. Use "stderr" to log to stderr. Default is stderr
    • log_level - Log verbosity level (4: debug, 3: info, 2: warning, 1: error). Default is 1
    • manage - Manage Agent. Default is true
    • manage_service - Manage Agent service. Default is true
    • service_ensure - Default is running
    • socket - The socket the agent will listen to. Default is unix:///var/run/blackfire/agent.sock
    • spec - The path to the json specifications file
    • version - Which version of the agent to install. Default is latest
  • manage_repo - Manage Blackfire repository. Default is true
  • php - Configuration for Blackfire PHP extension
    • agent_socket - The agent socket. Default is unix:///var/run/blackfire/agent.sock
    • agent_timeout - The agent timeout. Default 0.25
    • log_file - The path of the log file.
    • log_level - Log verbosity level (4: debug, 3: info, 2: warning, 1: error). Default is 1
    • manage - Manage PHP extension. Default is true
    • version - Which version of the probe to install. Default is latest
    • ini_path - Path of the blackfire.ini file to be generated. If not set, will try find out the path by installed PHP Version. Default is empty
  • server_id - Server ID to use for the agent (See https://blackfire.io/account/credentials)
  • server_token - Server Token to use for the agent (See https://blackfire.io/account/credentials)

Limitations

This module is currently tested on:

  • Ubuntu (16.04, 14.04, 12.04, 10.04)
  • Centos (7.0, 6.6)
  • Debian (8.0, 7.8, 6.0)

It may work on other distros.

Development

Module testing

  • bundle exec rake validate - Check syntax of Ruby files and call :syntax and :metadata / Validate manifests, templates, and ruby files
  • bundle exec rake lint - Check puppet manifests with puppet-lint / Run puppet-lint
  • bundle exec rake spec - Run spec tests in a clean fixtures directory (using spec_helper)

Acceptance testing with beaker

  • bundle exec rake beaker_nodes - List available beaker nodesets
  • BLACKFIRE_SERVER_ID=... BLACKFIRE_SERVER_TOKEN=... bundle exec rake beaker - Run beaker acceptance tests (default nodeset)
  • BEAKER_set=centos-70-x64 BLACKFIRE_SERVER_ID=... BLACKFIRE_SERVER_TOKEN=... bundle exec rake beaker - Run beaker acceptance tests for the nodeset

puppet-blackfire's People

Contributors

flepoutre avatar jtreminio avatar s12v avatar schnitzel avatar yggdrasil avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

puppet-blackfire's Issues

Installation fails on Ubuntu Trusty

The installation of this module fails on Ubuntu Trusty:

Evaluation Error: Error while evaluating a Resource Statement, Could not find declared class apt at /.../blackfire/manifests/repo.pp:8:11 on node ...

Installing puppetlabs-apt fixes this issue. Is there some way to express this conditional dependency in your metadata.json so that the installation works right away? (Using librarian-puppet here.)

Missing blackfire.so and /etc/php.d/zz-blackfire.ini

When I try CentOS 6 and 7, the 2 blackfire RPMs are installed but the module is not copied to /usr/lib64/php/modules/ and /etc/php.d/zz-blackfire.ini file is not being created with the LoadModule statement.

I also get the following errors as the /etc/php.d/zz-blackfire.ini is missing

==> default: Notice: /Stage[main]/Blackfire::Repo/Yumrepo[blackfire]/ensure: created
==> default: Notice: /Stage[main]/Blackfire::Agent::Install/Package[blackfire-agent]/ensure: created
==> default: Notice: /Stage[main]/Blackfire::Agent::Config/Ini_setting[log-level]/value: value changed '1' to '2'
==> default: Notice: /Stage[main]/Blackfire::Agent::Config/Ini_setting[server-id]/value: value changed '' to 'c33d3286-a86b-40a2-9b42-c5411697760f'
==> default: Notice: /Stage[main]/Blackfire::Agent::Config/Ini_setting[server-token]/value: value changed '' to '16322f79ef8900390f53898eedda0e9b302b632044c5c08c0cc4c6c5f9b3faf0'
==> default: Notice: /Stage[main]/Blackfire::Agent::Service/Service[blackfire-agent]/ensure: ensure changed 'stopped' to 'running'
==> default: Notice: /Stage[main]/Blackfire::Agent/Anchor[::blackfire::agent::end]: Triggered 'refresh' from 1 events
==> default: Notice: /Stage[main]/Blackfire::Php/Anchor[::blackfire::php::begin]: Triggered 'refresh' from 1 events
==> default: Notice: /Stage[main]/Blackfire::Php::Install/Package[blackfire-php]/ensure: created
==> default: Error: Could not set 'present' on ensure: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini at 25:/tmp/vagrant-puppet/environments/development/modules/blackfire/manifests/php/config.pp
==> default: Error: Could not set 'present' on ensure: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini at 25:/tmp/vagrant-puppet/environments/development/modules/blackfire/manifests/php/config.pp
==> default: Wrapped exception:
==> default: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini
==> default: Error: /Stage[main]/Blackfire::Php::Config/Ini_setting[blackfire.agent_socket]/ensure: change from absent to present failed: Could not set 'present' on ensure: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini at 25:/tmp/vagrant-puppet/environments/development/modules/blackfire/manifests/php/config.pp
==> default: Error: Could not set 'present' on ensure: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini at 33:/tmp/vagrant-puppet/environments/development/modules/blackfire/manifests/php/config.pp
==> default: Error: Could not set 'present' on ensure: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini at 33:/tmp/vagrant-puppet/environments/development/modules/blackfire/manifests/php/config.pp
==> default: Wrapped exception:
==> default: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini
==> default: Error: /Stage[main]/Blackfire::Php::Config/Ini_setting[blackfire.agent_timeout]/ensure: change from absent to present failed: Could not set 'present' on ensure: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini at 33:/tmp/vagrant-puppet/environments/development/modules/blackfire/manifests/php/config.pp
==> default: Error: Could not set 'present' on ensure: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini at 41:/tmp/vagrant-puppet/environments/development/modules/blackfire/manifests/php/config.pp
==> default: Error: Could not set 'present' on ensure: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini at 41:/tmp/vagrant-puppet/environments/development/modules/blackfire/manifests/php/config.pp
==> default: Wrapped exception:
==> default: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini
==> default: Error: /Stage[main]/Blackfire::Php::Config/Ini_setting[blackfire.server_id]/ensure: change from absent to present failed: Could not set 'present' on ensure: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini at 41:/tmp/vagrant-puppet/environments/development/modules/blackfire/manifests/php/config.pp
==> default: Error: Could not set 'present' on ensure: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini at 49:/tmp/vagrant-puppet/environments/development/modules/blackfire/manifests/php/config.pp
==> default: Error: Could not set 'present' on ensure: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini at 49:/tmp/vagrant-puppet/environments/development/modules/blackfire/manifests/php/config.pp
==> default: Wrapped exception:
==> default: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini
==> default: Error: /Stage[main]/Blackfire::Php::Config/Ini_setting[blackfire.server_token]/ensure: change from absent to present failed: Could not set 'present' on ensure: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini at 49:/tmp/vagrant-puppet/environments/development/modules/blackfire/manifests/php/config.pp
==> default: Error: Could not set 'present' on ensure: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini at 57:/tmp/vagrant-puppet/environments/development/modules/blackfire/manifests/php/config.pp
==> default: Error: Could not set 'present' on ensure: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini at 57:/tmp/vagrant-puppet/environments/development/modules/blackfire/manifests/php/config.pp
==> default: Wrapped exception:
==> default: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini
==> default: Error: /Stage[main]/Blackfire::Php::Config/Ini_setting[blackfire.log_level]/ensure: change from absent to present failed: Could not set 'present' on ensure: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini at 57:/tmp/vagrant-puppet/environments/development/modules/blackfire/manifests/php/config.pp
==> default: Error: Could not set 'present' on ensure: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini at 65:/tmp/vagrant-puppet/environments/development/modules/blackfire/manifests/php/config.pp
==> default: Error: Could not set 'present' on ensure: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini at 65:/tmp/vagrant-puppet/environments/development/modules/blackfire/manifests/php/config.pp
==> default: Wrapped exception:
==> default: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini
==> default: Error: /Stage[main]/Blackfire::Php::Config/Ini_setting[blackfire.log_file]/ensure: change from absent to present failed: Could not set 'present' on ensure: No such file or directory @ rb_sysopen - /etc/php.d/zz-blackfire.ini at 65:/tmp/vagrant-puppet/environments/development/modules/blackfire/manifests/php/config.pp
==> default: Notice: /Stage[main]/Blackfire::Php/Anchor[::blackfire::php::end]: Dependency Ini_setting[blackfire.agent_socket] has failures: true
==> default: Notice: /Stage[main]/Blackfire::Php/Anchor[::blackfire::php::end]: Dependency Ini_setting[blackfire.agent_timeout] has failures: true
==> default: Notice: /Stage[main]/Blackfire::Php/Anchor[::blackfire::php::end]: Dependency Ini_setting[blackfire.server_id] has failures: true
==> default: Notice: /Stage[main]/Blackfire::Php/Anchor[::blackfire::php::end]: Dependency Ini_setting[blackfire.server_token] has failures: true
==> default: Notice: /Stage[main]/Blackfire::Php/Anchor[::blackfire::php::end]: Dependency Ini_setting[blackfire.log_level] has failures: true
==> default: Notice: /Stage[main]/Blackfire::Php/Anchor[::blackfire::php::end]: Dependency Ini_setting[blackfire.log_file] has failures: true
==> default: Warning: /Stage[main]/Blackfire::Php/Anchor[::blackfire::php::end]: Skipping because of failed dependencies
==> default: Notice: /Stage[main]/Blackfire/Anchor[::blackfire::end]: Dependency Ini_setting[blackfire.agent_socket] has failures: true
==> default: Notice: /Stage[main]/Blackfire/Anchor[::blackfire::end]: Dependency Ini_setting[blackfire.agent_timeout] has failures: true
==> default: Notice: /Stage[main]/Blackfire/Anchor[::blackfire::end]: Dependency Ini_setting[blackfire.server_id] has failures: true
==> default: Notice: /Stage[main]/Blackfire/Anchor[::blackfire::end]: Dependency Ini_setting[blackfire.server_token] has failures: true
==> default: Notice: /Stage[main]/Blackfire/Anchor[::blackfire::end]: Dependency Ini_setting[blackfire.log_level] has failures: true
==> default: Notice: /Stage[main]/Blackfire/Anchor[::blackfire::end]: Dependency Ini_setting[blackfire.log_file] has failures: true
==> default: Warning: /Stage[main]/Blackfire/Anchor[::blackfire::end]: Skipping because of failed dependencies

Documentation improvement - requires inifile module

Hi,

I'm getting this error:

Jan  3 10:39:59 foo puppet-agent[XXXXX]: Could not retrieve catalog from remote server: Error 400 on SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type ini_setting at /etc/puppet/environments/dev/modules/blackfire/manifests/agent/config.pp:13 on node foo.codeenigma.net

And a quick look around implies it's because I need this module:
https://forge.puppet.com/puppetlabs/inifile/1.2.0

(See jippi/puppet-php#117)

Would be good if the README stated that dependency, assuming it is a dependency. :-)

Thanks,

Greg

Is this module/repo dead?

Blackfire has updated its package naming and before I try to open a PR for this repo, I'd like to know if it is dead

blackfire.so not loaded

We are using the PHP PPA of Ondřej Surý in our Vagrant/Puppet/Hiera setup and following the advice in #11 we are setting the newly added ini_path accordingly:

blackfire::php:
  ini_path: "/etc/php/5.6/mods-available/blackfire.ini"

This works fine as far as creating /etc/php/5.6/mods-available/blackfire.ini with a few INI settings.

However, the extension=blackfire.so line is missing here. Manually adding that line alone also won't help:

$ php -v
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20131226/blackfire.so' - /usr/lib/php/20131226/blackfire.so: cannot open shared object file: No such file or directory in Unknown on line 0

In this case the correct path would be /usr/lib/blackfire-php/amd64/blackfire-20131226.so. It only works with extension=/usr/lib/blackfire-php/amd64/blackfire-20131226.so which is not really an option since the PHP API version can change.

How can we integrate this properly?

Problem with merge() in blackfire.php

I get a error when running the module:
"Error: merge: unexpected argument type String, only expects hash arguments at /tmp/vagrant-puppet/modules-27c07ec6f70536deab5b55f59f574ecc/blackfire/manifests/php.pp:14 on node dev"

I hade to maketge following patch to make it work:

Index: modules/blackfire/manifests/php.pp
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- modules/blackfire/manifests/php.pp  (revision )
+++ modules/blackfire/manifests/php.pp  (revision )
@@ -11,7 +11,14 @@
     log_level => 1,
     agent_timeout => 0.25,
   }
-  $params = merge($default_params, $::blackfire::params)
+  $blackfire_params = {
+    server_id => $::blackfire::server_id,
+    server_token => $::blackfire::server_token,
+    agent => $::blackfire::agent,
+    php => $::blackfire::php,
+    manage_repo => $::blackfire::manage_repo
+  }
+  $params = merge($default_params, $blackfire_params)
   $log_level = 0 + $params['log_level']

   validate_bool($params['manage'])

i run puppet 3.8.1, puppetlabs-stdlib 4.1.0.
Is it just me?

Including blackfire module fails

Installed Puppet module to master. Included the class in one of my nodes

class { 'blackfire':
  server_id     => 'xxxxxx',
  server_token  => 'xxxxxx',
  agent         => { log_level => 1},
  php           => { log_level => 1 }
  notify        => Service['httpd'],
}

Result during Puppet run:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: merge: unexpected argument type String, only expects hash arguments at opt/puppet_modules/production/forge_modules/current/blackfire/manifests/php.pp:14 on node xxxxxxxx

Any help is appreciated.

Trouble with params (hiera related?)

We're using hiera to manage params, and load blackfire by just including it.

So in params.yml we have
blackfire::server_id: xxx
blackfire::server_token: xxx
blackfire::client_id: xxx
blackfire::client_token: xxx

And in init.pp we include it with
include blackfire

This gives an error on provision:

Error: merge: unexpected argument type String, only expects hash arguments at /blackfire/manifests/php.pp:14

So I'm missing something..

Configuration files on Ubuntu with PHP 7

This won't work on Ubuntu (maybe Debian too) when PHP 7 is installed instead of PHP 5.
The paths changed from /etc/php5/ to something like /etc/php/7.0/.

Could you please provide a way to override the paths manually, so one can easily switch between those versions?

Problem with php 5.6

I'm using this module with PuPHPet and with PHP 5.6. But some time ago PuPHPet switched the PPA on Ubuntu 14.04 from ppa:ondrej/php5-5.6 to ppa:ondrej/php. And after this the path to config directory changed from /etc/php5/ to /etc/php/5.6/. Maybe its possible to check the /etc/php/5.6/ directory first and if it doesn't exists check the /etc/php5/.

Issue on PuPHPet: puphpet/puphpet#2148
And same issue here, but with php 7.0: #6

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.