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

support for blackfire.io #211

Merged
merged 3 commits into from Jun 4, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Phansible/Application.php
Expand Up @@ -79,6 +79,7 @@ protected function initRoles()
$this['roles']->register(new Roles\Php($this));
$this['roles']->register(new Roles\Xdebug($this));
$this['roles']->register(new Roles\Composer($this));
$this['roles']->register(new Roles\Blackfire($this));
}

/**
Expand Down
@@ -0,0 +1,3 @@
---
- name: restart blackfire-agent
service: name=blackfire-agent enabled=yes state=restarted
23 changes: 23 additions & 0 deletions src/Phansible/Resources/ansible/roles/blackfire/tasks/main.yml
@@ -0,0 +1,23 @@
---
- name: Add Blackfire GPG key
apt_key: url=https://packagecloud.io/gpg.key state=present

- name: add Blackfire repo
apt_repository: repo='deb http://packages.blackfire.io/debian any main' state=present update_cache=yes

- name: Install Blackfire Agent
apt: pkg=blackfire-agent state=latest

- name: Set server ID
lineinfile: dest=/etc/blackfire/agent
regexp='server-id='
line='server-id={{ blackfire.server_id }}'

- name: Set server token
lineinfile: dest=/etc/blackfire/agent
regexp='server-token='
line='server-token={{ blackfire.server_token }}'
notify: restart blackfire-agent

- name: Install Blackfire PHP Probe
apt: pkg=blackfire-php state=latest
16 changes: 16 additions & 0 deletions src/Phansible/Resources/views/bundles/languages/php.html.twig
Expand Up @@ -50,5 +50,21 @@
{% endfor %}
</select>
</div>
<div class="field">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a link to https://blackfire.io/account/credentials or something? I think it would be handful

<label for="blackfire[install]">BlackFire:</label>
<div class="field inline">
<div class="ui checkbox">
<input type="checkbox" name="blackfire[install]" value="1" {% if blackfire.install %}checked="checked"{% endif %} /><label>Install BlackFire</label>
</div>
</div>
<div class="field">
<label for="blackfire[server_id]">Blackfire Server ID:</label>
<input type="text" id="blackfire_server_id" name="blackfire[server_id]" value="{{ blackfire.server_id }}" />
</div>
<div class="field">
<label for="blackfire[server_token]">Blackfire Server Token:</label>
<input type="text" id="blackfire_server_token" name="blackfire[server_token]" value="{{ blackfire.server_token }}" />
</div>
</div>
</div>
</div>
36 changes: 36 additions & 0 deletions src/Phansible/Roles/Blackfire.php
@@ -0,0 +1,36 @@
<?php

namespace Phansible\Roles;

use Phansible\BaseRole;

class Blackfire extends BaseRole
{
protected $name = 'BlackFire';
protected $slug = 'blackfire';
protected $role = 'blackfire';

public function getInitialValues()
{
return [
'install' => 0,
'server_id' => '',
'server_token' => '',
];
}

protected function installRole($requestVars)
{
return parent::installRole($requestVars) && $this->blackfireWillBeInstalled($requestVars);
}

private function blackfireWillBeInstalled($requestVars)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to do this since this is already done in installRole in the BaseRole

{
$config = $requestVars['blackfire'];

if (!is_array($config) || !array_key_exists('install', $config) || $config['install'] == 0) {
return false;
}
return true;
}
}