Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add support for Composer, Vagrant and Puppet #3314

Closed
tsteur opened this Issue · 56 comments

4 participants

@tsteur
Owner

DONE! :-) See: Get started with Piwik development Piwik Puppet Module + Vagrant

We should support Composer ( http://getcomposer.org ) and add our repository to http://packagist.org/

We should also add a Vagrant/Puppet configuration. All files should be located under "misc/deploy".

I'd suggest to start with a Lucid64 base box ( http://files.vagrantup.com/lucid64.box ) and add different boxes later. Network Interface should be "Bridged"?

Required configurations/pacakges in Puppet:

  • PHP + all required extensions like GD, MySQL, Subversion, Git, Apache or Nignx, Composer, Vim :)
  • The Piwik project itself

Related Puppet links:

Tasks:

  • Nginx + PHP-FPM + Host nginx.piwik:8080
  • Apache2 + Mod PHP + Host apache.piwik
  • PHP Modules required by Piwik
  • PHPUnit (and other Tools like PHP_PMD, PHP_Depend, PHP_CodeCoverage, PHP_CodeSniffer, phpDox)
  • Git
  • Subversion
  • MySQL / PDO
  • Percona Tools
  • Vim
  • python-setuptools python-dev build-essential
  • Composer
  • ~~easy_install ~~
  • simplejson (via easy_install)
  • Once everything is done: Create a puppet-piwik module
  • Allow creation of multiple DB users
  • Blog post
  • FAQ, see ticket #3319
  • Create a repo "puppet-piwik" on Github and move source to this repository
  • Create a repo "piwik-dev-environment" on Github which contains all required Vagrant/Puppet files. Including all required Puppet modules (via Git submodule)
  • Composer detects only trunk / Jenkins does not sync our tags to Github
@tsteur
Owner

(In [6722]) refs #3314 added composer.json

@robocoder
Collaborator

I've published piwik/piwik to packagist. (Matt: see email for packagist credentials.) At minimum, we're reserving our namespace. Do you see using composer.json for Piwik's dependencies (currently in libs), or Piwik as a dependency (when included in another project)?

Contrary to http://getcomposer.org/doc/02-libraries.md#tags, it doesn't look like Packagist recognizes our tag (without the 'v' prefix). I've created an issue here: composer/packagist#191

I'm a puppet n00b, but I want to help with a Precise64 box. I was planning on using a "Host-only" network interface, assuming the VM was for dev/test. "Bridged" makes sense if we want to provide users with a config that they can use to spin up a VM and test drive Piwik.

@tsteur
Owner

I created a Packagist account too :) Then I saw it's already added :) I'll delete my account again.

I'm not sure whether we should include other libs like Zend via composer. I see it more as a dependency. If we include Zend and other libs via composer, other developers would have to use composer too when checking out the repository. This would require PHP 5.3.

OK, I'll start with an Ubuntu base box and add a few packages to Puppet. It's easy to add a Precise64 box afterwards.

@tsteur
Owner

(In [6723]) refs #3314 added lucid64 vagrant base box

@tsteur
Owner

(In [6729]) refs #3314 a very first puppet configuration for Piwik. I will add the required modules later

@tsteur
Owner

(In [6730]) refs #3314 added precise64 base box

@tsteur
Owner

A list of available base boxes can be found here:

http://www.vagrantbox.es/

@tsteur
Owner

(In [6731]) refs #3314 change file permissions of config directory after checkout

@tsteur
Owner

(In [6732]) refs #3314 change file permissions of tmp directory after checkout

@tsteur
Owner

(In [6735]) refs #3314 configured nginx, piwik is running now but mysqli is still missing

@tsteur
Owner

(In [6736]) refs #3314 fix php, mysql naming conflict

@JulienMoumne
Collaborator

I have logged the task of writing a FAQ entry about this superb initiative in #3319

@tsteur
Owner

(In [6759]) refs #3314 nginx.piwik:8080 is now fully working with nginx and php-fpm. piwik installation works

@tsteur
Owner

(In [6760]) refs #3314 added required packages for testing log analytics

@tsteur
Owner

(In [6765]) refs #3314 include PHPUnit and lots of php qa tools

@tsteur
Owner

(In [6766]) refs #3314 apach2 is up and running as well. both use the same piwik directoy. apache.piwik listens on port 80

@tsteur
Owner

(In [6775]) refs #3314 removing the lucid64 vagrant configuration for the first

@tsteur
Owner

(In [6777]) refs #3314 removed deprecated files

@tsteur
Owner

(In [6778]) refs #3314 create user after repo checkout. the directory does not exist before

@tsteur
Owner

(In [6779]) refs #3314 install simplejson via pip and install those packages only if they are not already installed

@tsteur
Owner

(In [6780]) refs #3314 do not notify fpm, the fpm service is not created at this moment

@tsteur
Owner

(In [6795]) refs #3314 added some requires to make sure the packages will be installed in the correct order. It still needs further improvements

@tsteur
Owner

(In [6796]) refs #3314 added percona toolkit package

@tsteur
Owner

(In [6797]) refs #3314 added composer. usage: "php composer.phar ..."

@tsteur
Owner

(In [6798]) refs #3314 added simple test

@tsteur
Owner

(In [6809]) refs #3314 install composer only once and make it globally available

@tsteur
Owner

(In [6810]) refs #3314 removed users dependency

@tsteur
Owner

(In [6816]) refs #3314 adding a precise 32bit base box

@tsteur
Owner

(In [6817]) refs #3314 change owner of piwik directory

@tsteur
Owner

(In [6823]) refs #3314 added a class to create the user

@tsteur
Owner

(In [6825]) refs #3314 more docs

@tsteur
Owner

(In [6831]) refs #3314 moved user definition, this allows us to host several different Piwik versions

@tsteur
Owner

(In [6832]) refs #3314 added todo note

@tsteur
Owner

Are there any command line tools (bash, php, ...) to install/configure Piwik? To add users and websites and so on?

Would be great to have the possibility to configure Piwik totally with Puppet in a future release. Especially for a production environment.

Example could be:

 piwik:install{ path => '...' }
 piwik:website {name =>'myexample1', url => 'example.org/1',  timezone => '', 'use_ecommerce' => true}
 piwik:website {name =>'myexample2', url => 'example.org/2',  timezone => '', 'use_ecommerce' => false}
 piwik:user {name => 'username1', websites => 'myexample1', access => 'view'}
 piwik:user {name => 'username2', websites => 'myexample2', access => 'view'}
@mattab
Owner

It is the ticket: #1586 Headless install / command line piwik remote install.

Definitely would be nice to have and have as a scriptable piwik setup for several use cases!

@tsteur
Owner

(In [6833]) refs #3314 better description of the requirements

@tsteur
Owner

The piwik-puppet module is now available here:

https://github.com/piwik/puppet-piwik

Once I've created the "piwik-dev-environment" I'll delete the files in svn (misc/deploy)

@tsteur
Owner

The piwik-dev-environment is now available here:

https://github.com/piwik/piwik-dev-environment

Contains all available vagrant boxes, the Puppet configuration as well as all required modules

@tsteur
Owner

(In [6835]) refs #3314 removing the configuration from SVN repository. Those files are now on Github

@tsteur
Owner

Can someone follow the instructions from https://github.com/piwik/piwik-dev-environment and try it? Anthon?

@robocoder
Collaborator

Sure. I'll give it a spin later tonight.

@robocoder
Collaborator

Awesome work, Thomas!

Installing the pear modules took much longer than I expected. (Total runtime for vagrant > 50 minutes.)

As an alternative to modifying one's /etc/hosts file, maybe we could set up a couple of DNS A records both pointing to 192.168.33.10. (Maybe Matt could use one of the alternate piwik domains?)

Do the puppet scripts set up a MySQL user with sufficient privileges? (site.pp doesn't contain working credentials) I manually created a piwik user. (BTW I noticed something odd in the mysql.user table, e.g., SELECT COUNT(User) from mysql.user where User = ''; returns 2 records.)

The www-data user's home directory is /var/www, it defaults to: AllowOverride FileInfo AuthConfig Limit Indexes. We should remove "Indexes" from the config (to reflect best practices).

@mattab
Owner

As an alternative to modifying one's /etc/hosts file, maybe we could set up a couple of DNS A records both pointing to 192.168.33.10. (Maybe Matt could use one of the alternate piwik domains?)

It would be nice not to have to edit hosts file indeed. Could we use a subdomain such as virtual.piwik.org ?

@tsteur
Owner

Thanks for testing, Anthon!

Yes, that's right. Without Pear modules it takes about 10 minutes, with Pear modules it takes about 20-30 minutes on my machine. Shall I remove some probably not needed QA Tools? It currently installs the following packages: https://github.com/rafaelfelix/puppet-phpqatools/blob/master/manifests/init.pp among a few others.

Great idea regarding set up a couple of DNS A records! Let me know the domains and I'll changed it.

Database user should work now. But only from localhost. I've updated dev-environment as well as puppet module. The created user was "piwik@%". That means it is possible to access the machine from any host. But "piwik@%" works only if there's also at least one "piwik@localhost" entry. This was not the case... I'll refactor the module to allow the creation of multiple DB users. For example "piwik@localhost" as well as "piwik@%", "piwik@192.168.1.2", ...
The "grants" are currently set to "all", see https://github.com/piwik/puppet-piwik/blob/master/manifests/db.pp#L45 . Shall I change it?

The www-data user's home directory should be "/var/www/piwik". I'll have a look into this. Do we need UserDir Module at all? Guess I have to overwrite the file.

@tsteur
Owner

It's now possible to define multiple initial database users within site.pp this way:

db_user => ['piwik@localhost' , 'piwik@192.168.0.0/255.255.0.0']

But I don't think we need the ability to connect from any host, do we? Some tools like "Navicat" are able to establish a connection via ssh. I think the actual problem is that MySQL doesn't listen to the external IP at the moment.

@robocoder
Collaborator

I think we can leave the home dir as /var/www, and UserDir module as is. The closer we have it to the default, the more familiar it'll be to others, and at the same time, not further prolong the startup time.

I agree localhost access to the MySQL server is sufficient.

I'm going to take a look at the pear puppet module. It shouldn't be that slow.

@tsteur
Owner

The home dir is now /var/www again (default directory).

@tsteur
Owner

FYI: Added possibility to define local vagrant settings, see step 3 https://github.com/piwik/piwik-dev-environment#installation

There's a gitignore on "vagrantconfig_local.yaml". So, any changes will be ignored (not commited). It is now possible for example to set your svn username/password there. See https://github.com/piwik/piwik-dev-environment/blob/master/vagrantconfig.yaml

Let me know if we need more settings. For example mount points (shared folders) and so on.

@JulienMoumne
Collaborator

I have successfully configured my IDE to sync Piwik source files via SFTP.

I had to perform several user rights adjustments so the Vagrant user had the rights to update Piwik source files :

  • add Vagrant user to the www-data group
  • perform a chmod g+w on all Piwik files

I was wondering if I was correct in using the Vagrant user in that case or if there was a better way.

The main idea is to be able to set-up a complete development environment using Vagrant.

@tsteur
Owner

Thanks Julien. Puppet will do this now for you when creating a new Piwik VM :)
I changed the owner of Piwik files to "vagrant:www-data" and added "vagrant" to group "www-data".

See piwik/piwik-dev-environment@6fbc2ee

That's my main idea too ;)

@JulienMoumne
Collaborator

Because I am no sysadmin expert, I do not know the best practices to resolve the issue.

The commands I gave was to illustrate the issue and how I resolved it, but it may be 'quick and dirty'.

There are maybe several other ways to solve this issue such as :

  • adding a non-sudoer piwik user (to contrast with vagrant which is a sudoer)
  • using www-data instead of Vagrant?
@JulienMoumne
Collaborator

As a side note, when running phpunit tests, one needs to configure the [database_tests] config section to set

password = secure

It is possible to edit config.ini.php via SSH but it would be nice if it was possible to do so using the IDE.

The way permissions are currently set-up it is not possible with the vagrant user because of the rights associated to config.ini.php :

-rw-r--r-- 1 www-data www-data 1756 Sep  2 19:06 /var/www/piwik/config/config.ini.php

Another related issue is happening when running PHPUnit integration tests within the virtual machine.

The following error occurs :


SmartyException: unable to write to $compile_dir '/var/www/piwik/tmp/templates_c'. Be sure $compile_dir is writable by the web server user.

Because '/var/www/piwik/tmp/templates_c' is not writable by the Vagrant user :

drwxr-xr-x  2 www-data www-data 4096 Sep  2 19:06 templates_c/
@tsteur
Owner

Thanks for this feedback!

I created a new VM and verified config.ini.php is editable now with vagrant user because the files do now belong to the "vagrant" user. I changed this yesterday.

Using the "vagrant" user is ok and not "quick and dirty" I think.

@tsteur
Owner

Packagist recognizes our tag now. Version 1.8.3 is available. I've tried it and it works! Thanks for syncing our tags!

@mattab
Owner

Nice team work... Love the look of this Tasks list now ;-)

@mattab
Owner

DONE! :-) See: Get started with Piwik development Piwik Puppet Module + Vagrant

well done Thomas! this will be useful for the build server/jenkins :)

@tsteur tsteur added this to the 1.9.2 - Piwik 1.9.2 milestone
@tsteur tsteur self-assigned this
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.