diff --git a/.gitattributes b/.gitattributes index b3bbb77b211..c5785ace780 100644 --- a/.gitattributes +++ b/.gitattributes @@ -20,7 +20,6 @@ *.yaml text eol=lf .bash_aliases text eol=lf -.vimrc text eol=lf # Denote all files that are truly binary and should not be modified. *.bmp binary diff --git a/dev/vagrant/README.md b/dev/vagrant/README.md index 3a2317abcf1..1a84a8db4b3 100644 --- a/dev/vagrant/README.md +++ b/dev/vagrant/README.md @@ -28,13 +28,13 @@ That's all you need to do. It will build a brand new VirtalBox machine for you w ### Name resolution For easy access to the VM you need to setup name resolution to the machines IP. -Edit the [hosts](https://fr.wikipedia.org/wiki/Hosts) file on the machine you run Vagrant on to map the virtual machine's IP to it's Vhost name. +Edit the [hosts](https://en.wikipedia.org/wiki/Hosts_(file)) file on the machine you run Vagrant on to map the virtual machine's IP to it's Vhost name. Example syntax: 192.168.42.101 dev.dolibarr.org -Once this is done, you will be able to access your VM's service at +Once this is done, you will be able to access your VM's service at Available boxes --------------- @@ -58,3 +58,5 @@ Somewhat bleeding edge vagrant box for develop branch related work. - Debugger: XDebug - Profiler: Xhprof - phpMyAdmin: + +You can access MailCatcher to read all outgoing emails at http://192.168.42.101:1080 diff --git a/dev/vagrant/dolibarrdev/Vagrantfile b/dev/vagrant/dolibarrdev/Vagrantfile index eab9f03b69d..a4094aa24e4 100644 --- a/dev/vagrant/dolibarrdev/Vagrantfile +++ b/dev/vagrant/dolibarrdev/Vagrantfile @@ -1,42 +1,100 @@ +require 'yaml' + +dir = File.dirname(File.expand_path(__FILE__)) + +configValues = YAML.load_file("#{dir}/puphpet/config.yaml") +data = configValues['vagrantfile-local'] + Vagrant.configure("2") do |config| - config.vm.box = "debian-wheezy72-x64-vbox43" - config.vm.box_url = "https://puphpet.s3.amazonaws.com/debian-wheezy72-x64-vbox43.box" + config.vm.box = "#{data['vm']['box']}" + config.vm.box_url = "#{data['vm']['box_url']}" - config.vm.network "private_network", ip: "192.168.42.101" - - - config.vm.synced_folder "../../../", "/var/www", id: "vagrant-root", :nfs => false, owner: "www-data", group: "www-data" - - config.vm.usable_port_range = (2200..2250) - config.vm.provider :virtualbox do |virtualbox| - virtualbox.customize ["modifyvm", :id, "--name", "dolibarrdev"] - virtualbox.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] - virtualbox.customize ["modifyvm", :id, "--memory", "512"] - virtualbox.customize ["setextradata", :id, "--VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"] + if data['vm']['hostname'].to_s != '' + config.vm.hostname = "#{data['vm']['hostname']}" end - config.vm.provision :shell, :path => "shell/initial-setup.sh" - config.vm.provision :shell, :path => "shell/update-puppet.sh" - config.vm.provision :shell, :path => "shell/librarian-puppet-vagrant.sh" + if data['vm']['network']['private_network'].to_s != '' + config.vm.network "private_network", ip: "#{data['vm']['network']['private_network']}" + end + + data['vm']['network']['forwarded_port'].each do |i, port| + if port['guest'] != '' && port['host'] != '' + config.vm.network :forwarded_port, guest: port['guest'].to_i, host: port['host'].to_i + end + end + + data['vm']['synced_folder'].each do |i, folder| + if folder['source'] != '' && folder['target'] != '' && folder['id'] != '' + nfs = (folder['nfs'] == "true") ? "nfs" : nil + config.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{folder['id']}", type: nfs + end + end + + config.vm.usable_port_range = (10200..10500) + + if !data['vm']['provider']['virtualbox'].empty? + config.vm.provider :virtualbox do |virtualbox| + data['vm']['provider']['virtualbox']['modifyvm'].each do |key, value| + if key == "natdnshostresolver1" + value = value ? "on" : "off" + end + virtualbox.customize ["modifyvm", :id, "--#{key}", "#{value}"] + end + end + end + + config.vm.provision "shell" do |s| + s.path = "puphpet/shell/initial-setup.sh" + s.args = "/vagrant/puphpet" + end + config.vm.provision :shell, :path => "puphpet/shell/update-puppet.sh" + config.vm.provision :shell, :path => "puphpet/shell/librarian-puppet-vagrant.sh" + config.vm.provision :puppet do |puppet| + ssh_username = !data['ssh']['username'].nil? ? data['ssh']['username'] : "vagrant" puppet.facter = { - "ssh_username" => "vagrant" + "ssh_username" => "#{ssh_username}" } + puppet.manifests_path = "#{data['vm']['provision']['puppet']['manifests_path']}" + puppet.manifest_file = "#{data['vm']['provision']['puppet']['manifest_file']}" - puppet.manifests_path = "puppet/manifests" - puppet.options = ["--verbose", "--hiera_config /vagrant/hiera.yaml", "--parser future"] + if !data['vm']['provision']['puppet']['options'].empty? + puppet.options = data['vm']['provision']['puppet']['options'] + end end + config.vm.provision :shell, :path => "puphpet/shell/execute-files.sh" + if !data['ssh']['host'].nil? + config.ssh.host = "#{data['ssh']['host']}" + end + if !data['ssh']['port'].nil? + config.ssh.port = "#{data['ssh']['port']}" + end + if !data['ssh']['private_key_path'].nil? + config.ssh.private_key_path = "#{data['ssh']['private_key_path']}" + end + if !data['ssh']['username'].nil? + config.ssh.username = "#{data['ssh']['username']}" + end + if !data['ssh']['guest_port'].nil? + config.ssh.guest_port = data['ssh']['guest_port'] + end + if !data['ssh']['shell'].nil? + config.ssh.shell = "#{data['ssh']['shell']}" + end + if !data['ssh']['keep_alive'].nil? + config.ssh.keep_alive = data['ssh']['keep_alive'] + end + if !data['ssh']['forward_agent'].nil? + config.ssh.forward_agent = data['ssh']['forward_agent'] + end + if !data['ssh']['forward_x11'].nil? + config.ssh.forward_x11 = data['ssh']['forward_x11'] + end + if !data['vagrant']['host'].nil? + config.vagrant.host = data['vagrant']['host'].gsub(":", "").intern + end - - config.ssh.username = "vagrant" - - config.ssh.shell = "bash -l" - - config.ssh.keep_alive = true - config.ssh.forward_agent = false - config.ssh.forward_x11 = false - config.vagrant.host = :detect end diff --git a/dev/vagrant/dolibarrdev/puppet/hieradata/common.yaml b/dev/vagrant/dolibarrdev/puphpet/config.yaml similarity index 65% rename from dev/vagrant/dolibarrdev/puppet/hieradata/common.yaml rename to dev/vagrant/dolibarrdev/puphpet/config.yaml index 2db740bef15..e54c4532766 100644 --- a/dev/vagrant/dolibarrdev/puppet/hieradata/common.yaml +++ b/dev/vagrant/dolibarrdev/puphpet/config.yaml @@ -2,31 +2,31 @@ vagrantfile-local: vm: box: debian-wheezy72-x64-vbox43 - box_url: 'https://puphpet.s3.amazonaws.com/debian-wheezy72-x64-vbox43.box' + box_url: 'http://box.puphpet.com/debian-wheezy72-x64-vbox43.box' hostname: null network: private_network: 192.168.42.101 forwarded_port: - IoUPe5V4KFVe: - host: '' - guest: '' + jHkzZVuBoVtG: + host: '9252' + guest: '22' provider: virtualbox: modifyvm: - name: dolibarrdev natdnshostresolver1: on memory: '512' setextradata: VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root: 1 provision: puppet: - manifests_path: puppet/manifests + manifests_path: puphpet/puppet + manifest_file: manifest.pp options: - - --verbose - - '--hiera_config /vagrant/hiera.yaml' + - '--verbose' + - '--hiera_config /vagrant/puphpet/puppet/hiera.yaml' - '--parser future' synced_folder: - w8TR2T1V5h4o: + vMRGvEXBrASV: id: vagrant-root source: ../../../ target: /var/www @@ -43,7 +43,7 @@ vagrantfile-local: forward_x11: false shell: 'bash -l' vagrant: - host: ':detect' + host: detect server: packages: - nano @@ -52,12 +52,21 @@ server: - bash_aliases: null _prevent_empty: '' +mailcatcher: + install: '1' + settings: + smtp_ip: 0.0.0.0 + smtp_port: 1025 + http_ip: 0.0.0.0 + http_port: '1080' + path: /usr/local/bin + log: /var/log/mailcatcher/mailcatcher.log apache: modules: - php - rewrite vhosts: - vkJFW364QjeN: + fIrYPRDORtSV: servername: dev.dolibarr.org docroot: /var/www/htdocs port: '80' @@ -68,24 +77,27 @@ apache: user: www-data group: www-data default_vhost: true - mpm_module: prefork + mod_pagespeed: 0 + mod_spdy: 0 php: + install: '1' version: '55' composer: '1' modules: php: - cli + - curl + - gd + - imagick - intl - mcrypt - - curl - - imagick - - gd pear: { } pecl: { } ini: display_errors: On error_reporting: '-1' session.save_path: /var/lib/php/session + sendmail_path: '"/usr/bin/env catchmail"' timezone: UTC xdebug: install: '1' @@ -98,12 +110,16 @@ xdebug: xdebug.remote_port: '9000' xhprof: install: '1' - location: /var/www/xhprof +drush: + install: 0 + settings: + drush.tag_branch: 6.x mysql: root_password: root phpmyadmin: '1' + adminer: 0 databases: - 4TUR1gNNdrQV: + K7xpd6KqfK3E: grant: - ALTER - CREATE @@ -118,4 +134,24 @@ mysql: user: user password: user sql_file: /var/www/dev/initdata/mysqldump_dolibarr_3.5.0.sql +mongodb: + install: 0 + auth: 1 + port: '27017' + databases: { } +beanstalkd: + install: 0 + settings: + listenaddress: 0.0.0.0 + listenport: '13000' + maxjobsize: '65535' + maxconnections: '1024' + binlogdir: /var/lib/beanstalkd/binlog + binlogfsync: null + binlogsize: '10485760' + beanstalk_console: 0 + binlogdir: /var/lib/beanstalkd/binlog +rabbitmq: + install: 0 + port: '5672' diff --git a/dev/vagrant/dolibarrdev/files/dot/.bash_aliases b/dev/vagrant/dolibarrdev/puphpet/files/dot/.bash_aliases similarity index 100% rename from dev/vagrant/dolibarrdev/files/dot/.bash_aliases rename to dev/vagrant/dolibarrdev/puphpet/files/dot/.bash_aliases diff --git a/dev/vagrant/dolibarrdev/files/dot/.vimrc b/dev/vagrant/dolibarrdev/puphpet/files/dot/.vimrc similarity index 100% rename from dev/vagrant/dolibarrdev/files/dot/.vimrc rename to dev/vagrant/dolibarrdev/puphpet/files/dot/.vimrc diff --git a/dev/vagrant/dolibarrdev/puphpet/files/exec-always/empty b/dev/vagrant/dolibarrdev/puphpet/files/exec-always/empty new file mode 100644 index 00000000000..e69de29bb2d diff --git a/dev/vagrant/dolibarrdev/puphpet/files/exec-once/empty b/dev/vagrant/dolibarrdev/puphpet/files/exec-once/empty new file mode 100644 index 00000000000..e69de29bb2d diff --git a/dev/vagrant/dolibarrdev/puphpet/puppet/Puppetfile b/dev/vagrant/dolibarrdev/puphpet/puppet/Puppetfile new file mode 100644 index 00000000000..8b6cc92cb67 --- /dev/null +++ b/dev/vagrant/dolibarrdev/puphpet/puppet/Puppetfile @@ -0,0 +1,19 @@ +forge "http://forge.puppetlabs.com" +mod 'stdlib', :git => 'https://github.com/puphpet/puppetlabs-stdlib.git' +mod 'concat', :git => 'https://github.com/puphpet/puppetlabs-concat.git' +mod 'apt', :git => 'https://github.com/puphpet/puppetlabs-apt.git' +mod 'yum', :git => 'https://github.com/puphpet/puppet-yum.git' +mod 'vcsrepo', :git => 'https://github.com/puphpet/puppetlabs-vcsrepo.git' +mod 'ntp', :git => 'https://github.com/puphpet/puppetlabs-ntp.git' +mod 'iptables', :git => 'https://github.com/puphpet/puppet-iptables.git' +mod 'mailcatcher', :git => 'https://github.com/puphpet/puppet-mailcatcher.git' +mod 'supervisord', :git => 'https://github.com/puphpet/puppet-supervisord.git' +mod 'apache', :git => 'https://github.com/puphpet/puppetlabs-apache.git' +mod 'php', :git => 'https://github.com/puphpet/puppet-php.git' +mod 'composer', :git => 'https://github.com/puphpet/puppet-composer.git' +mod 'puphpet', :git => 'https://github.com/puphpet/puppet-puphpet.git' +mod 'drush', :git => 'https://github.com/puphpet/puppet-drush.git', :ref => 'new' +mod 'mysql', :git => 'https://github.com/puphpet/puppetlabs-mysql.git' +mod 'mongodb', :git => 'https://github.com/puphpet/puppetlabs-mongodb.git' +mod 'beanstalkd', :git => 'https://github.com/puphpet/puppet-beanstalkd.git' +mod 'rabbitmq', :git => 'https://github.com/puphpet/puppetlabs-rabbitmq.git' diff --git a/dev/vagrant/dolibarrdev/hiera.yaml b/dev/vagrant/dolibarrdev/puphpet/puppet/hiera.yaml similarity index 50% rename from dev/vagrant/dolibarrdev/hiera.yaml rename to dev/vagrant/dolibarrdev/puphpet/puppet/hiera.yaml index 2cab35e31f2..0cde1f6a6a6 100644 --- a/dev/vagrant/dolibarrdev/hiera.yaml +++ b/dev/vagrant/dolibarrdev/puphpet/puppet/hiera.yaml @@ -1,7 +1,7 @@ --- :backends: yaml :yaml: - :datadir: '/vagrant/puppet/hieradata' + :datadir: '/vagrant/puphpet' :hierarchy: - - common + - config :logger: console diff --git a/dev/vagrant/dolibarrdev/puphpet/puppet/manifest.pp b/dev/vagrant/dolibarrdev/puphpet/puppet/manifest.pp new file mode 100644 index 00000000000..7480726aa63 --- /dev/null +++ b/dev/vagrant/dolibarrdev/puphpet/puppet/manifest.pp @@ -0,0 +1,993 @@ +## Begin Server manifest + +if $server_values == undef { + $server_values = hiera('server', false) +} + +# Ensure the time is accurate, reducing the possibilities of apt repositories +# failing for invalid certificates +include '::ntp' + +Exec { path => [ '/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/' ] } +group { 'puppet': ensure => present } +group { 'www-data': ensure => present } + +user { $::ssh_username: + shell => '/bin/bash', + home => "/home/${::ssh_username}", + ensure => present +} + +user { ['apache', 'nginx', 'httpd', 'www-data']: + shell => '/bin/bash', + ensure => present, + groups => 'www-data', + require => Group['www-data'] +} + +file { "/home/${::ssh_username}": + ensure => directory, + owner => $::ssh_username, +} + +# copy dot files to ssh user's home directory +exec { 'dotfiles': + cwd => "/home/${::ssh_username}", + command => "cp -r /vagrant/puphpet/files/dot/.[a-zA-Z0-9]* /home/${::ssh_username}/ \ + && chown -R ${::ssh_username} /home/${::ssh_username}/.[a-zA-Z0-9]* \ + && cp -r /vagrant/puphpet/files/dot/.[a-zA-Z0-9]* /root/", + onlyif => 'test -d /vagrant/puphpet/files/dot', + returns => [0, 1], + require => User[$::ssh_username] +} + +case $::osfamily { + # debian, ubuntu + 'debian': { + class { 'apt': } + + Class['::apt::update'] -> Package <| + title != 'python-software-properties' + and title != 'software-properties-common' + |> + + ensure_packages( ['augeas-tools'] ) + } + # redhat, centos + 'redhat': { + class { 'yum': extrarepo => ['epel'] } + + class { 'yum::repo::rpmforge': } + class { 'yum::repo::repoforgeextras': } + + Class['::yum'] -> Yum::Managed_yumrepo <| |> -> Package <| |> + + if defined(Package['git']) == false { + package { 'git': + ensure => latest, + require => Class['yum::repo::repoforgeextras'] + } + } + + exec { 'bash_git': + cwd => "/home/${::ssh_username}", + command => "curl https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh > /home/${::ssh_username}/.bash_git", + creates => "/home/${::ssh_username}/.bash_git" + } + + exec { 'bash_git for root': + cwd => '/root', + command => "cp /home/${::ssh_username}/.bash_git /root/.bash_git", + creates => '/root/.bash_git', + require => Exec['bash_git'] + } + + file_line { 'link ~/.bash_git': + ensure => present, + line => 'if [ -f ~/.bash_git ] ; then source ~/.bash_git; fi', + path => "/home/${::ssh_username}/.bash_profile", + require => [ + Exec['dotfiles'], + Exec['bash_git'], + ] + } + + file_line { 'link ~/.bash_git for root': + ensure => present, + line => 'if [ -f ~/.bash_git ] ; then source ~/.bash_git; fi', + path => '/root/.bashrc', + require => [ + Exec['dotfiles'], + Exec['bash_git'], + ] + } + + file_line { 'link ~/.bash_aliases': + ensure => present, + line => 'if [ -f ~/.bash_aliases ] ; then source ~/.bash_aliases; fi', + path => "/home/${::ssh_username}/.bash_profile", + require => File_line['link ~/.bash_git'] + } + + file_line { 'link ~/.bash_aliases for root': + ensure => present, + line => 'if [ -f ~/.bash_aliases ] ; then source ~/.bash_aliases; fi', + path => '/root/.bashrc', + require => File_line['link ~/.bash_git for root'] + } + + ensure_packages( ['augeas'] ) + } +} + +if $php_values == undef { + $php_values = hiera('php', false) +} + +case $::operatingsystem { + 'debian': { + include apt::backports + + add_dotdeb { 'packages.dotdeb.org': release => $lsbdistcodename } + + if is_hash($php_values) and has_key($php_values, 'install') and $php_values['install'] == 1 { + # Debian Squeeze 6.0 can do PHP 5.3 (default) and 5.4 + if $lsbdistcodename == 'squeeze' and $php_values['version'] == '54' { + add_dotdeb { 'packages.dotdeb.org-php54': release => 'squeeze-php54' } + } + # Debian Wheezy 7.0 can do PHP 5.4 (default) and 5.5 + elsif $lsbdistcodename == 'wheezy' and $php_values['version'] == '55' { + add_dotdeb { 'packages.dotdeb.org-php55': release => 'wheezy-php55' } + } + } + + $server_lsbdistcodename = downcase($lsbdistcodename) + + apt::force { 'git': + release => "${server_lsbdistcodename}-backports", + timeout => 60 + } + } + 'ubuntu': { + apt::key { '4F4EA0AAE5267A6C': + key_server => 'hkp://keyserver.ubuntu.com:80' + } + apt::key { '4CBEDD5A': + key_server => 'hkp://keyserver.ubuntu.com:80' + } + + apt::ppa { 'ppa:pdoes/ppa': require => Apt::Key['4CBEDD5A'] } + + if is_hash($php_values) and has_key($php_values, 'install') and $php_values['install'] == 1 { + # Ubuntu Lucid 10.04, Precise 12.04, Quantal 12.10 and Raring 13.04 can do PHP 5.3 (default <= 12.10) and 5.4 (default <= 13.04) + if $lsbdistcodename in ['lucid', 'precise', 'quantal', 'raring'] and $php_values['version'] == '54' { + if $lsbdistcodename == 'lucid' { + apt::ppa { 'ppa:ondrej/php5-oldstable': require => Apt::Key['4F4EA0AAE5267A6C'], options => '' } + } else { + apt::ppa { 'ppa:ondrej/php5-oldstable': require => Apt::Key['4F4EA0AAE5267A6C'] } + } + } + # Ubuntu Precise 12.04, Quantal 12.10 and Raring 13.04 can do PHP 5.5 + elsif $lsbdistcodename in ['precise', 'quantal', 'raring'] and $php_values['version'] == '55' { + apt::ppa { 'ppa:ondrej/php5': require => Apt::Key['4F4EA0AAE5267A6C'] } + } + elsif $lsbdistcodename in ['lucid'] and $php_values['version'] == '55' { + err('You have chosen to install PHP 5.5 on Ubuntu 10.04 Lucid. This will probably not work!') + } + } + } + 'redhat', 'centos': { + if is_hash($php_values) and has_key($php_values, 'install') and $php_values['install'] == 1 { + if $php_values['version'] == '54' { + class { 'yum::repo::remi': } + } + # remi_php55 requires the remi repo as well + elsif $php_values['version'] == '55' { + class { 'yum::repo::remi': } + class { 'yum::repo::remi_php55': } + } + } + } +} + +if !empty($server_values['packages']) { + ensure_packages( $server_values['packages'] ) +} + +define add_dotdeb ($release){ + apt::source { $name: + location => 'http://packages.dotdeb.org', + release => $release, + repos => 'all', + required_packages => 'debian-keyring debian-archive-keyring', + key => '89DF5277', + key_server => 'keys.gnupg.net', + include_src => true + } +} + +## Begin MailCatcher manifest + +if $mailcatcher_values == undef { + $mailcatcher_values = hiera('mailcatcher', false) +} + +if is_hash($mailcatcher_values) and has_key($mailcatcher_values, 'install') and $mailcatcher_values['install'] == 1 { + $mailcatcher_path = $mailcatcher_values['settings']['path'] + $mailcatcher_smtp_ip = $mailcatcher_values['settings']['smtp_ip'] + $mailcatcher_smtp_port = $mailcatcher_values['settings']['smtp_port'] + $mailcatcher_http_ip = $mailcatcher_values['settings']['http_ip'] + $mailcatcher_http_port = $mailcatcher_values['settings']['http_port'] + $mailcatcher_log = $mailcatcher_values['settings']['log'] + + class { 'mailcatcher': + mailcatcher_path => $mailcatcher_path, + smtp_ip => $mailcatcher_smtp_ip, + smtp_port => $mailcatcher_smtp_port, + http_ip => $mailcatcher_http_ip, + http_port => $mailcatcher_http_port, + } + + if $::osfamily == 'redhat' and ! defined(Iptables::Allow["tcp/${mailcatcher_smtp_port}"]) { + iptables::allow { "tcp/${mailcatcher_smtp_port}": + port => $mailcatcher_smtp_port, + protocol => 'tcp' + } + } + + if $::osfamily == 'redhat' and ! defined(Iptables::Allow["tcp/${mailcatcher_http_port}"]) { + iptables::allow { "tcp/${mailcatcher_http_port}": + port => $mailcatcher_http_port, + protocol => 'tcp' + } + } + + if ! defined(Class['supervisord']) { + class { 'supervisord': + install_pip => true, + } + } + + $supervisord_mailcatcher_options = sort(join_keys_to_values({ + ' --smtp-ip' => $mailcatcher_smtp_ip, + ' --smtp-port' => $mailcatcher_smtp_port, + ' --http-ip' => $mailcatcher_http_ip, + ' --http-port' => $mailcatcher_http_port + }, ' ')) + + $supervisord_mailcatcher_cmd = "mailcatcher ${supervisord_mailcatcher_options} -f >> ${mailcatcher_log}" + + supervisord::program { 'mailcatcher': + command => $supervisord_mailcatcher_cmd, + priority => '100', + user => 'mailcatcher', + autostart => true, + autorestart => true, + environment => { + 'PATH' => "/bin:/sbin:/usr/bin:/usr/sbin:${mailcatcher_path}" + }, + require => Package['mailcatcher'] + } +} + +## Begin Apache manifest + +if $yaml_values == undef { + $yaml_values = loadyaml('/vagrant/puphpet/config.yaml') +} + +if $apache_values == undef { + $apache_values = $yaml_values['apache'] +} + +if $php_values == undef { + $php_values = hiera('php', false) +} + +if $hhvm_values == undef { + $hhvm_values = hiera('hhvm', false) +} + +include puphpet::params +include apache::params + +$webroot_location = $puphpet::params::apache_webroot_location + +exec { "exec mkdir -p ${webroot_location}": + command => "mkdir -p ${webroot_location}", + creates => $webroot_location, +} + +if ! defined(File[$webroot_location]) { + file { $webroot_location: + ensure => directory, + group => 'www-data', + mode => 0775, + require => [ + Exec["exec mkdir -p ${webroot_location}"], + Group['www-data'] + ] + } +} + +if is_hash($hhvm_values) and has_key($hhvm_values, 'install') and $hhvm_values['install'] == 1 { + $mpm_module = 'worker' + $disallowed_modules = ['php'] + $apache_conf_template = 'puphpet/apache/hhvm-httpd.conf.erb' +} elsif (is_hash($php_values)) { + $mpm_module = 'prefork' + $disallowed_modules = [] + $apache_conf_template = $apache::params::conf_template +} else { + $mpm_module = 'prefork' + $disallowed_modules = [] + $apache_conf_template = $apache::params::conf_template +} + +class { 'apache': + user => $apache_values['user'], + group => $apache_values['group'], + default_vhost => true, + mpm_module => $mpm_module, + manage_user => false, + manage_group => false, + conf_template => $apache_conf_template +} + +if $::osfamily == 'redhat' and ! defined(Iptables::Allow['tcp/80']) { + iptables::allow { 'tcp/80': + port => '80', + protocol => 'tcp' + } +} + +if has_key($apache_values, 'mod_pagespeed') and $apache_values['mod_pagespeed'] == 1 { + class { 'puphpet::apache::modpagespeed': } +} + +if has_key($apache_values, 'mod_spdy') and $apache_values['mod_spdy'] == 1 { + class { 'puphpet::apache::modspdy': } +} + +if count($apache_values['vhosts']) > 0 { + each( $apache_values['vhosts'] ) |$key, $vhost| { + exec { "exec mkdir -p ${vhost['docroot']} @ key ${key}": + command => "mkdir -p ${vhost['docroot']}", + creates => $vhost['docroot'], + } + + if ! defined(File[$vhost['docroot']]) { + file { $vhost['docroot']: + ensure => directory, + require => Exec["exec mkdir -p ${vhost['docroot']} @ key ${key}"] + } + } + } +} + +create_resources(apache::vhost, $apache_values['vhosts']) + +define apache_mod { + if ! defined(Class["apache::mod::${name}"]) and !($name in $disallowed_modules) { + class { "apache::mod::${name}": } + } +} + +if count($apache_values['modules']) > 0 { + apache_mod { $apache_values['modules']: } +} + +## Begin PHP manifest + +if $php_values == undef { + $php_values = hiera('php', false) +} + +if $apache_values == undef { + $apache_values = hiera('apache', false) +} + +if $nginx_values == undef { + $nginx_values = hiera('nginx', false) +} + +if is_hash($php_values) and has_key($php_values, 'install') and $php_values['install'] == 1 { + Class['Php'] -> Class['Php::Devel'] -> Php::Module <| |> -> Php::Pear::Module <| |> -> Php::Pecl::Module <| |> + + if $php_prefix == undef { + $php_prefix = $::operatingsystem ? { + /(?i:Ubuntu|Debian|Mint|SLES|OpenSuSE)/ => 'php5-', + default => 'php-', + } + } + + if $php_fpm_ini == undef { + $php_fpm_ini = $::operatingsystem ? { + /(?i:Ubuntu|Debian|Mint|SLES|OpenSuSE)/ => '/etc/php5/fpm/php.ini', + default => '/etc/php.ini', + } + } + + if is_hash($apache_values) { + include apache::params + + if has_key($apache_values, 'mod_spdy') and $apache_values['mod_spdy'] == 1 { + $php_webserver_service_ini = 'cgi' + } else { + $php_webserver_service_ini = 'httpd' + } + + $php_webserver_service = 'httpd' + $php_webserver_user = $apache::params::user + $php_webserver_restart = true + + class { 'php': + service => $php_webserver_service + } + } elsif is_hash($nginx_values) { + include nginx::params + + $php_webserver_service = "${php_prefix}fpm" + $php_webserver_service_ini = $php_webserver_service + $php_webserver_user = $nginx::params::nx_daemon_user + $php_webserver_restart = true + + class { 'php': + package => $php_webserver_service, + service => $php_webserver_service, + service_autorestart => false, + config_file => $php_fpm_ini, + } + + service { $php_webserver_service: + ensure => running, + enable => true, + hasrestart => true, + hasstatus => true, + require => Package[$php_webserver_service] + } + } else { + $php_webserver_service = undef + $php_webserver_service_ini = undef + $php_webserver_restart = false + + class { 'php': + package => "${php_prefix}cli", + service => $php_webserver_service, + service_autorestart => false, + } + } + + class { 'php::devel': } + + if count($php_values['modules']['php']) > 0 { + php_mod { $php_values['modules']['php']:; } + } + if count($php_values['modules']['pear']) > 0 { + php_pear_mod { $php_values['modules']['pear']:; } + } + if count($php_values['modules']['pecl']) > 0 { + php_pecl_mod { $php_values['modules']['pecl']:; } + } + if count($php_values['ini']) > 0 { + each( $php_values['ini'] ) |$key, $value| { + if is_array($value) { + each( $php_values['ini'][$key] ) |$innerkey, $innervalue| { + puphpet::ini { "${key}_${innerkey}": + entry => "CUSTOM_${innerkey}/${key}", + value => $innervalue, + php_version => $php_values['version'], + webserver => $php_webserver_service_ini + } + } + } else { + puphpet::ini { $key: + entry => "CUSTOM/${key}", + value => $value, + php_version => $php_values['version'], + webserver => $php_webserver_service_ini + } + } + } + + if $php_values['ini']['session.save_path'] != undef { + exec {"mkdir -p ${php_values['ini']['session.save_path']}": + onlyif => "test ! -d ${php_values['ini']['session.save_path']}", + } + + file { $php_values['ini']['session.save_path']: + ensure => directory, + group => 'www-data', + mode => 0775, + require => Exec["mkdir -p ${php_values['ini']['session.save_path']}"] + } + } + } + + puphpet::ini { $key: + entry => 'CUSTOM/date.timezone', + value => $php_values['timezone'], + php_version => $php_values['version'], + webserver => $php_webserver_service_ini + } + + if $php_values['composer'] == 1 { + class { 'composer': + target_dir => '/usr/local/bin', + composer_file => 'composer', + download_method => 'curl', + logoutput => false, + tmp_path => '/tmp', + php_package => "${php::params::module_prefix}cli", + curl_package => 'curl', + suhosin_enabled => false, + } + } +} + + +define php_mod { + php::module { $name: + service_autorestart => $php_webserver_restart, + } +} +define php_pear_mod { + php::pear::module { $name: + use_package => false, + service_autorestart => $php_webserver_restart, + } +} +define php_pecl_mod { + php::pecl::module { $name: + use_package => false, + service_autorestart => $php_webserver_restart, + } +} + +## Begin Xdebug manifest + +if $xdebug_values == undef { + $xdebug_values = hiera('xdebug', false) +} + +if $php_values == undef { + $php_values = hiera('php', false) +} + +if $apache_values == undef { + $apache_values = hiera('apache', false) +} + +if $nginx_values == undef { + $nginx_values = hiera('nginx', false) +} + +if is_hash($apache_values) { + $xdebug_webserver_service = 'httpd' +} elsif is_hash($nginx_values) { + $xdebug_webserver_service = 'nginx' +} else { + $xdebug_webserver_service = undef +} + +if (is_hash($xdebug_values) and has_key($xdebug_values, 'install') and $xdebug_values['install'] == 1) + and is_hash($php_values) and has_key($php_values, 'install') and $php_values['install'] == 1 { + class { 'puphpet::xdebug': + webserver => $xdebug_webserver_service + } + + if is_hash($xdebug_values['settings']) and count($xdebug_values['settings']) > 0 { + each( $xdebug_values['settings'] ) |$key, $value| { + puphpet::ini { $key: + entry => "XDEBUG/${key}", + value => $value, + php_version => $php_values['version'], + webserver => $xdebug_webserver_service + } + } + } +} + +## Begin Xhprof manifest + +if $xhprof_values == undef { + $xhprof_values = hiera('xhprof', false) +} + +if $apache_values == undef { + $apache_values = hiera('apache', false) +} + +if $nginx_values == undef { + $nginx_values = hiera('nginx', false) +} + +if is_hash($apache_values) or is_hash($nginx_values) { + $xhprof_webserver_restart = true +} else { + $xhprof_webserver_restart = false +} + +if (is_hash($xhprof_values) and has_key($xhprof_values, 'install') and $xhprof_values['install'] == 1) + and is_hash($php_values) and has_key($php_values, 'install') and $php_values['install'] == 1 { + if $::operatingsystem == 'ubuntu' { + apt::key { '8D0DC64F': + key_server => 'hkp://keyserver.ubuntu.com:80' + } + + apt::ppa { 'ppa:brianmercer/php5-xhprof': require => Apt::Key['8D0DC64F'] } + } + + $xhprof_package = $puphpet::params::xhprof_package + + if is_hash($apache_values) { + $xhprof_webroot_location = $puphpet::params::apache_webroot_location + $xhprof_webserver_service = Service['httpd'] + } elsif is_hash($nginx_values) { + $xhprof_webroot_location = $puphpet::params::nginx_webroot_location + $xhprof_webserver_service = Service['nginx'] + } else { + $xhprof_webroot_location = $xhprof_values['location'] + $xhprof_webserver_service = undef + } + + if defined(Package[$xhprof_package]) == false { + package { $xhprof_package: + ensure => installed, + require => Package['php'], + notify => $xhprof_webserver_service, + } + } + + ensure_packages( ['graphviz'] ) + + exec { 'delete-xhprof-path-if-not-git-repo': + command => "rm -rf ${xhprofPath}", + onlyif => "test ! -d ${xhprofPath}/.git" + } + + vcsrepo { "${xhprof_webroot_location}/xhprof": + ensure => present, + provider => git, + source => 'https://github.com/facebook/xhprof.git', + require => Exec['delete-xhprof-path-if-not-git-repo'] + } + + file { "${xhprofPath}/xhprof_html": + ensure => directory, + mode => 0775, + require => Vcsrepo["${xhprof_webroot_location}/xhprof"] + } + + composer::exec { 'xhprof-composer-run': + cmd => 'install', + cwd => "${xhprof_webroot_location}/xhprof", + require => [ + Class['composer'], + File["${xhprofPath}/xhprof_html"] + ] + } +} + +## Begin Drush manifest + +if $drush_values == undef { + $drush_values = hiera('drush', false) +} + +if is_hash($drush_values) and has_key($drush_values, 'install') and $drush_values['install'] == 1 { + if ($drush_values['settings']['drush.tag_branch'] != undef) { + $drush_tag_branch = $drush_values['settings']['drush.tag_branch'] + } else { + $drush_tag_branch = '' + } + + include drush::git::drush +} + +## Begin MySQL manifest + +if $mysql_values == undef { + $mysql_values = hiera('mysql', false) +} + +if $php_values == undef { + $php_values = hiera('php', false) +} + +if $apache_values == undef { + $apache_values = hiera('apache', false) +} + +if $nginx_values == undef { + $nginx_values = hiera('nginx', false) +} + +if is_hash($apache_values) or is_hash($nginx_values) { + $mysql_webserver_restart = true +} else { + $mysql_webserver_restart = false +} + +if (is_hash($php_values) and has_key($php_values, 'install') and $php_values['install'] == 1) + or (is_hash($hhvm_values) and has_key($hhvm_values, 'install') and $hhvm_values['install'] == 1) +{ + $mysql_php_installed = true +} else { + $mysql_php_installed = false +} + +if $mysql_values['root_password'] { + class { 'mysql::server': + root_password => $mysql_values['root_password'], + } + + if is_hash($mysql_values['databases']) and count($mysql_values['databases']) > 0 { + create_resources(mysql_db, $mysql_values['databases']) + } + + if is_hash($php_values) and has_key($php_values, 'install') and $php_values['install'] == 1 and ! defined(Php::Pecl::Module[$mongodb_pecl]) { + if $::osfamily == 'redhat' and $php_values['version'] == '53' and ! defined(Php::Module['mysql']) { + php::module { 'mysql': + service_autorestart => $mysql_webserver_restart, + } + } elsif ! defined(Php::Module['mysqlnd']) { + php::module { 'mysqlnd': + service_autorestart => $mysql_webserver_restart, + } + } + } +} + +define mysql_db ( + $user, + $password, + $host, + $grant = [], + $sql_file = false +) { + if $name == '' or $password == '' or $host == '' { + fail( 'MySQL DB requires that name, password and host be set. Please check your settings!' ) + } + + mysql::db { $name: + user => $user, + password => $password, + host => $host, + grant => $grant, + sql => $sql_file, + } +} + +if has_key($mysql_values, 'phpmyadmin') and $mysql_values['phpmyadmin'] == 1 and $mysql_php_installed { + if $::osfamily == 'debian' { + if $::operatingsystem == 'ubuntu' { + apt::key { '80E7349A06ED541C': key_server => 'hkp://keyserver.ubuntu.com:80' } + apt::ppa { 'ppa:nijel/phpmyadmin': require => Apt::Key['80E7349A06ED541C'] } + } + + $phpMyAdmin_package = 'phpmyadmin' + $phpMyAdmin_folder = 'phpmyadmin' + } elsif $::osfamily == 'redhat' { + $phpMyAdmin_package = 'phpMyAdmin.noarch' + $phpMyAdmin_folder = 'phpMyAdmin' + } + + if ! defined(Package[$phpMyAdmin_package]) { + package { $phpMyAdmin_package: + require => Class['mysql::server'] + } + } + + include puphpet::params + + if is_hash($apache_values) { + $mysql_pma_webroot_location = $puphpet::params::apache_webroot_location + } elsif is_hash($nginx_values) { + $mysql_pma_webroot_location = $puphpet::params::nginx_webroot_location + + mysql_nginx_default_conf { 'override_default_conf': + webroot => $mysql_pma_webroot_location + } + } + + exec { 'cp phpmyadmin to webroot': + command => "cp -LR /usr/share/${phpMyAdmin_folder} ${mysql_pma_webroot_location}/phpmyadmin", + onlyif => "test ! -d ${mysql_pma_webroot_location}/phpmyadmin", + require => [ + Package[$phpMyAdmin_package], + File[$mysql_pma_webroot_location] + ] + } +} + +if has_key($mysql_values, 'adminer') and $mysql_values['adminer'] == 1 and $mysql_php_installed { + if is_hash($apache_values) { + $mysql_adminer_webroot_location = $puphpet::params::apache_webroot_location + } elsif is_hash($nginx_values) { + $mysql_adminer_webroot_location = $puphpet::params::nginx_webroot_location + } else { + $mysql_adminer_webroot_location = $puphpet::params::apache_webroot_location + } + + class { 'puphpet::adminer': + location => "${mysql_adminer_webroot_location}/adminer", + owner => 'www-data' + } +} + +# @todo update this +define mysql_nginx_default_conf ( + $webroot +) { + if $php5_fpm_sock == undef { + $php5_fpm_sock = '/var/run/php5-fpm.sock' + } + + if $fastcgi_pass == undef { + $fastcgi_pass = $php_values['version'] ? { + undef => null, + '53' => '127.0.0.1:9000', + default => "unix:${php5_fpm_sock}" + } + } + + class { 'puphpet::nginx': + fastcgi_pass => $fastcgi_pass, + notify => Class['nginx::service'], + } +} + +## Begin MongoDb manifest + +if $mongodb_values == undef { + $mongodb_values = hiera('mongodb', false) +} + +if $php_values == undef { + $php_values = hiera('php', false) +} + +if $apache_values == undef { + $apache_values = hiera('apache', false) +} + +if $nginx_values == undef { + $nginx_values = hiera('nginx', false) +} + +if is_hash($apache_values) or is_hash($nginx_values) { + $mongodb_webserver_restart = true +} else { + $mongodb_webserver_restart = false +} + +if has_key($mongodb_values, 'install') and $mongodb_values['install'] == 1 { + case $::osfamily { + 'debian': { + class {'::mongodb::globals': + manage_package_repo => true, + }-> + class {'::mongodb::server': + auth => $mongodb_values['auth'], + port => $mongodb_values['port'], + } + + $mongodb_pecl = 'mongo' + } + 'redhat': { + class {'::mongodb::globals': + manage_package_repo => true, + }-> + class {'::mongodb::server': + auth => $mongodb_values['auth'], + port => $mongodb_values['port'], + }-> + class {'::mongodb::client': } + + $mongodb_pecl = 'pecl-mongo' + } + } + + if is_hash($mongodb_values['databases']) and count($mongodb_values['databases']) > 0 { + create_resources(mongodb_db, $mongodb_values['databases']) + } + + if is_hash($php_values) and has_key($php_values, 'install') and $php_values['install'] == 1 and ! defined(Php::Pecl::Module[$mongodb_pecl]) { + php::pecl::module { $mongodb_pecl: + service_autorestart => $mariadb_webserver_restart, + require => Class['::mongodb::server'] + } + } +} + +define mongodb_db ( + $user, + $password +) { + if $name == '' or $password == '' { + fail( 'MongoDB requires that name and password be set. Please check your settings!' ) + } + + mongodb::db { $name: + user => $user, + password => $password + } +} + +# Begin beanstalkd + +if $beanstalkd_values == undef { + $beanstalkd_values = hiera('beanstalkd', false) +} + +if $php_values == undef { + $php_values = hiera('php', false) +} + +if $hhvm_values == undef { + $hhvm_values = hiera('hhvm', false) +} + +if $apache_values == undef { + $apache_values = hiera('apache', false) +} + +if $nginx_values == undef { + $nginx_values = hiera('nginx', false) +} + +if is_hash($apache_values) { + $beanstalk_console_webroot_location = "${puphpet::params::apache_webroot_location}/beanstalk_console" +} elsif is_hash($nginx_values) { + $beanstalk_console_webroot_location = "${puphpet::params::nginx_webroot_location}/beanstalk_console" +} else { + $beanstalk_console_webroot_location = undef +} + +if (is_hash($php_values) and has_key($php_values, 'install') and $php_values['install'] == 1) + or (is_hash($hhvm_values) and has_key($hhvm_values, 'install') and $hhvm_values['install'] == 1) +{ + $beanstalkd_php_installed = true +} else { + $beanstalkd_php_installed = false +} + +if is_hash($beanstalkd_values) and has_key($beanstalkd_values, 'install') and $beanstalkd_values['install'] == 1 { + create_resources(beanstalkd::config, {'beanstalkd' => $beanstalkd_values['settings']}) + + if has_key($beanstalkd_values, 'beanstalk_console') and $beanstalkd_values['beanstalk_console'] == 1 and $beanstalk_console_webroot_location != undef and $beanstalkd_php_installed { + exec { 'delete-beanstalk_console-path-if-not-git-repo': + command => "rm -rf ${beanstalk_console_webroot_location}", + onlyif => "test ! -d ${beanstalk_console_webroot_location}/.git" + } + + vcsrepo { $beanstalk_console_webroot_location: + ensure => present, + provider => git, + source => 'https://github.com/ptrofimov/beanstalk_console.git', + require => Exec['delete-beanstalk_console-path-if-not-git-repo'] + } + } +} + +# Begin rabbitmq + +if $rabbitmq_values == undef { + $rabbitmq_values = hiera('rabbitmq', false) +} + +if $php_values == undef { + $php_values = hiera('php', false) +} + +if has_key($rabbitmq_values, 'install') and $rabbitmq_values['install'] == 1 { + class { 'rabbitmq': + port => $rabbitmq_values['port'] + } + + if is_hash($php_values) and has_key($php_values, 'install') and $php_values['install'] == 1 and ! defined(Php::Pecl::Module['amqp']) { + php_pecl_mod { 'amqp': } + } +} + diff --git a/dev/vagrant/dolibarrdev/puphpet/shell/execute-files.sh b/dev/vagrant/dolibarrdev/puphpet/shell/execute-files.sh new file mode 100644 index 00000000000..6cb58597fd5 --- /dev/null +++ b/dev/vagrant/dolibarrdev/puphpet/shell/execute-files.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +VAGRANT_CORE_FOLDER=$(cat "/.puphpet-stuff/vagrant-core-folder.txt") + +shopt -s nullglob +files=("${VAGRANT_CORE_FOLDER}"/files/exec-once/*) + +if [[ ! -f /.puphpet-stuff/exec-once-ran && (${#files[@]} -gt 0) ]]; then + echo 'Running files in files/exec-once' + find "${VAGRANT_CORE_FOLDER}/files/exec-once" -maxdepth 1 -type f \( ! -iname "empty" \) -exec chmod +x '{}' \; -exec {} \; + echo 'Finished running files in files/exec-once' + echo 'To run again, delete file /.puphpet-stuff/exec-once-ran' + touch /.puphpet-stuff/exec-once-ran +fi + +echo 'Running files in files/exec-always' +find "${VAGRANT_CORE_FOLDER}/files/exec-always" -maxdepth 1 -type f \( ! -iname "empty" \) -exec chmod +x '{}' \; -exec {} \; +echo 'Finished running files in files/exec-always' diff --git a/dev/vagrant/dolibarrdev/puphpet/shell/initial-setup.sh b/dev/vagrant/dolibarrdev/puphpet/shell/initial-setup.sh new file mode 100644 index 00000000000..b6fb27aa6b8 --- /dev/null +++ b/dev/vagrant/dolibarrdev/puphpet/shell/initial-setup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +VAGRANT_CORE_FOLDER=$(echo "$1") + +OS=$(/bin/bash "${VAGRANT_CORE_FOLDER}/shell/os-detect.sh" ID) +CODENAME=$(/bin/bash "${VAGRANT_CORE_FOLDER}/shell/os-detect.sh" CODENAME) + +if [[ ! -d /.puphpet-stuff ]]; then + mkdir /.puphpet-stuff + + echo "${VAGRANT_CORE_FOLDER}" > "/.puphpet-stuff/vagrant-core-folder.txt" + + cat "${VAGRANT_CORE_FOLDER}/shell/self-promotion.txt" + echo "Created directory /.puphpet-stuff" +fi + +if [[ ! -f /.puphpet-stuff/initial-setup-repo-update ]]; then + if [ "${OS}" == 'debian' ] || [ "${OS}" == 'ubuntu' ]; then + echo "Running initial-setup apt-get update" + apt-get update >/dev/null + touch /.puphpet-stuff/initial-setup-repo-update + echo "Finished running initial-setup apt-get update" + elif [[ "${OS}" == 'centos' ]]; then + echo "Running initial-setup yum update" + yum install yum-plugin-fastestmirror -y >/dev/null + yum check-update -y >/dev/null + echo "Finished running initial-setup yum update" + + echo "Updating to Ruby 1.9.3" + yum install centos-release-SCL >/dev/null + yum remove ruby >/dev/null + yum install ruby193 facter hiera ruby193-ruby-irb ruby193-ruby-doc ruby193-rubygem-json ruby193-libyaml >/dev/null + gem update --system >/dev/null + gem install haml >/dev/null + echo "Finished updating to Ruby 1.9.3" + + echo "Installing basic development tools (CentOS)" + yum -y groupinstall "Development Tools" >/dev/null + echo "Finished installing basic development tools (CentOS)" + touch /.puphpet-stuff/initial-setup-repo-update + fi +fi + +if [[ "${OS}" == 'ubuntu' && ("${CODENAME}" == 'lucid' || "${CODENAME}" == 'precise') && ! -f /.puphpet-stuff/ubuntu-required-libraries ]]; then + echo 'Installing basic curl packages (Ubuntu only)' + apt-get install -y libcurl3 libcurl4-gnutls-dev curl >/dev/null + echo 'Finished installing basic curl packages (Ubuntu only)' + + touch /.puphpet-stuff/ubuntu-required-libraries +fi diff --git a/dev/vagrant/dolibarrdev/shell/librarian-puppet-vagrant.sh b/dev/vagrant/dolibarrdev/puphpet/shell/librarian-puppet-vagrant.sh similarity index 65% rename from dev/vagrant/dolibarrdev/shell/librarian-puppet-vagrant.sh rename to dev/vagrant/dolibarrdev/puphpet/shell/librarian-puppet-vagrant.sh index 46569a88424..9c4dc8af238 100644 --- a/dev/vagrant/dolibarrdev/shell/librarian-puppet-vagrant.sh +++ b/dev/vagrant/dolibarrdev/puphpet/shell/librarian-puppet-vagrant.sh @@ -1,7 +1,9 @@ #!/bin/bash -OS=$(/bin/bash /vagrant/shell/os-detect.sh ID) -CODENAME=$(/bin/bash /vagrant/shell/os-detect.sh CODENAME) +VAGRANT_CORE_FOLDER=$(cat "/.puphpet-stuff/vagrant-core-folder.txt") + +OS=$(/bin/bash "${VAGRANT_CORE_FOLDER}/shell/os-detect.sh" ID) +CODENAME=$(/bin/bash "${VAGRANT_CORE_FOLDER}/shell/os-detect.sh" CODENAME) # Directory in which librarian-puppet should manage its modules directory PUPPET_DIR=/etc/puppet/ @@ -9,7 +11,7 @@ PUPPET_DIR=/etc/puppet/ $(which git > /dev/null 2>&1) FOUND_GIT=$? -if [ "$FOUND_GIT" -ne '0' ] && [ ! -f /.puphpet-stuff/librarian-puppet-installed ]; then +if [ "${FOUND_GIT}" -ne '0' ] && [ ! -f /.puphpet-stuff/librarian-puppet-installed ]; then $(which apt-get > /dev/null 2>&1) FOUND_APT=$? $(which yum > /dev/null 2>&1) @@ -27,15 +29,15 @@ if [ "$FOUND_GIT" -ne '0' ] && [ ! -f /.puphpet-stuff/librarian-puppet-installed echo 'Finished installing git' fi -if [[ ! -d "$PUPPET_DIR" ]]; then - mkdir -p "$PUPPET_DIR" - echo "Created directory $PUPPET_DIR" +if [[ ! -d "${PUPPET_DIR}" ]]; then + mkdir -p "${PUPPET_DIR}" + echo "Created directory ${PUPPET_DIR}" fi -cp "/vagrant/puppet/Puppetfile" "$PUPPET_DIR" +cp "${VAGRANT_CORE_FOLDER}/puppet/Puppetfile" "${PUPPET_DIR}" echo "Copied Puppetfile" -if [ "$OS" == 'debian' ] || [ "$OS" == 'ubuntu' ]; then +if [ "${OS}" == 'debian' ] || [ "${OS}" == 'ubuntu' ]; then if [[ ! -f /.puphpet-stuff/librarian-base-packages ]]; then echo 'Installing base packages for librarian' apt-get install -y build-essential ruby-dev >/dev/null @@ -45,7 +47,7 @@ if [ "$OS" == 'debian' ] || [ "$OS" == 'ubuntu' ]; then fi fi -if [ "$OS" == 'ubuntu' ]; then +if [ "${OS}" == 'ubuntu' ]; then if [[ ! -f /.puphpet-stuff/librarian-libgemplugin-ruby ]]; then echo 'Updating libgemplugin-ruby (Ubuntu only)' apt-get install -y libgemplugin-ruby >/dev/null @@ -54,7 +56,7 @@ if [ "$OS" == 'ubuntu' ]; then touch /.puphpet-stuff/librarian-libgemplugin-ruby fi - if [ "$CODENAME" == 'lucid' ] && [ ! -f /.puphpet-stuff/librarian-rubygems-update ]; then + if [ "${CODENAME}" == 'lucid' ] && [ ! -f /.puphpet-stuff/librarian-rubygems-update ]; then echo 'Updating rubygems (Ubuntu Lucid only)' echo 'Ignore all "conflicting chdir" errors!' gem install rubygems-update >/dev/null @@ -71,12 +73,17 @@ if [[ ! -f /.puphpet-stuff/librarian-puppet-installed ]]; then echo 'Finished installing librarian-puppet' echo 'Running initial librarian-puppet' - cd "$PUPPET_DIR" && librarian-puppet install --clean >/dev/null + cd "${PUPPET_DIR}" && librarian-puppet install --clean >/dev/null echo 'Finished running initial librarian-puppet' touch /.puphpet-stuff/librarian-puppet-installed else echo 'Running update librarian-puppet' - cd "$PUPPET_DIR" && librarian-puppet update >/dev/null + cd "${PUPPET_DIR}" && librarian-puppet update >/dev/null echo 'Finished running update librarian-puppet' fi + +echo "Replacing puppetlabs-git module with custom" +rm -rf /etc/puppet/modules/git +git clone https://github.com/puphpet/puppetlabs-git.git /etc/puppet/modules/git +echo "Finished replacing puppetlabs-git module with custom" diff --git a/dev/vagrant/dolibarrdev/shell/os-detect.sh b/dev/vagrant/dolibarrdev/puphpet/shell/os-detect.sh similarity index 85% rename from dev/vagrant/dolibarrdev/shell/os-detect.sh rename to dev/vagrant/dolibarrdev/puphpet/shell/os-detect.sh index 07d2adb4fd3..a521f442798 100644 --- a/dev/vagrant/dolibarrdev/shell/os-detect.sh +++ b/dev/vagrant/dolibarrdev/puphpet/shell/os-detect.sh @@ -9,7 +9,7 @@ ID="unknown" CODENAME="unknown" RELEASE="unknown" -if [ "$OS" == "Linux" ]; then +if [ "${OS}" == "Linux" ]; then # detect centos grep "centos" /etc/issue -i -q if [ $? = '0' ]; then @@ -36,12 +36,12 @@ fi declare -A info -info[id]=$(echo "$ID" | tr '[A-Z]' '[a-z]') -info[codename]=$(echo "$CODENAME" | tr '[A-Z]' '[a-z]') -info[release]=$(echo "$RELEASE" | tr '[A-Z]' '[a-z]') +info[id]=$(echo "${ID}" | tr '[A-Z]' '[a-z]') +info[codename]=$(echo "${CODENAME}" | tr '[A-Z]' '[a-z]') +info[release]=$(echo "${RELEASE}" | tr '[A-Z]' '[a-z]') if [ "$TYPE" ] ; then - echo "${info[$TYPE]}" + echo "${info[${TYPE}]}" else echo -e "ID\t${info[id]}" echo -e "CODENAME\t${info[codename]}" diff --git a/dev/vagrant/dolibarrdev/shell/self-promotion.txt b/dev/vagrant/dolibarrdev/puphpet/shell/self-promotion.txt similarity index 100% rename from dev/vagrant/dolibarrdev/shell/self-promotion.txt rename to dev/vagrant/dolibarrdev/puphpet/shell/self-promotion.txt diff --git a/dev/vagrant/dolibarrdev/shell/update-puppet.sh b/dev/vagrant/dolibarrdev/puphpet/shell/update-puppet.sh similarity index 70% rename from dev/vagrant/dolibarrdev/shell/update-puppet.sh rename to dev/vagrant/dolibarrdev/puphpet/shell/update-puppet.sh index 128707c8292..13eb88d4870 100644 --- a/dev/vagrant/dolibarrdev/shell/update-puppet.sh +++ b/dev/vagrant/dolibarrdev/puphpet/shell/update-puppet.sh @@ -1,13 +1,15 @@ #!/bin/bash -OS=$(/bin/bash /vagrant/shell/os-detect.sh ID) -RELEASE=$(/bin/bash /vagrant/shell/os-detect.sh RELEASE) -CODENAME=$(/bin/bash /vagrant/shell/os-detect.sh CODENAME) +VAGRANT_CORE_FOLDER=$(cat "/.puphpet-stuff/vagrant-core-folder.txt") + +OS=$(/bin/bash "${VAGRANT_CORE_FOLDER}/shell/os-detect.sh" ID) +RELEASE=$(/bin/bash "${VAGRANT_CORE_FOLDER}/shell/os-detect.sh" RELEASE) +CODENAME=$(/bin/bash "${VAGRANT_CORE_FOLDER}/shell/os-detect.sh" CODENAME) if [[ ! -f /.puphpet-stuff/update-puppet ]]; then - if [ "$OS" == 'debian' ] || [ "$OS" == 'ubuntu' ]; then + if [ "${OS}" == 'debian' ] || [ "${OS}" == 'ubuntu' ]; then echo "Downloading http://apt.puppetlabs.com/puppetlabs-release-${CODENAME}.deb" - wget --quiet --tries=5 --timeout=10 -O "/.puphpet-stuff/puppetlabs-release-${CODENAME}.deb" "http://apt.puppetlabs.com/puppetlabs-release-${CODENAME}.deb" + wget --quiet --tries=5 --connect-timeout=10 -O "/.puphpet-stuff/puppetlabs-release-${CODENAME}.deb" "http://apt.puppetlabs.com/puppetlabs-release-${CODENAME}.deb" echo "Finished downloading http://apt.puppetlabs.com/puppetlabs-release-${CODENAME}.deb" dpkg -i "/.puphpet-stuff/puppetlabs-release-${CODENAME}.deb" >/dev/null @@ -19,11 +21,11 @@ if [[ ! -f /.puphpet-stuff/update-puppet ]]; then echo "Updating Puppet to latest version" apt-get -y install puppet >/dev/null PUPPET_VERSION=$(puppet help | grep 'Puppet v') - echo "Finished updating puppet to latest version: $PUPPET_VERSION" + echo "Finished updating puppet to latest version: ${PUPPET_VERSION}" touch /.puphpet-stuff/update-puppet echo "Created empty file /.puphpet-stuff/update-puppet" - elif [ "$OS" == 'centos' ]; then + elif [ "${OS}" == 'centos' ]; then echo "Downloading http://yum.puppetlabs.com/el/${RELEASE}/products/x86_64/puppetlabs-release-6-7.noarch.rpm" yum -y --nogpgcheck install "http://yum.puppetlabs.com/el/${RELEASE}/products/x86_64/puppetlabs-release-6-7.noarch.rpm" >/dev/null echo "Finished downloading http://yum.puppetlabs.com/el/${RELEASE}/products/x86_64/puppetlabs-release-6-7.noarch.rpm" @@ -35,7 +37,7 @@ if [[ ! -f /.puphpet-stuff/update-puppet ]]; then echo "Installing/Updating Puppet to latest version" yum -y install puppet >/dev/null PUPPET_VERSION=$(puppet help | grep 'Puppet v') - echo "Finished installing/updating puppet to latest version: $PUPPET_VERSION" + echo "Finished installing/updating puppet to latest version: ${PUPPET_VERSION}" touch /.puphpet-stuff/update-puppet echo "Created empty file /.puphpet-stuff/update-puppet" diff --git a/dev/vagrant/dolibarrdev/puppet/Puppetfile b/dev/vagrant/dolibarrdev/puppet/Puppetfile deleted file mode 100644 index 252ae8e32cf..00000000000 --- a/dev/vagrant/dolibarrdev/puppet/Puppetfile +++ /dev/null @@ -1,13 +0,0 @@ -forge "http://forge.puppetlabs.com" -mod 'stdlib', :git => 'git://github.com/puphpet/puppetlabs-stdlib.git' -mod 'concat', :git => 'git://github.com/puphpet/puppetlabs-concat.git' -mod 'apt', :git => 'git://github.com/puphpet/puppetlabs-apt.git' -mod 'yum', :git => 'git://github.com/puphpet/puppet-yum.git' -mod 'vcsrepo', :git => 'git://github.com/puphpet/puppetlabs-vcsrepo.git' -mod 'ntp', :git => 'git://github.com/puphpet/puppetlabs-ntp.git' -mod 'iptables', :git => 'git://github.com/puphpet/puppet-iptables.git' -mod 'apache', :git => 'git://github.com/puphpet/puppetlabs-apache.git' -mod 'php', :git => 'git://github.com/puphpet/puppet-php.git' -mod 'composer', :git => 'git://github.com/puphpet/puppet-composer.git' -mod 'puphpet', :git => 'git://github.com/puphpet/puppet-puphpet.git' -mod 'mysql', :git => 'git://github.com/puphpet/puppetlabs-mysql.git' diff --git a/dev/vagrant/dolibarrdev/puppet/manifests/default.pp b/dev/vagrant/dolibarrdev/puppet/manifests/default.pp deleted file mode 100644 index f3fd5a6f930..00000000000 --- a/dev/vagrant/dolibarrdev/puppet/manifests/default.pp +++ /dev/null @@ -1,541 +0,0 @@ -## Begin Server manifest - -if $server_values == undef { - $server_values = hiera('server', false) -} - -# Ensure the time is accurate, reducing the possibilities of apt repositories -# failing for invalid certificates -include '::ntp' - -Exec { path => [ '/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/' ] } -File { owner => 0, group => 0, mode => 0644 } - -group { 'puppet': ensure => present } -group { 'www-data': ensure => present } - -user { $::ssh_username: - shell => '/bin/bash', - home => "/home/${::ssh_username}", - ensure => present -} - -user { ['apache', 'nginx', 'httpd', 'www-data']: - shell => '/bin/bash', - ensure => present, - groups => 'www-data', - require => Group['www-data'] -} - -file { "/home/${::ssh_username}": - ensure => directory, - owner => $::ssh_username, -} - -# copy dot files to ssh user's home directory -exec { 'dotfiles': - cwd => "/home/${::ssh_username}", - command => "cp -r /vagrant/files/dot/.[a-zA-Z0-9]* /home/${::ssh_username}/ && chown -R ${::ssh_username} /home/${::ssh_username}/.[a-zA-Z0-9]*", - onlyif => "test -d /vagrant/files/dot", - require => User[$::ssh_username] -} - -case $::osfamily { - # debian, ubuntu - 'debian': { - class { 'apt': } - - Class['::apt::update'] -> Package <| - title != 'python-software-properties' - and title != 'software-properties-common' - |> - - ensure_packages( ['augeas-tools'] ) - } - # redhat, centos - 'redhat': { - class { 'yum': extrarepo => ['epel'] } - - Class['::yum'] -> Yum::Managed_yumrepo <| |> -> Package <| |> - - exec { 'bash_git': - cwd => "/home/${::ssh_username}", - command => "curl https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh > /home/${::ssh_username}/.bash_git", - creates => "/home/${::ssh_username}/.bash_git" - } - - file_line { 'link ~/.bash_git': - ensure => present, - line => 'if [ -f ~/.bash_git ] ; then source ~/.bash_git; fi', - path => "/home/${::ssh_username}/.bash_profile", - require => [ - Exec['dotfiles'], - Exec['bash_git'], - ] - } - - file_line { 'link ~/.bash_aliases': - ensure => present, - line => 'if [ -f ~/.bash_aliases ] ; then source ~/.bash_aliases; fi', - path => "/home/${::ssh_username}/.bash_profile", - require => [ - File_line['link ~/.bash_git'], - ] - } - - ensure_packages( ['augeas'] ) - } -} - -if $php_values == undef { - $php_values = hiera('php', false) -} - -case $::operatingsystem { - 'debian': { - add_dotdeb { 'packages.dotdeb.org': release => $lsbdistcodename } - - if is_hash($php_values) { - # Debian Squeeze 6.0 can do PHP 5.3 (default) and 5.4 - if $lsbdistcodename == 'squeeze' and $php_values['version'] == '54' { - add_dotdeb { 'packages.dotdeb.org-php54': release => 'squeeze-php54' } - } - # Debian Wheezy 7.0 can do PHP 5.4 (default) and 5.5 - elsif $lsbdistcodename == 'wheezy' and $php_values['version'] == '55' { - add_dotdeb { 'packages.dotdeb.org-php55': release => 'wheezy-php55' } - } - } - } - 'ubuntu': { - apt::key { '4F4EA0AAE5267A6C': } - - if is_hash($php_values) { - # Ubuntu Lucid 10.04, Precise 12.04, Quantal 12.10 and Raring 13.04 can do PHP 5.3 (default <= 12.10) and 5.4 (default <= 13.04) - if $lsbdistcodename in ['lucid', 'precise', 'quantal', 'raring'] and $php_values['version'] == '54' { - if $lsbdistcodename == 'lucid' { - apt::ppa { 'ppa:ondrej/php5-oldstable': require => Apt::Key['4F4EA0AAE5267A6C'], options => '' } - } else { - apt::ppa { 'ppa:ondrej/php5-oldstable': require => Apt::Key['4F4EA0AAE5267A6C'] } - } - } - # Ubuntu Precise 12.04, Quantal 12.10 and Raring 13.04 can do PHP 5.5 - elsif $lsbdistcodename in ['precise', 'quantal', 'raring'] and $php_values['version'] == '55' { - apt::ppa { 'ppa:ondrej/php5': require => Apt::Key['4F4EA0AAE5267A6C'] } - } - elsif $lsbdistcodename in ['lucid'] and $php_values['version'] == '55' { - err('You have chosen to install PHP 5.5 on Ubuntu 10.04 Lucid. This will probably not work!') - } - } - } - 'redhat', 'centos': { - if is_hash($php_values) { - if $php_values['version'] == '54' { - class { 'yum::repo::remi': } - } - # remi_php55 requires the remi repo as well - elsif $php_values['version'] == '55' { - class { 'yum::repo::remi': } - class { 'yum::repo::remi_php55': } - } - } - } -} - -if !empty($server_values['packages']) { - ensure_packages( $server_values['packages'] ) -} - -define add_dotdeb ($release){ - apt::source { $name: - location => 'http://packages.dotdeb.org', - release => $release, - repos => 'all', - required_packages => 'debian-keyring debian-archive-keyring', - key => '89DF5277', - key_server => 'keys.gnupg.net', - include_src => true - } -} - -## Begin Apache manifest - -if $yaml_values == undef { - $yaml_values = loadyaml('/vagrant/puppet/hieradata/common.yaml') -} - -if $apache_values == undef { - $apache_values = $yaml_values['apache'] -} - -include puphpet::params - -$webroot_location = $puphpet::params::apache_webroot_location - -exec { "exec mkdir -p ${webroot_location}": - command => "mkdir -p ${webroot_location}", - onlyif => "test -d ${webroot_location}", -} - -if ! defined(File[$webroot_location]) { - file { $webroot_location: - ensure => directory, - group => 'www-data', - mode => 0775, - require => [ - Exec["exec mkdir -p ${webroot_location}"], - Group['www-data'] - ] - } -} - -class { 'apache': - user => $apache_values['user'], - group => $apache_values['group'], - default_vhost => $apache_values['default_vhost'], - mpm_module => $apache_values['mpm_module'], - manage_user => false, - manage_group => false -} - -if $::osfamily == 'debian' { - case $apache_values['mpm_module'] { - 'prefork': { ensure_packages( ['apache2-mpm-prefork'] ) } - 'worker': { ensure_packages( ['apache2-mpm-worker'] ) } - 'event': { ensure_packages( ['apache2-mpm-event'] ) } - } -} elsif $::osfamily == 'redhat' and ! defined(Iptables::Allow['tcp/80']) { - iptables::allow { 'tcp/80': - port => '80', - protocol => 'tcp' - } -} - -create_resources(apache::vhost, $apache_values['vhosts']) - -define apache_mod { - if ! defined(Class["apache::mod::${name}"]) { - class { "apache::mod::${name}": } - } -} - -if count($apache_values['modules']) > 0 { - apache_mod { $apache_values['modules']: } -} - -## Begin PHP manifest - -if $php_values == undef { - $php_values = hiera('php', false) -} - -if $apache_values == undef { - $apache_values = hiera('apache', false) -} - -if $nginx_values == undef { - $nginx_values = hiera('nginx', false) -} - -Class['Php'] -> Class['Php::Devel'] -> Php::Module <| |> -> Php::Pear::Module <| |> -> Php::Pecl::Module <| |> - -if $php_prefix == undef { - $php_prefix = $::operatingsystem ? { - /(?i:Ubuntu|Debian|Mint|SLES|OpenSuSE)/ => 'php5-', - default => 'php-', - } -} - -if $php_fpm_ini == undef { - $php_fpm_ini = $::operatingsystem ? { - /(?i:Ubuntu|Debian|Mint|SLES|OpenSuSE)/ => '/etc/php5/fpm/php.ini', - default => '/etc/php.ini', - } -} - -if is_hash($apache_values) { - include apache::params - - $php_webserver_service = 'httpd' - $php_webserver_user = $apache::params::user - - class { 'php': - service => $php_webserver_service - } -} elsif is_hash($nginx_values) { - include nginx::params - - $php_webserver_service = "${php_prefix}fpm" - $php_webserver_user = $nginx::params::nx_daemon_user - - class { 'php': - package => $php_webserver_service, - service => $php_webserver_service, - service_autorestart => false, - config_file => $php_fpm_ini, - } - - service { $php_webserver_service: - ensure => running, - enable => true, - hasrestart => true, - hasstatus => true, - require => Package[$php_webserver_service] - } -} - -class { 'php::devel': } - -if count($php_values['modules']['php']) > 0 { - php_mod { $php_values['modules']['php']:; } -} -if count($php_values['modules']['pear']) > 0 { - php_pear_mod { $php_values['modules']['pear']:; } -} -if count($php_values['modules']['pecl']) > 0 { - php_pecl_mod { $php_values['modules']['pecl']:; } -} -if count($php_values['ini']) > 0 { - $php_values['ini'].each { |$key, $value| - puphpet::ini { $key: - entry => "CUSTOM/${key}", - value => $value, - php_version => $php_values['version'], - webserver => $php_webserver_service - } - } - - if $php_values['ini']['session.save_path'] != undef { - exec {"mkdir -p ${php_values['ini']['session.save_path']}": - onlyif => "test ! -d ${php_values['ini']['session.save_path']}", - } - - file { $php_values['ini']['session.save_path']: - ensure => directory, - group => 'www-data', - mode => 0775, - require => Exec["mkdir -p ${php_values['ini']['session.save_path']}"] - } - } -} - -puphpet::ini { $key: - entry => 'CUSTOM/date.timezone', - value => $php_values['timezone'], - php_version => $php_values['version'], - webserver => $php_webserver_service -} - -define php_mod { - php::module { $name: } -} -define php_pear_mod { - php::pear::module { $name: use_package => false } -} -define php_pecl_mod { - php::pecl::module { $name: use_package => false } -} - -if $php_values['composer'] == 1 { - class { 'composer': - target_dir => '/usr/local/bin', - composer_file => 'composer', - download_method => 'curl', - logoutput => false, - tmp_path => '/tmp', - php_package => "${php::params::module_prefix}cli", - curl_package => 'curl', - suhosin_enabled => false, - } -} - -if $xdebug_values == undef { - $xdebug_values = hiera('xdebug', false) -} - -if is_hash($apache_values) { - $xdebug_webserver_service = 'httpd' -} elsif is_hash($nginx_values) { - $xdebug_webserver_service = 'nginx' -} else { - $xdebug_webserver_service = undef -} - -if $xdebug_values['install'] != undef and $xdebug_values['install'] == 1 { - class { 'puphpet::xdebug': - webserver => $xdebug_webserver_service - } - - if is_hash($xdebug_values['settings']) and count($xdebug_values['settings']) > 0 { - $xdebug_values['settings'].each { |$key, $value| - puphpet::ini { $key: - entry => "XDEBUG/${key}", - value => $value, - php_version => $php_values['version'], - webserver => $xdebug_webserver_service - } - } - } -} - -## Begin Xhprof manifest - -if $xhprof_values == undef { - $xhprof_values = hiera('xhprof', false) -} - -if is_hash($xhprof_values) and $xhprof_values['install'] == 1 { - $xhprofPath = $xhprof_values['location'] - - php::pecl::module { 'xhprof': - use_package => false, - preferred_state => 'beta', - } - - exec { 'delete-xhprof-path-if-not-git-repo': - command => "rm -rf ${xhprofPath}", - onlyif => "test ! -d ${xhprofPath}/.git" - } - - vcsrepo { $xhprofPath: - ensure => present, - provider => git, - source => 'https://github.com/facebook/xhprof.git', - require => Exec['delete-xhprof-path-if-not-git-repo'] - } - - file { "${xhprofPath}/xhprof_html": - ensure => directory, - mode => 0775, - require => Vcsrepo[$xhprofPath] - } - - composer::exec { 'xhprof-composer-run': - cmd => 'install', - cwd => $xhprofPath, - require => [ - Class['composer'], - File["${xhprofPath}/xhprof_html"] - ] - } -} - -## Begin MySQL manifest - -if $mysql_values == undef { - $mysql_values = hiera('mysql', false) -} - -if $php_values == undef { - $php_values = hiera('php', false) -} - -if $apache_values == undef { - $apache_values = hiera('apache', false) -} - -if $nginx_values == undef { - $nginx_values = hiera('nginx', false) -} - -if $mysql_values['root_password'] { - class { 'mysql::server': - root_password => $mysql_values['root_password'], - } - - if is_hash($mysql_values['databases']) and count($mysql_values['databases']) > 0 { - create_resources(mysql_db, $mysql_values['databases']) - } - - if is_hash($php_values) { - if $::osfamily == 'redhat' and $php_values['version'] == '53' and ! defined(Php::Module['mysql']) { - php::module { 'mysql': } - } elsif ! defined(Php::Module['mysqlnd']) { - php::module { 'mysqlnd': } - } - } -} - -define mysql_db ( - $user, - $password, - $host, - $grant = [], - $sql_file = false -) { - if $name == '' or $password == '' or $host == '' { - fail( 'MySQL DB requires that name, password and host be set. Please check your settings!' ) - } - - mysql::db { $name: - user => $user, - password => $password, - host => $host, - grant => $grant, - sql => $sql_file, - } -} - -if $mysql_values['phpmyadmin'] == 1 and is_hash($php_values) { - if $::osfamily == 'debian' { - if $::operatingsystem == 'ubuntu' { - apt::key { '80E7349A06ED541C': } - apt::ppa { 'ppa:nijel/phpmyadmin': require => Apt::Key['80E7349A06ED541C'] } - } - - $phpMyAdmin_package = 'phpmyadmin' - $phpMyAdmin_folder = 'phpmyadmin' - } elsif $::osfamily == 'redhat' { - $phpMyAdmin_package = 'phpMyAdmin.noarch' - $phpMyAdmin_folder = 'phpMyAdmin' - } - - if ! defined(Package[$phpMyAdmin_package]) { - package { $phpMyAdmin_package: - require => Class['mysql::server'] - } - } - - include puphpet::params - - if is_hash($apache_values) { - $mysql_webroot_location = $puphpet::params::apache_webroot_location - } elsif is_hash($nginx_values) { - $mysql_webroot_location = $puphpet::params::nginx_webroot_location - - mysql_nginx_default_conf { 'override_default_conf': - webroot => $mysql_webroot_location - } - } - - file { "${mysql_webroot_location}/phpmyadmin": - target => "/usr/share/${phpMyAdmin_folder}", - ensure => link, - replace => 'no', - require => [ - Package[$phpMyAdmin_package], - File[$mysql_webroot_location] - ] - } -} - -define mysql_nginx_default_conf ( - $webroot -) { - if $php5_fpm_sock == undef { - $php5_fpm_sock = '/var/run/php5-fpm.sock' - } - - if $fastcgi_pass == undef { - $fastcgi_pass = $php_values['version'] ? { - undef => null, - '53' => '127.0.0.1:9000', - default => "unix:${php5_fpm_sock}" - } - } - - class { 'puphpet::nginx': - fastcgi_pass => $fastcgi_pass, - notify => Class['nginx::service'], - } -} - diff --git a/dev/vagrant/dolibarrdev/shell/initial-setup.sh b/dev/vagrant/dolibarrdev/shell/initial-setup.sh deleted file mode 100644 index 724963a066d..00000000000 --- a/dev/vagrant/dolibarrdev/shell/initial-setup.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -OS=$(/bin/bash /vagrant/shell/os-detect.sh ID) -CODENAME=$(/bin/bash /vagrant/shell/os-detect.sh CODENAME) - -if [[ ! -d /.puphpet-stuff ]]; then - cat /vagrant/shell/self-promotion.txt - mkdir /.puphpet-stuff - echo "Created directory /.puphpet-stuff" -fi - -if [[ ! -f /.puphpet-stuff/initial-setup-repo-update ]]; then - if [ "$OS" == 'debian' ] || [ "$OS" == 'ubuntu' ]; then - echo "Running initial-setup apt-get update" - apt-get update >/dev/null - touch /.puphpet-stuff/initial-setup-repo-update - echo "Finished running initial-setup apt-get update" - elif [[ "$OS" == 'centos' ]]; then - echo "Running initial-setup yum update" - yum update -y >/dev/null - echo "Finished running initial-setup yum update" - - echo "Installing basic development tools (CentOS)" - yum -y groupinstall "Development Tools" >/dev/null - echo "Finished installing basic development tools (CentOS)" - touch /.puphpet-stuff/initial-setup-repo-update - fi -fi - -if [[ "$OS" == 'ubuntu' && ("$CODENAME" == 'lucid' || "$CODENAME" == 'precise') && ! -f /.puphpet-stuff/ubuntu-required-libraries ]]; then - echo 'Installing basic curl packages (Ubuntu only)' - apt-get install -y libcurl3 libcurl4-gnutls-dev >/dev/null - echo 'Finished installing basic curl packages (Ubuntu only)' - - touch /.puphpet-stuff/ubuntu-required-libraries -fi