define wordpress::instance (
  $db_name,
  $db_user,
  $install_dir          = '/srv/wordpress/site/devel/root',
  $install_url          = 'http://wordpress.org',
  $version              = '4.1',
  $create_db            = true,
  $create_db_user       = true,
  $db_host              = 'localhost',
  $db_password          = 'password',
  $wp_owner             = 'puppet',
  $wp_group             = '0',
  $wp_lang              = '',
  $wp_config_content    = undef,
  $wp_additional_config = 'DEFAULT',
  $wp_table_prefix      = 'wp_de15vel',
  $wp_multisite         = false,
  $wp_site_domain       = '',
  $wp_debug             = false,
) {

  # Creating database via Puppet plugin
  wordpress::instance::db { "${db_host}/${db_name}":
    create_db      => $create_db,
    create_db_user => $create_db_user,
    db_name        => $db_name,
    db_host        => $db_host,
    db_user        => $db_user,
    db_password    => $db_password,
  }
  
  # Creating Wordpress instance
  wordpress::instance::app { $install_dir:
    install_dir          => $install_dir,
    install_url          => $install_url,
    version              => $version,
    db_name              => $db_name,
    db_host              => $db_host,
    db_user              => $db_user,
    db_password          => $db_password,
    wp_owner             => $wp_owner,
    wp_group             => $wp_group,
    wp_lang              => $wp_lang,
    wp_config_content    => $wp_config_content,
    wp_additional_config => $wp_additional_config,
    wp_table_prefix      => $wp_table_prefix,
    wp_multisite         => $wp_multisite,
    wp_site_domain       => $wp_site_domain,
    wp_debug             => $wp_debug,
  }
}
