sebas5384 / charm-drupal Goto Github PK
View Code? Open in Web Editor NEWDrupal Juju Charm - Bash and Ansible
Drupal Juju Charm - Bash and Ansible
I believe that with the update of #22 a bug was introduced.
Now when I try to deploy the machine I get the following error:
INFO install TASK: [pbuyle.nginx-drupal | Create available sites configuration files] ******
INFO install fatal: [localhost] => {'msg': "One or more undefined variables: 'dict object' has no attribute 'limit_conn'", 'failed': True}
INFO install fatal: [localhost] => {'msg': 'One or more items failed.', 'failed': True, 'changed': False, 'results': [{'msg': "One or more undefined variables: 'dict object' has no attribute 'limit_conn'", 'failed': True}]}
Which causes the install to fail.
This is just a suggestion, just to have a clue of whats expected:
# OS staff: Setting Deploy key.
if is_project_from_git && [[ ! -z $DEPLOY_KEY ]]; then
juju-log "Write the deploy ssh key."
echo "$DEPLOY_KEY" > /home/ubuntu/.ssh/deploy_key
chown ubuntu:ubuntu /home/ubuntu/.ssh/deploy_key
chmod 400 /home/ubuntu/.ssh/deploy_key
if [[ ! -f /usr/bin/git-wrapped ]]; then
wget https://raw2.github.com/sebas5384/utils/master/bin/git.sh
mv git.sh /usr/bin/git-wrapped
chmod +x /usr/bin/git-wrapped
fi
elif [[ -f /home/ubuntu/.ssh/deploy_key ]]; then
juju-log "Removing ssh deploy key."
rm /home/ubuntu/.ssh/deploy_key
fi
I've faced a problem with the media module when opening the media browse modal.
In the inspector console I get the following error:
Load denied by X-Frame-Options: http://project_name.local/media/browser?render=media-popup&types%5Bimage%5D=image&enabledPlugins%5Bmedia_default--media_browser_1%5D=media_default--media_browser_1&enabledPlugins%5Bmedia_default--media_browser_my_files%5D=media_default--media_browser_my_files&enabledPlugins%5Bmedia_internet%5D=media_internet&enabledPlugins%5Bupload%5D=upload&schemes%5Bpublic%5D=public&schemes%5Byoutube%5D=0&file_directory=&file_extensions=png+gif+jpg+jpeg&max_filesize=&uri_scheme=public&min_resolution=805x168&max_resolution=&plugins=undefined does not permit framing.
Adding the following line the problems was solved:
add_header X-Frame-Options SAMEORIGIN;
Maybe we could add the X-Frame-Options directive into the charm configuration. I think its a good choice because it may chance in some projects.
Relations to be set:
requires:
cache-redis:
interface: redis-master
cache-memcached:
interface: memcache
Create a nfs-client Ansible role
# Composer: install.
juju-log "Installing Composer"
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
sed -i '1i export PATH="$HOME/.composer/vendor/bin:$PATH"' $HOME/.bashrc
# Drush: install.
juju-log "Installing Drush 6.* with composer"
composer global require drush/drush:6.*
Install php-fpm 5.3 for Drupal 6 or 7,
php5-fpm php5-cli php5-gd php5-mysql php5-mcrypt php-pear php-apc php5-curl php5-xdebug php-mail
with configurations from perusio:
https://github.com/perusio/php-fpm-example-config
Just an example of whats expected:
# Drupal project: Needs to install a new fresh Drupal project.
if need_new_install; then
echo "$DEPLOY_SOURCE" > .deploy-source
# Drupal: Check if there is a Drupal running.
if is_drupal_booting; then
# @TODO: Needs to do a Backup.
juju-log "Backuping the settings.php files for using with the new project."
#1. backup the settings.*.php files
#2. backup the files somewhere.
#3. Clean and remove for the new project.
fi
# Download the project files including Drupal if not exist.
if !is_drupal_downloaded; then
# From Git, already installed.
if is_project_from_git; then
juju-log "Cloning the project from Git repository $DEPLOY_SOURCE."
do_git clone $DEPLOY_SOURCE $project_path
# From Drupal.org with drush.
else
(
juju-log "Download a fresh Drupal $DRUPAL_VERSION using a boilerplate as directory skeleton."
cd /mnt/tmp
# @TODO: This could be an option.
wget https://github.com/TallerWebSolutions/drupal-boilerplate/archive/master.tar.gz
tar -zxvf master.tar.gz; rm master.tar.gz
mv drupal-boilerplate-master $project_path
juju-log "Downloading Drupal from Drupal.org with drush."
if [[ $DRUPAL_VERSION == 8 ]]; then
drush dl drupal-8 --dev --drupal-project-rename="drupal.fresh"
else
drush dl drupal-$DRUPAL_VERSION --drupal-project-rename="drupal.fresh"
fi
juju-log "Move the new Drupal to the docroot."
rm -rf $drupal_path
mv drupal.fresh $drupal_path
)
# Setting some directories.
mkdir $drupal_path/sites/all/modules/contrib
mkdir $drupal_path/sites/all/themes/contrib
(
cd $project_path
git init
)
fi
juju-log "Configure the Git Flow init."
(
cd $project_path
# Init the Git flow.
do_git_flow_init
)
fi
# Directory for upload files.
mkdir $drupal_path/sites/default/files
chmod ug+w $drupal_path/sites/default/files
# Create the Drupal settings.
install -o ubuntu -g www-data -m 0644 $drupal_path/sites/default/default.settings.php $config_file_path
# Set the right owners.
chown -R ubuntu:www-data $project_path
fi
Create a playbook setting the configurations from the charm.
Suggested config variables:
options:
drupal-version:
type: string
default: "7"
description: "Drupal version, currently supported 6 and 7"
drupal-profile:
type: string
default: "standard"
description: "Profile name like standard, minimal or testing."
deploy-branch:
type: string
default: "master"
description: "The branch's name when a Git repository is deployed."
deploy-source:
type: string
default: "drupal.org"
description: |
"From where the Drupal will be downloaded, currently supported a repository Git (Ex. git@host:path/repo.git) or 'drupal.org'.
Deploying from Git a Lullabot boilerplate fork is expected, like https://github.com/TallerWebSolutions/drupal-boilerplate"
deploy-key:
type: string
default: ""
description: "A deploy ssh key that is stored on the server and grants access to a repository (Git only)."
nginx-port:
type: int
default: 80
description: "The port number where Nginx will listen."
php-fpm-upstream:
type: string
default: "unix"
description: "The PHP-FPM upstream, supported unix and tcp."
install-compass:
type: boolean
default: True
description: "Install SASS/Compass, so that means ruby-full and rubygems1.8 will be installed."
Modify this role https://github.com/TallerWebSolutions/ansible-role-php-xdebug to be more agnostic.
And add some configurations to the charm.
Something to think about:
if [ -f "$config_file_path" ] || [ -f "$config_db_file_path" ]; then
juju-log "Drupal is already setup, just silently going away"
exit 0
fi
host=`relation-get private-address`
database=`relation-get database`
user=`relation-get user`
password=`relation-get password`
if [ -z "$database" ] ; then
exit 0
fi
# Drupal: Include the new Settings.
echo -e "\ninclude settings.db.php" >> $config_file_path
# Database info.
cp files/charm/drupal/settings.db.php $config_db_file_path
sed -i "s/\${host}/$host/" $config_db_file_path
sed -i "s/\${database}/$database/" $config_db_file_path
sed -i "s/\${user}/$user/" $config_db_file_path
sed -i "s/\${password}/$password/" $config_db_file_path
# Configuring the Salt hash.
(
cd $drupal_path
drupal_hash_salt=`drush php-eval "echo drupal_get_hash_salt();"`
sed -i "s/^\$drupal_hash_salt = \'\'\;/\$drupal_hash_salt = \'$drupal_hash_salt\'\;/" $config_file_path
)
chmod 0644 $config_file_path
chmod 0644 $config_db_file_path
juju-log "Resetting permissions"
chown -R ubuntu:www-data $project_path
# When project is from an existent Git repository, will try to import the dump form the branch.
if is_project_from_git && [ -f $project_path/databases/$DEPLOY_BRANCH.dump.sql ]; then
juju-log "Trying to importing MySQL dump in /databases/$DEPLOY_BRANCH.dump.sql"
(
cd $drupal_path
drush sqlc < $project_path/databases/$DEPLOY_BRANCH.dump.sql
)
drupal_clear_all_cache
fi
. hooks/restart
# Make it publicly visible, once the Drupal service is exposed
open-port 80/tcp
When this relation is set the built-in php must be disabled and configure the nginx to use the php units to scale.
Describe what this charm, and each configuration option does.
Write some examples, and compatible relations.
# Compass: The project needs Ruby for Sass and Compass.
if [[ "$INSTALL_COMPASS" == "True" ]] && [[ ! -f .installed-compass ]]; then
juju-log "Install Compass and SASS"
apt-get install -y ruby-full rubygems1.8
gem install sass -v 3.2.7
gem install compass
touch .installed-compass
else
juju-log "Uninstall Compass and SASS"
apt-get remove -y --purge ruby-full rubygems1.8
rm .installed-compass
fi
This issue will contain all the user stories with the objective of developing the automated tests with Amulet.
Create a common role, for downloading some tools, like:
wget git-core git-flow curl vim rsync sysstat mailutils charm-helper-sh mktemp aptitude nfs-common
Hi there, tried to deploy cs:~sebas5384/precise/drupal-6 in my juju setup (private openstack provider, defaults to a precise image - using ubuntu's cloud image) and it failed out complaining about PHP being too old (looks like 5.5.9 required, 5.3.10 installed; logs below).
I did try changing drush-version to 5.x, then 4.5, hoping to back it up to something that might work, but that didn't appear to change anything - same dependency errors.
2016-02-11 17:04:55 INFO config-changed TASK: [geerlingguy.drush | Install Drush dependencies with Composer.] *********
2016-02-11 17:04:55 INFO config-changed failed: [localhost] => {"changed": true, "cmd": "/usr/local/bin/composer install", "delta": "0:00:00.236105", "end": "2016-02-11 17:04:55.844284", "rc": 2, "start": "2016-02-11 17:04:55.608179"}
2016-02-11 17:04:55 INFO config-changed stderr: You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
2016-02-11 17:04:55 INFO config-changed Loading composer repositories with package information
2016-02-11 17:04:55 INFO config-changed Installing dependencies (including require-dev) from lock file
2016-02-11 17:04:55 INFO config-changed Your requirements could not be resolved to an installable set of packages.
2016-02-11 17:04:55 INFO config-changed
2016-02-11 17:04:55 INFO config-changed Problem 1
2016-02-11 17:04:55 INFO config-changed - This package requires php >=5.4.5 but your PHP version (5.3.10) does not satisfy that requirement.
2016-02-11 17:04:55 INFO config-changed Problem 2
2016-02-11 17:04:55 INFO config-changed - Installation request for nikic/php-parser v2.0.0 -> satisfiable by nikic/php-parser[v2.0.0].
2016-02-11 17:04:55 INFO config-changed - nikic/php-parser v2.0.0 requires php >=5.4 -> your PHP version (5.3.10) does not satisfy that requirement.
2016-02-11 17:04:55 INFO config-changed Problem 3
2016-02-11 17:04:55 INFO config-changed - Installation request for symfony/console v3.0.2 -> satisfiable by symfony/console[v3.0.2].
2016-02-11 17:04:55 INFO config-changed - symfony/console v3.0.2 requires php >=5.5.9 -> your PHP version (5.3.10) does not satisfy that requirement.
2016-02-11 17:04:55 INFO config-changed Problem 4
2016-02-11 17:04:55 INFO config-changed - nikic/php-parser v2.0.0 requires php >=5.4 -> your PHP version (5.3.10) does not satisfy that requirement.
2016-02-11 17:04:55 INFO config-changed - psy/psysh v0.6.1 requires nikic/php-parser ^1.2.1|~2.0 -> satisfiable by nikic/php-parser[v2.0.0].
2016-02-11 17:04:55 INFO config-changed - Installation request for psy/psysh v0.6.1 -> satisfiable by psy/psysh[v0.6.1].
2016-02-11 17:04:55 INFO config-changed
2016-02-11 17:04:55 INFO config-changed FATAL: all hosts have already failed -- aborting
As a new user, if I were to deploy this according to the README instructions, I would be lost as to why this is missing.
Worth noting that make sync-charm-helpers
requires bzr to be installed prior to execution.
I have created a list of Drupal related tools: https://drupaltools.github.io. Is this project active to add it on the list?
Thanks
I noticed the readme states precise, and thought 'i'll just deploy this on trusty and see what happens' - here's step one to upgrading for trusty.
TASK: [Install Ruby.] *********************************************************
failed: [localhost] => (item=ruby,rubygems) => {"failed": true, "item": "ruby,rubygems"}
msg: No package matching 'rubygems' is available
FATAL: all hosts have already failed -- aborting
If i can make a recomendation, try using the brightboxppa for ruby, and look into using their stack, as they keep an up to date revision of ruby 1.9.x -> 2.1.x in a ppa with security patches. https://launchpad.net/~brightbox/+archive/ubuntu/ruby-ng
Drupal needs postfix for sending emails.
Needs to download a boilerplate from: https://github.com/TallerWebSolutions/drupal-boilerplate
This can be an option.
# OS staff: User ubuntu in www-data group.
juju-log "Adding ubuntu user in the www-data group."
usermod -a -G www-data ubuntu
# Nginx: install.
juju-log "Download, compile and install Nginx with all the extra modules like Upload Progress."
apt-get -y install libpcre3-dev libssl-dev zlib1g-dev
wget -O - http://nginx.org/download/nginx-1.4.1.tar.gz | tar -C /opt -zxvf
mv /opt/nginx-1.4.1 /opt/nginx
mkdir /opt/nginx/modules
git clone https://github.com/masterzen/nginx-upload-progress-module.git /opt/nginx/modules/
git clone https://github.com/gnosek/nginx-upstream-fair /opt/nginx/modules/
git clone https://github.com/FRiCKLE/ngx_cache_purge.git /opt/nginx/modules/
/opt/nginx/configure --conf-path=/etc/nginx/nginx.conf --user=www-data --group=www-data --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --without-mail_pop3_module --without-mail_imap_module --without-http_scgi_module --without-http_uwsgi_module --with-ipv6 --with-debug --add-module=modules/nginx-upload-progress-module --add-module=modules/nginx-upstream-fair --add-module=modules/ngx_cache_purge --with-file-aio --pid-path=/var/run/nginx.pid
mkdir -p /var/cache/nginx/microcache
mkdir -p /var/log/nginx
juju-log "Installing Nginx"
cd /opt/nginx; make && make install
juju-log "Nginx as a service. (service nginx start/stop)"
wget https://raw.github.com/sebas5384/nginx-init-ubuntu/master/nginx -O /etc/init.d/nginx
chmod +x /etc/init.d/nginx
update-rc.d -f nginx defaults
For now the ansible roles are being added using ansible-galaxy install -n {role} to avoid dependencies download.
To keep ansible-nginx-drupal as a "module", must add the repository as a submodule:
https://github.com/sebas5384/ansible-nginx-drupal
Directory of destination: /roles/nginx-perusio
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.