Search code examples
phpwordpressvagrantpuppetpuphpet

puphpet install wordpress on ubuntu server


I am wondering if anyone has attempted to automate the deployment of wordpress and puphpet. I am not to familiar with puphpet but I know it uses the hiera.yaml file along with the manifets and modules folder. I attempted something simple

I added this to config.yaml file and imported the wordpress module from vagrant press

wordpress:
    install: '1'

It looks like I may need to add something to the main manifest.pp file that puphpet generates. If anyone has attempted something like this I would appreciate any advice. Or is it better to just use yeoman instead?

Update

I add this to the config.yaml file

wordpress:
    install: '1'

Then in the manifest.pp file I added this at the bottom form (wordpress vagrant box) and it seems to work:

# Begin wordpess

if $wordpress_values == undef {

  $wordpress_values = hiera('wordpress', false)

  if hash_key_equals($wordpress_values, 'install', 1) {

        # Download WordPress
        exec {"download_wordpress":
          command => "wget http://wordpress.org/latest.tar.gz",
          cwd     => "/tmp",
          creates => "/tmp/latest.tar.gz",
          path    => ["/usr/bin", "/bin", "/usr/local/bin"],
          unless  => "test -f /var/www/index.php",
        }

        # Extract WordPress
        exec {"extract_wordpress":
          command => "tar xzf /tmp/latest.tar.gz",
          cwd     => "/tmp",
          creates => "/tmp/wordpress",
          path    => ["/usr/bin", "/usr/local/bin", "/bin"],
          require => Exec["download_wordpress"],
          unless  => "test -f /var/www/index.php",
        }

        # Install WordPress
        exec {"install_wordpress":
          command => "cp -r /tmp/wordpress/* /var/www/wordpress",
          cwd     => "/tmp",
          path    => ["/usr/bin", "/usr/local/bin", "/bin", "/usr/local/sbin", "/usr/sbin", "/sbin"],
          require => Exec["extract_wordpress"],
          unless  => "test -f /home/www/index.php",
        }
  }

}

Solution

  • PuPHPet uses hiera but not in the traditional Puppet way. You still need to actually create the Puppet code that interacts with the hiera values.