Add rake tasks, provisioning, and templates
This commit is contained in:
parent
20bee0fac4
commit
cdf390f082
7 changed files with 193 additions and 11 deletions
23
Rakefile
Normal file
23
Rakefile
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# "dev" => {
|
||||||
|
# "host" => "vlad@simone.mayfirst.org",
|
||||||
|
# "path" => "/var/local/drupal/findit/web",
|
||||||
|
# "backups" => "/tmp",
|
||||||
|
# },
|
||||||
|
ENVIRONMENTS = {
|
||||||
|
"test" => {
|
||||||
|
"host" => "agaric_test@drutopia.org",
|
||||||
|
"path" => "/home/agaric_test/site/web",
|
||||||
|
"drush" => "/home/agaric_test/site/vendor/bin/drush",
|
||||||
|
"backups" => "/tmp",
|
||||||
|
},
|
||||||
|
"live" => {
|
||||||
|
"host" => "agaric_live@drutopia.org",
|
||||||
|
"path" => "/home/agaric_live/site/web",
|
||||||
|
"drush" => "/home/agaric_live/site/vendor/bin/drush",
|
||||||
|
"backups" => "/tmp",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
TAGNAMES = %w(stable)
|
||||||
|
DRUPAL = "web"
|
||||||
|
PROFILE = "agaric"
|
||||||
|
BUILDDIR = "/tmp/build"
|
|
@ -155,7 +155,7 @@ installed_extras:
|
||||||
- nodejs
|
- nodejs
|
||||||
- pimpmylog
|
- pimpmylog
|
||||||
# - redis
|
# - redis
|
||||||
# - ruby
|
- ruby
|
||||||
# - selenium
|
# - selenium
|
||||||
# - solr
|
# - solr
|
||||||
# - tideways
|
# - tideways
|
||||||
|
@ -206,13 +206,6 @@ php_opcache_max_accelerated_files: 4096
|
||||||
php_max_input_vars: "4000"
|
php_max_input_vars: "4000"
|
||||||
php_packages_extra: ['php7.1-zip']
|
php_packages_extra: ['php7.1-zip']
|
||||||
|
|
||||||
# Run specified scripts before or after VM is provisioned. Use {{ playbook_dir }}
|
|
||||||
# to reference the provisioning/ folder in Drupal VM or {{ config_dir }} to
|
|
||||||
# reference the directory where your `config.yml` is.
|
|
||||||
pre_provision_scripts: []
|
|
||||||
post_provision_scripts: []
|
|
||||||
# - "{{ playbook_dir }}/../examples/scripts/configure-solr.sh"
|
|
||||||
|
|
||||||
# MySQL Configuration.
|
# MySQL Configuration.
|
||||||
mysql_root_password: root
|
mysql_root_password: root
|
||||||
mysql_slow_query_log_enabled: true
|
mysql_slow_query_log_enabled: true
|
||||||
|
@ -229,7 +222,7 @@ npm_config_prefix: "/home/{{ drupalvm_user }}/.npm-global"
|
||||||
|
|
||||||
# Ruby Configuration (if enabled above).
|
# Ruby Configuration (if enabled above).
|
||||||
ruby_install_gems_user: "{{ drupalvm_user }}"
|
ruby_install_gems_user: "{{ drupalvm_user }}"
|
||||||
ruby_install_gems: []
|
ruby_install_gems: ['rake']
|
||||||
|
|
||||||
# Varnish Configuration (if enabled above).
|
# Varnish Configuration (if enabled above).
|
||||||
varnish_listen_port: "81"
|
varnish_listen_port: "81"
|
||||||
|
@ -272,5 +265,5 @@ hostname_configure: true
|
||||||
hostname_fqdn: "{{ vagrant_hostname }}"
|
hostname_fqdn: "{{ vagrant_hostname }}"
|
||||||
ssh_home: "{{ drupal_core_path }}"
|
ssh_home: "{{ drupal_core_path }}"
|
||||||
|
|
||||||
post_provision_tasks_dir: ../../provisioning/box/post-tasks/*.yml
|
|
||||||
pre_provision_tasks_dir: ../../provisioning/box/pre-tasks/*.yml
|
pre_provision_tasks_dir: ../../provisioning/box/pre-tasks/*.yml
|
||||||
|
post_provision_tasks_dir: ../../provisioning/box/post-tasks/*.yml
|
||||||
|
|
|
@ -59,6 +59,16 @@
|
||||||
changed_when: false
|
changed_when: false
|
||||||
become: no
|
become: no
|
||||||
|
|
||||||
|
- name: create drush.yml
|
||||||
|
template:
|
||||||
|
src: "drush.yml.j2"
|
||||||
|
dest: "{{ drupal_composer_install_dir }}/drush/drush.yml"
|
||||||
|
|
||||||
|
- name: create local.site.yml
|
||||||
|
template:
|
||||||
|
src: "local.site.yml.j2"
|
||||||
|
dest: "{{ drupal_composer_install_dir }}/drush/sites/local.site.yml"
|
||||||
|
|
||||||
- name: Install Drupal with drush.
|
- name: Install Drupal with drush.
|
||||||
command: >
|
command: >
|
||||||
{{ drupal_composer_install_dir }}/vendor/bin/drush site-install -y
|
{{ drupal_composer_install_dir }}/vendor/bin/drush site-install -y
|
||||||
|
|
3
provisioning/box/post-tasks/templates/drush.yml.j2
Normal file
3
provisioning/box/post-tasks/templates/drush.yml.j2
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
options:
|
||||||
|
uri: "http://{{ vagrant_hostname }}"
|
||||||
|
root: "{{ drupal_core_path }}"
|
7
provisioning/box/post-tasks/templates/local.site.yml.j2
Normal file
7
provisioning/box/post-tasks/templates/local.site.yml.j2
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
dev:
|
||||||
|
root: "{{ drupal_core_path }}"
|
||||||
|
uri: "http://{{ vagrant_hostname }}"
|
||||||
|
|
||||||
|
local:
|
||||||
|
root: "{{ drupal_core_path }}"
|
||||||
|
uri: "http://{{ vagrant_hostname }}"
|
106
rakelib/agaric.rake
Normal file
106
rakelib/agaric.rake
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
# As agaric.rake did not know how to deploy to Drutopia,
|
||||||
|
# all deployment features have been removed.
|
||||||
|
# Use drutopia_host to deploy.
|
||||||
|
|
||||||
|
require 'date'
|
||||||
|
require 'rake/clean'
|
||||||
|
|
||||||
|
CLEAN.include("#{BUILDDIR}")
|
||||||
|
|
||||||
|
ENVIRONMENTS.keys.each do |env|
|
||||||
|
settings_source = "#{BUILDDIR}/#{env}/#{DRUPAL}/sites/default/#{env}.settings.php"
|
||||||
|
settings_target = "#{BUILDDIR}/#{env}/#{DRUPAL}/sites/default/settings.php"
|
||||||
|
|
||||||
|
release_host = ENVIRONMENTS[env]["host"]
|
||||||
|
release_path = ENVIRONMENTS[env]["path"]
|
||||||
|
release_backups = ENVIRONMENTS[env]["backups"]
|
||||||
|
release_tag = ENVIRONMENTS[env]["tag"]
|
||||||
|
drush_path = ENVIRONMENTS[env]["drush"]
|
||||||
|
drush_path = drush_path ? drush_path : "drush"
|
||||||
|
|
||||||
|
db_backup_task = "db_backup_#{env}".to_sym
|
||||||
|
task db_backup_task do
|
||||||
|
file = "#{release_backups}/backup-#{env}-#{DateTime.now}.sql.gz"
|
||||||
|
sh "ssh #{release_host} '#{drush_path} -r #{release_path} sql-dump --structure-tables-key=common --gzip > #{file}'"
|
||||||
|
end
|
||||||
|
|
||||||
|
db_drop_tables_task = "db_drop_tables_#{env}".to_sym
|
||||||
|
task db_drop_tables_task => db_backup_task do
|
||||||
|
sh "ssh #{release_host} #{drush_path} -y -r #{release_path} sql-drop"
|
||||||
|
end
|
||||||
|
|
||||||
|
file_sync_task = "file_sync_#{env}_to_local".to_sym
|
||||||
|
desc "Sync files from #{env} to local environment."
|
||||||
|
task file_sync_task do
|
||||||
|
sh "rsync -rz --stats --exclude styles --exclude css --exclude js --delete \
|
||||||
|
#{release_host}:#{release_path}/sites/default/files/ \
|
||||||
|
#{DRUPAL}/sites/default/files/"
|
||||||
|
end
|
||||||
|
|
||||||
|
db_sync_task = "db_sync_#{env}_to_local".to_sym
|
||||||
|
desc "Sync database from #{env} to local environment."
|
||||||
|
task db_sync_task do
|
||||||
|
sh "drush -y sql-drop"
|
||||||
|
sh "ssh -C #{release_host} #{drush_path} -r #{release_path} \
|
||||||
|
sql-dump --structure-tables-key=common | drush sql-cli"
|
||||||
|
end
|
||||||
|
|
||||||
|
ENVIRONMENTS.keys.each do |e|
|
||||||
|
unless e == env then
|
||||||
|
from_host = ENVIRONMENTS[e]["host"]
|
||||||
|
from_path = ENVIRONMENTS[e]["path"]
|
||||||
|
from_drush = ENVIRONMENTS[e]["drush"]
|
||||||
|
from_drush = from_drush ? from_drush : "drush"
|
||||||
|
|
||||||
|
file_sync_task = "file_sync_#{e}_to_#{env}".to_sym
|
||||||
|
desc "Sync files from #{e} to #{env} environment."
|
||||||
|
task file_sync_task do
|
||||||
|
sh "ssh -A #{from_host} rsync -rz --stats --exclude styles \
|
||||||
|
--exclude css --exclude js #{from_path}/sites/default/files/ \
|
||||||
|
--delete " + (from_host == release_host ? "" : "#{release_host}:") + "#{release_path}/sites/default/files/"
|
||||||
|
end
|
||||||
|
db_sync_task = "db_sync_#{e}_to_#{env}".to_sym
|
||||||
|
desc "Sync database from #{e} to #{env} environment."
|
||||||
|
task db_sync_task => db_drop_tables_task do
|
||||||
|
sh "ssh -C #{from_host} #{from_drush} -r #{from_path} \
|
||||||
|
sql-dump --structure-tables-key=common | \
|
||||||
|
ssh -C #{release_host} #{drush_path} -r #{release_path} sql-cli"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
TAGNAMES.each do |tagname|
|
||||||
|
desc "Tag a commit with #{tagname}."
|
||||||
|
task "tag_#{tagname}".to_sym do
|
||||||
|
sh "git fetch --tags"
|
||||||
|
num = `git tag`.scan(Regexp.new(tagname + "-")).size + 1
|
||||||
|
sh "git tag -am '#{tagname.upcase} Release #{num}' #{tagname}-#{num}"
|
||||||
|
sh "git tag -afm 'Current #{tagname.upcase} Release' #{tagname}"
|
||||||
|
sh "git push origin :refs/tags/#{tagname}"
|
||||||
|
sh "git push origin --tags"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Detect coding standard violations in profile and custom modules."
|
||||||
|
task :sniff do
|
||||||
|
files = ["web/profiles/#{PROFILE}", 'web/sites/all/modules/custom'].join(' ')
|
||||||
|
extensions = ['module', 'profile', 'install', 'inc', 'php'].join(',')
|
||||||
|
sh "phpcs --extensions=#{extensions} #{files}"
|
||||||
|
end
|
||||||
|
|
||||||
|
namespace :tests do
|
||||||
|
|
||||||
|
desc "Run integration tests."
|
||||||
|
task "integration" do
|
||||||
|
sh "phpunit --process-isolation --bootstrap=tests/bootstrap.php tests/integration"
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
if defined? PROFILE
|
||||||
|
desc "Delete and re-install a site from its installation profile."
|
||||||
|
task "site_install" do
|
||||||
|
sh "#{drush_path} -y site-install #{PROFILE}"
|
||||||
|
end
|
||||||
|
end
|
40
rakelib/init.rake
Normal file
40
rakelib/init.rake
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
desc "Create a central bare repository from the local repository."
|
||||||
|
task :init_repo do
|
||||||
|
repo_id = File.basename(Dir.getwd)
|
||||||
|
repo_path = "/srv/git/#{repo_id}.git"
|
||||||
|
post_receive = "/usr/bin/kgb-client --git-reflog - --conf /etc/kgb-client/kgb.conf --repository git --repo-id #{repo_id}"
|
||||||
|
|
||||||
|
commands = [
|
||||||
|
"mkdir #{repo_path}",
|
||||||
|
"cd #{repo_path}",
|
||||||
|
"git init --bare",
|
||||||
|
# For HTTP access such as gitweb
|
||||||
|
"mv hooks/post-update.sample hooks/post-update",
|
||||||
|
# For KGB to send commit notifications over IRC.
|
||||||
|
# This still requires additional server-side configuration, see
|
||||||
|
# http://my.agaric.com/agaric/node/11694
|
||||||
|
"echo #{post_receive} >> hooks/post-receive",
|
||||||
|
"chmod a+x hooks/post-receive"
|
||||||
|
].join(" && ")
|
||||||
|
sh "ssh git.agaric.com '#{commands}'"
|
||||||
|
sh "git remote add origin git.agaric.com:#{repo_path}"
|
||||||
|
sh "git push origin master"
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Add .gitignore file with basic project specific patterns."
|
||||||
|
task ".gitignore" do
|
||||||
|
open(".gitignore", "a") do |f|
|
||||||
|
f.puts ".sass-cache/"
|
||||||
|
f.puts ".vagrant/"
|
||||||
|
f.puts "build/"
|
||||||
|
f.puts "web/sites/default/settings.php"
|
||||||
|
f.puts "web/sites/default/files/"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Add .gitattributes file with basic project specific patterns."
|
||||||
|
task ".gitattributes" do
|
||||||
|
open(".gitattributes", "a") do |f|
|
||||||
|
f.puts "etc export-ignore"
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue