Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ] } # set the time zone to PDT exec {'set time': command => 'echo "America/Los_Angeles" > /etc/timezone; dpkg-reconfigure --frontend noninteractive tzdata', unless => 'grep "Los_Angeles" /etc/timezone', } file {'/vagrant/perforce': ensure => directory, } # # Setup Perforce # exec {'fetch p4': command => 'wget -O /vagrant/perforce/p4 ftp://ftp.perforce.com/perforce/r13.2/bin.linux26x86_64/p4', creates => '/vagrant/perforce/p4', require => File['/vagrant/perforce'], } exec {'fetch p4d': command => 'wget -O /vagrant/perforce/p4d ftp://ftp.perforce.com/perforce/r13.2/bin.linux26x86_64/p4d', creates => '/vagrant/perforce/p4d', require => File['/vagrant/perforce'], } file {'p4': path => '/vagrant/perforce/p4', mode => 0775, require => Exec['fetch p4'], } file {'p4d': path => '/vagrant/perforce/p4d', mode => 0775, require => Exec['fetch p4d'], } file {'/usr/local/bin/p4': source => '/vagrant/perforce/p4', mode => 0555, require => File['p4'], } exec {'start p4d': command => '/vagrant/perforce/p4d -d -p 1666 -r /vagrant/perforce', unless => "/vagrant/perforce/p4 -p 1666 info", require => [ File['p4d'], File['p4'] ] } exec {'fetch sample depot': command => 'wget -O /vagrant/perforce/sampledepot.tar.gz http://ftp.perforce.com/perforce/tools/sampledepot.tar.gz', creates => '/vagrant/perforce/sampledepot.tar.gz', } exec {'deploy sample depot': command => 'tar xfz /vagrant/perforce/sampledepot.tar.gz -C /tmp; rm -rf /vagrant/perforce/db.*; cp -Rf /tmp/PerforceSample/* /vagrant/perforce; /vagrant/perforce/p4d -r /vagrant/perforce -jr /vagrant/perforce/checkpoint; /vagrant/perforce/p4 -p 1666 -u bruno passwd -P fooBARbaz', require => [ Exec['fetch sample depot'], Exec['start p4d'] ], unless => "find /vagrant/perforce -name jam | grep jam", } # setup a startup script for p4d file {'/etc/init/perforce-server.conf': source => '/vagrant/manifests/files/perforce-server.conf', ensure => 'present', owner => root, group => root, mode => 644, require => [ File['p4d'], File['p4'] ] } # # Setup Swarm # class { 'apache': mpm_module => 'prefork', default_vhost => false, } include apache::mod::php apache::mod { 'rewrite': } exec { "apt-get update": path => "/usr/bin", } package { "apt-show-versions": ensure => present, require => Exec["apt-get update"], } package { "php-pear": ensure => present, require => [ Exec["apt-get update"], Package['build-essential'] ], } package { "php-apc": ensure => present, require => [ Exec["apt-get update"], Package['php-pear'] ], } exec { 'get xdebug': command => 'pecl install xdebug-2.2.7', require => Package['php-pear'], unless => 'find /usr/lib -name xdebug.so | grep xdebug', } package { "imagemagick": ensure => present, require => [ Exec["apt-get update"] ], } # These are optional packages. They allow Swarm to preview Office files and # non-web safe images. They are nice to have, but take awhile to download. #package { "libreoffice-calc": # ensure => present, # require => Exec["apt-get update"], #} #package { "libreoffice-draw": # ensure => present, # require => Exec["apt-get update"], #} #package { "libreoffice-impress": # ensure => present, # require => Exec["apt-get update"], #} #package { "libreoffice-writer": # ensure => present, # require => Exec["apt-get update"], #} package { "build-essential": ensure => present, require => Exec["apt-get update"], } apache::vhost { 'localhost': port => '80', docroot => '/var/www/swarm/public', serveradmin => 'admin@example.com', directories => [ { path => '/var/www/swarm/public', allow_override => ['All'] }, order => 'Allow, Deny', allow => 'from all' ], error_log_file => 'swarm.error.log', access_log_file => 'swarm.access.log', access_log_format => 'combined', docroot_group => 'www-data', docroot_owner => 'www-data', require => [ Package['php-apc'], Exec['deploy sample depot'], File['/var/www/swarm/data'] ], notify => Service['httpd'], } # create the data directory that Swarm needs file {'/var/www/swarm/data': ensure => directory, mode => 0770, owner => 'www-data', group => 'www-data', } # copy the P4PHP module some place in the VM so that Apache doesn't need a restart on boot file {'/etc/php5/perforce-php53.so': source => '/vagrant/p4-bin/bin.linux26x86_64/perforce-php53.so', ensure => present, owner => root, group => root, mode => 444, require => Package['php-pear'], } # this adds P4PHP support to PHP. file {'/etc/php5/conf.d/p4php.ini': ensure => present, owner => root, group => root, mode => 444, content => "extension=/etc/php5/perforce-php53.so\n", require => File['/etc/php5/perforce-php53.so'], } # this adds P4PHP support to PHP. file {'/etc/php5/conf.d/xdebug.ini': ensure => present, owner => root, group => root, mode => 444, content => "zend_extension=/usr/lib/php5/20090626/xdebug.so\nxdebug.remote_enable=1\nxdebug.remote_host=192.168.33.02\n", require => File['/etc/php5/perforce-php53.so'], } # create a configuration file under data file { "/var/www/swarm/data/config.php": source => "/vagrant/manifests/files/config.php", ensure => file, require => File['/var/www/swarm/data'], } exec {"restart swarm": require => [ File['/var/www/swarm/data/config.php'], File['/etc/php5/conf.d/p4php.ini'],Apache::Vhost['localhost'] ], command => "service apache2 restart", creates => '/var/www/swarm/data/queue/tokens', } exec {"wait for swarm": require => [ File['/var/www/swarm/data/config.php'], File['/etc/php5/conf.d/p4php.ini'],Exec['restart swarm'] ], command => "/usr/bin/wget --spider --tries 10 --retry-connrefused http://localhost/login", creates => '/var/www/swarm/data/queue/tokens', } # stick the output somewhere we can read jackass # establish the trigger token exec { 'login to swarm': command => 'wget -o /dev/null -O /dev/null --keep-session-cookies --save-cookies /var/www/swarm/data/cjar --post-file /vagrant/manifests/files/pfile http://localhost/login', require => [ File['/var/www/swarm/data/config.php'], File['/etc/php5/conf.d/p4php.ini'], Exec['wait for swarm'] ], creates => '/var/www/swarm/data/queue/tokens', } # generate the auth token that Swarm needs for the triggers exec { 'generate token': command => 'wget -o /dev/null -O /dev/null --load-cookies /var/www/swarm/data/cjar http://localhost/about', require => [ Exec['login to swarm'], File['/var/www/swarm/data/config.php'], File['/etc/php5/conf.d/p4php.ini'] ], creates => '/var/www/swarm/data/queue/tokens', } # add custom directory in public for people to drop their js/css file { '/vagrant/public/custom': ensure => directory, mode => 775, } # add custom directory in public for people to drop their js/css file { '/vagrant/logs': ensure => directory, group => 'www-data', mode => 775, } file { '/vagrant/logs/email': ensure => directory, group => 'www-data', mode => 775, } # the apache error log file { '/vagrant/logs/apache.error.log': ensure => 'link', target => '/var/log/apache2/error.log', } # the swarm apache vhost log file { '/vagrant/logs/swarm.error.log': ensure => 'link', target => '/var/log/apache2/swarm.error.log', } # the swarm log file { '/vagrant/logs/swarm_log': ensure => 'link', target => '/var/www/swarm/data/log', } # generate demo data exec { 'generate demo data': command => 'wget -o /vagrant/logs/demolog -O /dev/null --load-cookies /var/www/swarm/data/cjar http://localhost/demo/generate?force=1', require => Exec['generate token'], creates => '/vagrant/logs/demolog', } # setup cronjob cron { 'worker': command => "wget -q -O /dev/null -T5 http://localhost/queue/worker", ensure => present, user => vagrant, } # replace the UUID exec { 'set token': command => 'sed -i "s:^SWARM_TOKEN=.*:SWARM_TOKEN=\"$(sudo ls -1 /var/www/swarm/data/queue/tokens | tr -d \'\n\')\":" /vagrant/p4-bin/scripts/swarm-trigger.sh', unless => 'grep -e "$(sudo ls -1 /var/www/swarm/data/queue/tokens | tr -d \'\n\')" /vagrant/p4-bin/scripts/swarm-trigger.sh', require => Exec['generate token'], } # replace the hostname exec { 'set hostname': command => 'sed -i "s|^SWARM_HOST=\"http://my-swarm-host\"|SWARM_HOST=\"http://localhost\"|" /vagrant/p4-bin/scripts/swarm-trigger.sh', onlyif => 'grep -e "SWARM_HOST=\"http://my-swarm-host\"" /vagrant/p4-bin/scripts/swarm-trigger.sh', require => Exec['generate token'], } # put the triggers in Perforce exec { 'update triggers': command => 'echo "$(/vagrant/perforce/p4 -p 1666 -u bruno -P fooBARbaz triggers -o)" "$(bash /vagrant/p4-bin/scripts/swarm-trigger.sh -o)" | /vagrant/perforce/p4 -p 1666 -u bruno -PfooBARbaz triggers -i', unless => '/vagrant/perforce/p4 -p 1666 -u bruno -P fooBARbaz triggers -o | grep -e "swarm.user"', require => Exec['set hostname'], }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#9 | 12870 | colin_grant |
Pin XDebug to version 2.2.7, the last one that supported PHP 5.3. Latest version of XDebug (2.3.2 as of this writing) requires PHP 5.4, but this dev environment uses 5.3.10-1ubuntu3.18. From announcements on http://xdebug.org/ [2015-02-22] - Xdebug 2.3.0 is out! ... This release drops support for PHP 5.2 and PHP 5.3, and raises the default max nesting level to 256. It also fixes a bunch of issues as found in Xdebug 2.2.7. @matt_attaway |
||
#8 | 11181 | Matt Attaway |
Update dev_env to use current p4php location. Tested with 14.3 |
||
#7 | 8419 | Matt Attaway | Set the timezone to PDT for the hackathon | ||
#6 | 8418 | Matt Attaway |
Install XDebug. I'm not terribly familiar with it, but phpinfo says it's installed |
||
#5 | 8417 | Matt Attaway | Fixx issue where Puppet tried to generate reviews when rebuilding with a Perforce installation | ||
#4 | 8416 | Matt Attaway |
More cleanup work for the dev environment * Setup debugging on port 9000 for phpstorm * Make sure all email is stored id logs/email * Make symlinks in logs to all relavent logs |
||
#3 | 8409 | Matt Attaway |
Harden the dev environment against 'vagrant halt' calls. This change adds a new Upstart script to start the Perforce server on startup and copies the P4PHP library to a static location so that Apache can properly load the module at boot time. Vagrant sets up the shared directories well after all of the services have been initialized which was causing Apache and Perforce grief. Also tweak a couple parts of the readme to clarify some of the odd Vagrant behavior. Many thanks to DJ for his help with testing the dev tools. |
||
#2 | 8408 | Matt Attaway |
Fix issues with the dev environment * Add a mention to 'vagrant halt' so people know how to turn machines off * Store sampledepot files in a stable place so they don't get redownloaded * Adjust the triger manipulation script to be more precise Only remaining issue is figuring out a way to restart Apache. I may just copy p4-php to a different location to protect it from the shared directory creation. |
||
#1 | 8401 | Matt Attaway | Add development environment for Swarm modding |