Add groups-dev.openstack.org node
Add a groups-dev node to openstack infra, based on drupal environment. This node checks out the repository: https://git.openstack.org/openstack-infra/groups Build a new deployment from scratch, including drush make distbuild and drush si auto-installation features. Change-Id: I71eef1c14724ceb13a896ff768923148dedcc2ef
This commit is contained in:
parent
99b39318ed
commit
648a8af52f
@ -34,6 +34,7 @@ MODULES["puppetlabs-stdlib"]="3.2.0"
|
||||
MODULES["saz-memcached"]="2.0.2"
|
||||
MODULES["saz-gearman"]="2.0.1"
|
||||
MODULES["spiette-selinux"]="0.5.1"
|
||||
MODULES["rafaelfc-pear"]="1.0.3"
|
||||
|
||||
MODULE_LIST=`puppet module list`
|
||||
|
||||
|
@ -152,6 +152,15 @@ node 'groups.openstack.org' {
|
||||
}
|
||||
}
|
||||
|
||||
node 'groups-dev.openstack.org' {
|
||||
class { 'openstack_project::groups_dev':
|
||||
sysadmins => hiera('sysadmins'),
|
||||
site_admin_password => hiera('groups_dev_site_admin_password'),
|
||||
site_mysql_host => hiera('groups_dev_site_mysql_host'),
|
||||
site_mysql_password => hiera('groups_dev_site_mysql_password'),
|
||||
}
|
||||
}
|
||||
|
||||
node 'lists.openstack.org' {
|
||||
class { 'openstack_project::lists':
|
||||
listadmins => hiera('listadmins'),
|
||||
|
120
modules/drupal/README.md
Normal file
120
modules/drupal/README.md
Normal file
@ -0,0 +1,120 @@
|
||||
# License
|
||||
|
||||
Copyright 2013 OpenStack Foundation
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
not use this file except in compliance with the License. You may obtain
|
||||
a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
# Drupal module for Puppet
|
||||
|
||||
This module manages Drupal on Linux distros.
|
||||
|
||||
## Description
|
||||
|
||||
## Usage
|
||||
|
||||
### drupal
|
||||
Install and configure a Drupal site, including Apache vhost entry, MySQL
|
||||
database, Pear and drush cli tool.
|
||||
|
||||
Example:
|
||||
|
||||
class { 'drupal':
|
||||
site_name => 'www.example.com',
|
||||
site_docroot => '/srv/vhosts/example.com',
|
||||
site_mysql_host => 'localhost',
|
||||
site_mysql_user => 'myuser',
|
||||
site_mysql_password => 's3cretPassw0rd',
|
||||
site_mysql_database => 'example',
|
||||
site_vhost_root => '/srv/vhosts',
|
||||
site_staging_tarball => 'example-dev.tar.gz',
|
||||
site_admin_password => 'adminadmin',
|
||||
site_build_reponame => 'example-master',
|
||||
site_makefile => 'build-example.make',
|
||||
site_repo_url => 'https://git.example.com/repo/example',
|
||||
site_profile => 'standard',
|
||||
site_base_url => 'http://example.com',
|
||||
...
|
||||
}
|
||||
|
||||
Build process:
|
||||
- build a distribution tarball (drupal::distbuild)
|
||||
- deploy a site from scratch (drupal:sitedeploy)
|
||||
|
||||
### drupal::distbuild
|
||||
Build a distribution from a git repository, using drush make command. Check
|
||||
out the git repository under site_sandbox_root and compare head commit with
|
||||
latest deployed version. If version is different, clean up the
|
||||
site_deploy_flagfile, and drush make building process start. The flag file
|
||||
site_build_flagfile always contains the version of built repository.
|
||||
|
||||
Example:
|
||||
|
||||
distbuild { "distbuild-${site_name}":
|
||||
site_sandbox_root => '/srv/sandbox',
|
||||
site_staging_root => '/srv/sandbox/release',
|
||||
site_repo_url => 'https://git.example.com/repo/example',
|
||||
site_build_repo_name => 'example-master',
|
||||
site_staging_tarball => 'example-dev.tar.gz',
|
||||
site_build_flagfile => '/tmp/drupal-site-build',
|
||||
site_deploy_flagfile => '/tmp/drupal-site-deploy',
|
||||
site_makefile => 'build-example.make',
|
||||
...
|
||||
}
|
||||
|
||||
Directory structure:
|
||||
/srv/sandbox/example-master local git repository clone
|
||||
build-example.make
|
||||
drupal-org-core.make
|
||||
drupal-org.make
|
||||
example.info
|
||||
example.install
|
||||
example.profile
|
||||
/srv/sandbox/release distribution tarball directory
|
||||
example-dev.tar.gz
|
||||
|
||||
Flag files:
|
||||
/tmp/drupal-site-build
|
||||
Holds the version of information of latest successfull build
|
||||
# pack-refs with: peeled
|
||||
df23bc9510ac8406c33f896f824997a79d20d27d refs/remotes/origin/master
|
||||
|
||||
/tmp/drupal-site-deploy
|
||||
If missing, drupal:sitedeploy triggers a new deployment process.
|
||||
|
||||
### drupal:sitedeploy
|
||||
Deploy and install a new site based on a previously built distribution
|
||||
tarball, using drupal_site_deploy.sh script.
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
sitedeploy { "sitedeploy-${site_name}":
|
||||
site_docroot => '/srv/vhosts/example.com',
|
||||
site_staging_root => '/srv/sandbox/release',
|
||||
site_staging_tarball => 'example-dev.tar.gz',
|
||||
site_deploy_flagfile => '/tmp/drupal-site-deploy',
|
||||
site_name => $site_name,
|
||||
site_profile => 'standard',
|
||||
site_mysql_host => 'localhost',
|
||||
site_mysql_user => 'myuser',
|
||||
site_mysql_password => 's3cretPassw0rd',
|
||||
site_mysql_database => 'example',
|
||||
site_admin_password => 'adminadmin',
|
||||
site_base_url => 'http://example.com',
|
||||
...
|
||||
}
|
||||
|
||||
Directory structure:
|
||||
/srv/vhosts/example.com drupal site root
|
||||
/etc/drupal
|
||||
example.com.config drupal site deploy script configuration
|
||||
|
223
modules/drupal/files/drupal_site_deploy.sh
Normal file
223
modules/drupal/files/drupal_site_deploy.sh
Normal file
@ -0,0 +1,223 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# Drupal site deploy tool. Install and setup Drupal from a distribution file.
|
||||
#
|
||||
# See drupal_site_deploy.sh --help for further parameters and examples.
|
||||
#
|
||||
# Basic deployment flow:
|
||||
# 1. clean-up destination directory (optional)
|
||||
# 2. extract dist tarball to destination with proper permissions,
|
||||
# create settings.php and files directory under sites/default
|
||||
# 3. install drupal with drush si command, setup admin password and
|
||||
# proper filename, and repair sites/default/files ownership
|
||||
# 4. create flag-file that marks successfull installation (optional)
|
||||
|
||||
site_admin_user=admin
|
||||
profile_name=standard
|
||||
file_group=www-data
|
||||
file_owner=ubuntu
|
||||
|
||||
_print_help() {
|
||||
echo "$(basename "$0") -- Deploy and configure a Drupal site from distribution file
|
||||
|
||||
## Global options ##
|
||||
|
||||
-st, --site-tarball <tar-file> source tarball file used for deployment
|
||||
-db, --db-url <db-url> database url: mysql://user:pass@hostname[:port]/dbname
|
||||
-sn, --site-name <sitename> name of the website
|
||||
-su, --site-admin-user <username> username of admin account
|
||||
-sp, --site-admin-password <password> password of admin account
|
||||
-pn, --profile-name <profilename> profile used to install (defaults to standard)
|
||||
-p, --prepare prepare for deployment, but skip the install phase
|
||||
-c, --clean clean target directory
|
||||
-dst, --dest-dir <target-directory> target directory
|
||||
-ff, --flag-file <flagfile> create a flagfile after successfull run
|
||||
-bu, --base-url <base-url> base_url parameter of settings.php
|
||||
-in, --config read parameters from configuration file
|
||||
-fo, --file-owner <user> file owner
|
||||
-fg, --file-group <group> group owner
|
||||
-h, --help display this help
|
||||
|
||||
|
||||
## Examples ##
|
||||
|
||||
install using cli parameters:
|
||||
|
||||
drupal_site_deploy.sh -st drupal-7.23.tar.gz -pn standard \\
|
||||
--db-url mysql://root:pass@localhost:port/dbname \\
|
||||
--site-name drupal-dev.local \\
|
||||
--site-admin-user admin \\
|
||||
--site-admin-password Wr5pUF@f8*Wr
|
||||
|
||||
install using config file params:
|
||||
|
||||
drupal_site_deploy.sh -in l10n-dev.config
|
||||
"
|
||||
}
|
||||
|
||||
_set_args() {
|
||||
while [ "$1" != "" ]; do
|
||||
case $1 in
|
||||
"-st" | "--site-tarball")
|
||||
shift
|
||||
site_tarball=$1
|
||||
;;
|
||||
"-db" | "--db-url")
|
||||
shift
|
||||
db_url=$1
|
||||
;;
|
||||
"-sn" | "--site-name")
|
||||
shift
|
||||
site_name=$1
|
||||
;;
|
||||
"-su" | "--site-admin-user")
|
||||
shift
|
||||
site_admin_user=$1
|
||||
;;
|
||||
"-sp" | "--site-admin-password")
|
||||
shift
|
||||
site_admin_password=$1
|
||||
;;
|
||||
"-pn" | "--profile-name")
|
||||
shift
|
||||
profile_name=$1
|
||||
;;
|
||||
"-p" | "--prepare")
|
||||
is_prepare=true
|
||||
;;
|
||||
"-c" | "--clean")
|
||||
is_clean=true
|
||||
;;
|
||||
"-dst" | "--dest-dir")
|
||||
shift
|
||||
dest_dir=$1
|
||||
;;
|
||||
"-ff" | "--flag-file")
|
||||
shift
|
||||
flag_file=$1
|
||||
;;
|
||||
"-bu" | "--base-url")
|
||||
shift
|
||||
base_url=$1
|
||||
;;
|
||||
"-in" | "--config-file")
|
||||
shift
|
||||
config_rc=$1
|
||||
;;
|
||||
"-fo" | "--file-owner")
|
||||
shift
|
||||
file_owner=$1
|
||||
;;
|
||||
"-fg" | "--file-group")
|
||||
shift
|
||||
file_group=$1
|
||||
;;
|
||||
"-h" | "--help")
|
||||
_print_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
_validate_args() {
|
||||
if [ ! $dest_dir ]; then
|
||||
echo "Error: Mandatory parameter destination directory is missing."
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -d $dest_dir ]; then
|
||||
echo "Error: Invalid destination directory: $dest_dir"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! $site_tarball ]; then
|
||||
echo "Error: Mandatory parameter site tarball is missing."
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f $site_tarball ]; then
|
||||
echo "Error: Invalid site tarball file: $site_tarball"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! $db_url ]; then
|
||||
echo "Error: Mandatory parameter db url is missing."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
_stage_cleanup() {
|
||||
echo "cleanup site directory"
|
||||
rm -rf $dest_dir/*
|
||||
}
|
||||
|
||||
_stage_prepare() {
|
||||
echo "prepare installation"
|
||||
umask 0027
|
||||
tar xfz $site_tarball --strip-components=1 --no-same-permissions -C $dest_dir
|
||||
cp $dest_dir/sites/default/default.settings.php $dest_dir/sites/default/settings.php
|
||||
if [ $base_url ]; then
|
||||
echo "\$base_url='$base_url';" >> $dest_dir/sites/default/settings.php
|
||||
fi
|
||||
mkdir -p $dest_dir/sites/default/files
|
||||
chmod g+rwxs $dest_dir/sites/default/files
|
||||
chown -R $file_owner:$file_group $dest_dir
|
||||
chmod 0664 $dest_dir/sites/default/settings.php
|
||||
umask 0022
|
||||
}
|
||||
|
||||
_stage_install() {
|
||||
echo "install distribution file"
|
||||
save_dir=`pwd`
|
||||
cd $dest_dir
|
||||
drush si -y $profile_name --db-url=$db_url
|
||||
chmod 0440 $dest_dir/sites/default/settings.php
|
||||
chgrp -R www-data $dest_dir/sites/default/files
|
||||
if [ $site_name ]; then
|
||||
drush vset site_name $site_name
|
||||
fi
|
||||
if [ $site_admin_password ]; then
|
||||
drush upwd $site_admin_user --password="$site_admin_password"
|
||||
fi
|
||||
drush features-revert-all -y
|
||||
cd $save_dir
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
_set_args $*
|
||||
|
||||
if [ -f $config_rc ]; then
|
||||
source $config_rc
|
||||
fi
|
||||
|
||||
_validate_args
|
||||
|
||||
if [ $is_clean ]; then
|
||||
_stage_cleanup
|
||||
fi
|
||||
|
||||
_stage_prepare
|
||||
|
||||
if [ ! $is_prepare ]; then
|
||||
_stage_install
|
||||
fi
|
||||
|
||||
if [ $flag_file ]; then
|
||||
touch $flag_file
|
||||
chown root:root $flag_file
|
||||
fi
|
||||
|
||||
echo "sitedeploy completed in $SECONDS seconds."
|
68
modules/drupal/manifests/distbuild.pp
Normal file
68
modules/drupal/manifests/distbuild.pp
Normal file
@ -0,0 +1,68 @@
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# == Define: distbuild
|
||||
#
|
||||
# define to build distribution from git makefile
|
||||
#
|
||||
define drupal::distbuild (
|
||||
$site_sandbox_root = undef,
|
||||
$site_staging_root = undef,
|
||||
$site_repo_url = undef,
|
||||
$site_repo_branch = 'master',
|
||||
$site_build_repo_name = undef,
|
||||
$site_staging_tarball = undef,
|
||||
$site_build_flagfile = undef,
|
||||
$site_deploy_flagfile = undef,
|
||||
$site_makefile = undef,
|
||||
) {
|
||||
file { $site_sandbox_root:
|
||||
ensure => directory,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0755',
|
||||
}
|
||||
|
||||
file { $site_staging_root:
|
||||
ensure => directory,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0755',
|
||||
}
|
||||
|
||||
vcsrepo { "${site_sandbox_root}/${site_build_repo_name}":
|
||||
ensure => latest,
|
||||
provider => git,
|
||||
revision => $site_repo_branch,
|
||||
source => $site_repo_url,
|
||||
}
|
||||
|
||||
exec { 'drupal-build-dist':
|
||||
path => '/usr/bin:/bin',
|
||||
timeout => 900,
|
||||
cwd => "${site_sandbox_root}/${$site_build_repo_name}",
|
||||
command => "rm -rf ${site_staging_root}/${site_staging_tarball} && drush make --tar ${site_makefile} ${site_staging_root}/${site_staging_tarball}",
|
||||
unless => "diff ${site_sandbox_root}/${$site_build_repo_name}/.git/packed-refs ${site_build_flagfile}",
|
||||
require => File[$site_staging_root],
|
||||
subscribe => Vcsrepo["${site_sandbox_root}/${$site_build_repo_name}"],
|
||||
}
|
||||
|
||||
exec { 'drupal-build-dist-post':
|
||||
path => '/usr/bin:/bin',
|
||||
command => "cp ${site_sandbox_root}/${$site_build_repo_name}/.git/packed-refs ${site_build_flagfile} && rm -rf ${site_deploy_flagfile}",
|
||||
unless => "diff ${site_sandbox_root}/${$site_build_repo_name}/.git/packed-refs ${site_build_flagfile}",
|
||||
subscribe => Vcsrepo["${site_sandbox_root}/${$site_build_repo_name}"],
|
||||
require => Exec['drupal-build-dist'],
|
||||
}
|
||||
}
|
163
modules/drupal/manifests/init.pp
Normal file
163
modules/drupal/manifests/init.pp
Normal file
@ -0,0 +1,163 @@
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# == Class: drupal
|
||||
#
|
||||
# A wrapper class to support drupal project integration based on LAMP
|
||||
# environment.
|
||||
#
|
||||
# Actions:
|
||||
# - Prepare apache vhost and create mysql database (optional)
|
||||
# - Build distribution tarball from git repo as a soruce
|
||||
# - Deploy dist tarball and setup Drupal from scratch
|
||||
#
|
||||
# Site parameters:
|
||||
# - site_name: name of the site (FQDN for example)
|
||||
# - site_admin_password: password of drupal admin
|
||||
# - site_docroot: root directory of drupal site
|
||||
# - site_vhost_root: root directory of virtual hosts
|
||||
# - site_create_database: if true, create a new database (default: false)
|
||||
#
|
||||
# Mysql connection:
|
||||
# - mysql_user: mysql user of drupal site
|
||||
# - mysql_password: password of site user
|
||||
# - mysql_database: site database name
|
||||
# - mysql_host: host of mysql server (default: localhost)
|
||||
#
|
||||
# Distribution build process:
|
||||
# - site_sandbox_root: root directory of sandbox where build happens
|
||||
# - site_staging_root: root directory of target tarballs
|
||||
# - site_staging_tarball: target tarball of build process
|
||||
# - site_makefile: installation profile drush makefile
|
||||
# - site_build_reponame: local repository name under sandbox root
|
||||
# - site_repo_url: git repo url of installation profile source
|
||||
# - site_build_flagfile: triggers a rebuild when missing or git head differs
|
||||
#
|
||||
# Deploy process:
|
||||
# - site_profile: installation profile to deploy
|
||||
# - site_deploy_flagfile: triggers a redeploy when this flagfile is missing
|
||||
|
||||
class drupal (
|
||||
$site_name = undef,
|
||||
$site_docroot = undef,
|
||||
$site_mysql_host = 'localhost',
|
||||
$site_mysql_user = undef,
|
||||
$site_mysql_password = undef,
|
||||
$site_mysql_database = undef,
|
||||
$site_vhost_root = '/srv/vhosts',
|
||||
$site_sandbox_root = '/srv/sandbox',
|
||||
$site_staging_root = '/srv/sandbox/release',
|
||||
$site_staging_tarball = '',
|
||||
$site_profile = 'standard',
|
||||
$site_admin_password = undef,
|
||||
$site_build_reponame = undef,
|
||||
$site_makefile = undef,
|
||||
$site_repo_url = undef,
|
||||
$site_build_flagfile = '/tmp/drupal-site-build',
|
||||
$site_deploy_flagfile = '/tmp/drupal-site-deploy',
|
||||
$site_create_database = false,
|
||||
$site_base_url = false,
|
||||
) {
|
||||
include apache
|
||||
include pear
|
||||
|
||||
# setup apache and virtualhosts, enable mod rewrite
|
||||
file { $site_vhost_root:
|
||||
ensure => directory,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0755',
|
||||
}
|
||||
|
||||
apache::vhost { $site_name:
|
||||
port => 80,
|
||||
priority => '50',
|
||||
docroot => $site_docroot,
|
||||
require => File[$site_docroot],
|
||||
template => 'drupal/drupal.vhost.erb',
|
||||
}
|
||||
|
||||
file { $site_docroot:
|
||||
ensure => directory,
|
||||
owner => 'root',
|
||||
group => 'www-data',
|
||||
mode => '0755',
|
||||
require => Package['httpd'],
|
||||
}
|
||||
|
||||
a2mod { 'rewrite':
|
||||
ensure => present,
|
||||
}
|
||||
|
||||
# php packages
|
||||
$drupal_related_packages = [ 'unzip', 'php5-mysql', 'php5-gd', 'php5-cli',
|
||||
'libapache2-mod-php5' ]
|
||||
|
||||
package { $drupal_related_packages:
|
||||
ensure => 'installed',
|
||||
require => Package['httpd'],
|
||||
notify => Service['httpd'],
|
||||
}
|
||||
|
||||
# pear / drush cli tool
|
||||
pear::package { 'PEAR': }
|
||||
pear::package { 'Console_Table': }
|
||||
pear::package { 'drush':
|
||||
version => '5.9.0',
|
||||
repository => 'pear.drush.org',
|
||||
require => Pear::Package['PEAR'],
|
||||
}
|
||||
|
||||
# site mysql database
|
||||
if $site_create_database == true {
|
||||
mysql::db { $site_mysql_database:
|
||||
user => $site_mysql_user,
|
||||
password => $site_mysql_password,
|
||||
host => $site_mysql_host,
|
||||
grant => ['all'],
|
||||
notify => Distbuild["distbuild-${site_name}"],
|
||||
}
|
||||
}
|
||||
|
||||
# drupal dist-build
|
||||
distbuild { "distbuild-${site_name}":
|
||||
site_sandbox_root => $site_sandbox_root,
|
||||
site_staging_root => $site_staging_root,
|
||||
site_repo_url => $site_repo_url,
|
||||
site_build_repo_name => $site_build_reponame,
|
||||
site_staging_tarball => $site_staging_tarball,
|
||||
site_build_flagfile => $site_build_flagfile,
|
||||
site_deploy_flagfile => $site_deploy_flagfile,
|
||||
site_makefile => $site_makefile,
|
||||
require => Package['httpd'],
|
||||
}
|
||||
|
||||
# drupal site deploy
|
||||
sitedeploy { "sitedeploy-${site_name}":
|
||||
site_docroot => $site_docroot,
|
||||
site_staging_root => $site_staging_root,
|
||||
site_staging_tarball => $site_staging_tarball,
|
||||
site_deploy_flagfile => $site_deploy_flagfile,
|
||||
site_name => $site_name,
|
||||
site_profile => $site_profile,
|
||||
site_mysql_user => $site_mysql_user,
|
||||
site_mysql_password => $site_mysql_password,
|
||||
site_mysql_host => $site_mysql_host,
|
||||
site_mysql_database => $site_mysql_database,
|
||||
site_admin_password => $site_admin_password,
|
||||
site_base_url => $site_base_url,
|
||||
require => Distbuild["distbuild-${site_name}"],
|
||||
}
|
||||
|
||||
}
|
66
modules/drupal/manifests/sitedeploy.pp
Normal file
66
modules/drupal/manifests/sitedeploy.pp
Normal file
@ -0,0 +1,66 @@
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# == Define: sitedeploy
|
||||
#
|
||||
# define to deploy drupal site from distribution tarball
|
||||
#
|
||||
define drupal::sitedeploy (
|
||||
$site_docroot = undef,
|
||||
$site_staging_root = undef,
|
||||
$site_staging_tarball = undef,
|
||||
$site_deploy_flagfile = undef,
|
||||
$site_name = undef,
|
||||
$site_profile = undef,
|
||||
$site_mysql_user = undef,
|
||||
$site_mysql_password = undef,
|
||||
$site_mysql_host = undef,
|
||||
$site_mysql_database = undef,
|
||||
$site_admin_password = '',
|
||||
$site_deploy_timeout = 600,
|
||||
$site_base_url = undef,
|
||||
$site_file_owner = 'root',
|
||||
) {
|
||||
file { '/usr/local/sbin/drupal-site-deploy.sh':
|
||||
ensure => present,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0744',
|
||||
source => 'puppet:///modules/drupal/drupal_site_deploy.sh',
|
||||
}
|
||||
|
||||
file { '/etc/drupal_site':
|
||||
ensure => directory,
|
||||
}
|
||||
|
||||
file { "/etc/drupal_site/${site_name}.config":
|
||||
ensure => present,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0400',
|
||||
content => template('drupal/site.config.erb'),
|
||||
replace => true,
|
||||
require => File['/etc/drupal_site'],
|
||||
}
|
||||
|
||||
exec { "drupal-deploy-${site_name}":
|
||||
path => '/usr/bin:/bin:/usr/local/sbin',
|
||||
command => "drupal-site-deploy.sh -in /etc/drupal_site/${site_name}.config",
|
||||
creates => $site_deploy_flagfile,
|
||||
timeout => $site_deploy_timeout,
|
||||
require => [ File["/etc/drupal_site/${site_name}.config"],
|
||||
File['/usr/local/sbin/drupal-site-deploy.sh'] ],
|
||||
}
|
||||
|
||||
}
|
139
modules/drupal/templates/drupal.vhost.erb
Normal file
139
modules/drupal/templates/drupal.vhost.erb
Normal file
@ -0,0 +1,139 @@
|
||||
# ************************************
|
||||
# Puppet Drupal 7 vhost template
|
||||
# Managed by Puppet
|
||||
# ************************************
|
||||
|
||||
NameVirtualHost <%= vhost_name %>:<%= port %>
|
||||
<VirtualHost <%= vhost_name %>:<%= port %>>
|
||||
ServerName <%= srvname %>
|
||||
<% if serveraliases.is_a? Array -%>
|
||||
<% serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%>
|
||||
<% elsif serveraliases != '' -%>
|
||||
<%= " ServerAlias #{serveraliases}" %>
|
||||
<% end -%>
|
||||
DocumentRoot <%= docroot %>
|
||||
<Directory <%= site_docroot %>>
|
||||
Options FollowSymLinks MultiViews
|
||||
AllowOverride None
|
||||
Order allow,deny
|
||||
allow from all
|
||||
# Protect files and directories from prying eyes.
|
||||
<FilesMatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$">
|
||||
Order allow,deny
|
||||
</FilesMatch>
|
||||
# Make Drupal handle any 404 errors.
|
||||
ErrorDocument 404 /index.php
|
||||
# Set the default handler.
|
||||
DirectoryIndex index.php index.html index.htm
|
||||
# PHP 5, Apache 1 and 2.
|
||||
<IfModule mod_php5.c>
|
||||
php_flag magic_quotes_gpc off
|
||||
php_flag magic_quotes_sybase off
|
||||
php_flag register_globals off
|
||||
php_flag session.auto_start off
|
||||
php_value mbstring.http_input pass
|
||||
php_value mbstring.http_output pass
|
||||
php_flag mbstring.encoding_translation off
|
||||
php_value max_execution_time 300
|
||||
php_value memory_limit 192M
|
||||
</IfModule>
|
||||
# Requires mod_expires to be enabled.
|
||||
<IfModule mod_expires.c>
|
||||
# Enable expirations.
|
||||
ExpiresActive On
|
||||
|
||||
# Cache all files for 2 weeks after access (A).
|
||||
ExpiresDefault A1209600
|
||||
|
||||
<FilesMatch \.php$>
|
||||
# Do not allow PHP scripts to be cached unless they explicitly send cache
|
||||
# headers themselves. Otherwise all scripts would have to overwrite the
|
||||
# headers set by mod_expires if they want another caching behavior. This may
|
||||
# fail if an error occurs early in the bootstrap process, and it may cause
|
||||
# problems if a non-Drupal PHP file is installed in a subdirectory.
|
||||
ExpiresActive Off
|
||||
</FilesMatch>
|
||||
</IfModule>
|
||||
# Various rewrite rules.
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine on
|
||||
|
||||
# Block access to "hidden" directories whose names begin with a period. This
|
||||
# includes directories used by version control systems such as Subversion or
|
||||
# Git to store control files. Files whose names begin with a period, as well
|
||||
# as the control files used by CVS, are protected by the FilesMatch directive
|
||||
# above.
|
||||
#
|
||||
# NOTE: This only works when mod_rewrite is loaded. Without mod_rewrite, it is
|
||||
# not possible to block access to entire directories from .htaccess, because
|
||||
# <DirectoryMatch> is not allowed here.
|
||||
#
|
||||
# If you do not have mod_rewrite installed, you should remove these
|
||||
# directories from your webroot or otherwise protect them from being
|
||||
# downloaded.
|
||||
RewriteRule "(^|/)\." - [F]
|
||||
|
||||
# If your site can be accessed both with and without the 'www.' prefix, you
|
||||
# can use one of the following settings to redirect users to your preferred
|
||||
# URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
|
||||
#
|
||||
# To redirect all users to access the site WITH the 'www.' prefix,
|
||||
# (http://example.com/... will be redirected to http://www.example.com/...)
|
||||
# uncomment the following:
|
||||
# RewriteCond %{HTTP_HOST} !^www\. [NC]
|
||||
# RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
|
||||
#
|
||||
# To redirect all users to access the site WITHOUT the 'www.' prefix,
|
||||
# (http://www.example.com/... will be redirected to http://example.com/...)
|
||||
# uncomment the following:
|
||||
# RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
|
||||
# RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]
|
||||
|
||||
# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
|
||||
# VirtualDocumentRoot and the rewrite rules are not working properly.
|
||||
# For example if your site is at http://example.com/drupal uncomment and
|
||||
# modify the following line:
|
||||
# RewriteBase /drupal
|
||||
#
|
||||
# If your site is running in a VirtualDocumentRoot at http://example.com/,
|
||||
# uncomment the following line:
|
||||
# RewriteBase /
|
||||
|
||||
# Pass all requests not referring directly to files in the filesystem to
|
||||
# index.php. Clean URLs are handled in drupal_environment_initialize().
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_URI} !=/favicon.ico
|
||||
RewriteRule ^ index.php [L]
|
||||
|
||||
# Rules to correctly serve gzip compressed CSS and JS files.
|
||||
# Requires both mod_rewrite and mod_headers to be enabled.
|
||||
<IfModule mod_headers.c>
|
||||
# Serve gzip compressed CSS files if they exist and the client accepts gzip.
|
||||
RewriteCond %{HTTP:Accept-encoding} gzip
|
||||
RewriteCond %{REQUEST_FILENAME}\.gz -s
|
||||
RewriteRule ^(.*)\.css $1\.css\.gz [QSA]
|
||||
|
||||
# Serve gzip compressed JS files if they exist and the client accepts gzip.
|
||||
RewriteCond %{HTTP:Accept-encoding} gzip
|
||||
RewriteCond %{REQUEST_FILENAME}\.gz -s
|
||||
RewriteRule ^(.*)\.js $1\.js\.gz [QSA]
|
||||
|
||||
# Serve correct content types, and prevent mod_deflate double gzip.
|
||||
RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1]
|
||||
RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1]
|
||||
|
||||
<FilesMatch "(\.js\.gz|\.css\.gz)$">
|
||||
# Serve correct encoding type.
|
||||
Header set Content-Encoding gzip
|
||||
# Force proxies to cache gzipped & non-gzipped css/js files separately.
|
||||
Header append Vary Accept-Encoding
|
||||
</FilesMatch>
|
||||
</IfModule>
|
||||
</IfModule>
|
||||
</Directory>
|
||||
ErrorLog /var/log/apache2/<%= name %>_error.log
|
||||
LogLevel warn
|
||||
CustomLog /var/log/apache2/<%= name %>_access.log combined
|
||||
ServerSignature Off
|
||||
</VirtualHost>
|
13
modules/drupal/templates/site.config.erb
Normal file
13
modules/drupal/templates/site.config.erb
Normal file
@ -0,0 +1,13 @@
|
||||
# Site deployment config file: <%= site_name %>
|
||||
#
|
||||
|
||||
site_tarball=<%= site_staging_root %>/<%= site_staging_tarball %>
|
||||
db_url=mysql://<%= site_mysql_user %>:<%= site_mysql_password %>@<%= site_mysql_host %>/<%= site_mysql_database %>
|
||||
site_admin_password=<%= site_admin_password %>
|
||||
site_name=<%= site_name %>
|
||||
profile_name=<%= site_profile %>
|
||||
dest_dir=<%= site_docroot %>
|
||||
flag_file=<%= site_deploy_flagfile %>
|
||||
is_clean=true
|
||||
base_url=<%= site_base_url %>
|
||||
file_owner=<%= site_file_owner %>
|
49
modules/openstack_project/manifests/groups_dev.pp
Normal file
49
modules/openstack_project/manifests/groups_dev.pp
Normal file
@ -0,0 +1,49 @@
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# User group management dev server
|
||||
#
|
||||
class openstack_project::groups_dev (
|
||||
$site_admin_password = '',
|
||||
$site_mysql_host = '',
|
||||
$site_mysql_password = '',
|
||||
$sysadmins = [],
|
||||
) {
|
||||
|
||||
# include drupal
|
||||
|
||||
class { 'openstack_project::server':
|
||||
iptables_public_tcp_ports => [80, 443],
|
||||
sysadmins => $sysadmins,
|
||||
}
|
||||
|
||||
class { 'drupal':
|
||||
site_name => 'groups-dev.openstack.org',
|
||||
site_docroot => '/srv/vhosts/groups-dev.openstack.org',
|
||||
site_mysql_host => $site_mysql_host,
|
||||
site_mysql_user => 'groups',
|
||||
site_mysql_password => $site_mysql_password,
|
||||
site_mysql_database => 'groups_dev',
|
||||
site_vhost_root => '/srv/vhosts',
|
||||
site_staging_tarball => 'groups-dev.tar.gz',
|
||||
site_admin_password => $site_admin_password,
|
||||
site_build_reponame => 'groups-master',
|
||||
site_makefile => 'build-groups.make',
|
||||
site_repo_url => 'https://git.openstack.org/openstack-infra/groups',
|
||||
site_profile => 'groups',
|
||||
site_base_url => 'http://groups-dev.openstack.org',
|
||||
require => Class['openstack_project::server'],
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user