Skip to content
This repository has been archived by the owner on Jun 13, 2019. It is now read-only.

Commit

Permalink
T/wpt vagrant (#1069)
Browse files Browse the repository at this point in the history
 * vagrant setup for WPT
 * general support for MySQL 5.7 in vagrant
 * fixes for 16.04

Related:
easybib/issues#5617
easybib/sbm-issues#255
  • Loading branch information
till committed Jul 29, 2016
1 parent bc2c4a9 commit b4c9da6
Show file tree
Hide file tree
Showing 17 changed files with 131 additions and 17 deletions.
5 changes: 2 additions & 3 deletions VERSIONS.md
@@ -1,6 +1,5 @@
Package | External Version | Comment
------------ | ------------- | -------------

apt | [2.6.1](https://github.com/opscode-cookbooks/apt/tree/v2.6.1) |
ark | [0.9.0](https://github.com/burtlo/ark/tree/v0.9.0) | removed 7-zip and windows dep
build-essential | [2.0.2](https://github.com/opscode-cookbooks/build-essential/tree/v2.0.2) |
Expand All @@ -10,7 +9,7 @@ cron | [1.3.12](https://github.com/opscode-cookbooks/cron/tree/v1.3.12) | - We
erlang | [1.5.6](https://github.com/opscode-cookbooks/erlang/commit/2af91e4650c1411fbf8e44626b1a548f777926c4) | ignored in our cs/test setup
fail2ban | 2.2.1 | removed yum dependencies, adapted to our rubocop scheme, changed attributes/default.rb
logrotate | [master](https://github.com/stevendanna/logrotate/commit/7d9b87791f8e7ba64e23121c0faddad7779d45ba) |
mysql | [6.1.2](https://github.com/chef-cookbooks/mysql/commit/4ba145f2d6e5fd710ba586bc86d9f78e35fbfa60) | disabled yum and smf deps
mysql | [6.1.2](https://github.com/chef-cookbooks/mysql/commit/4ba145f2d6e5fd710ba586bc86d9f78e35fbfa60) | disabled yum and smf deps, hacked 16.04 version in
nodejs | [2.4.0](https://github.com/redguide/nodejs/releases/tag/v2.4.0) | disabled deps on `homebrew` and `yum-epel`, added new install method in [d606ee](https://github.com/till/easybib-cookbooks/commit/d606ee9851390458e390a44875afaecc5277c219) and a minor [bugfix](https://github.com/till/easybib-cookbooks/commit/da0895e9f3813d7bf6e646fec2615a4756e3039d)
ohai| [2.0.4](https://github.com/chef-cookbooks/ohai/commit/bc6b53ff9807cd02d5cea86f18470a81e7678771) |
papertrail | [#21](https://github.com/librato/papertrail-cookbook/pull/21) | PR 21 is 0.0.7 + priority fix
Expand All @@ -20,7 +19,7 @@ rsyslog | [2.2.0](https://github.com/chef-cookbooks/rsyslog/releases/tag/v2.2.0)
runit | [master](https://github.com/hw-cookbooks/runit/commit/1ebeffa0f907811302a22b137015012ed6f11193) | dependency on packagecloud disabled
rvm | [0.9.4](https://github.com/martinisoft/chef-rvm/tree/v0.9.4) | removed chef_gem dependency
sinopia | [0.3.0](https://github.com/BarthV/sinopia-cookbook/releases/tag/0.3.0) | removed dependency `user` cookbook, fix: use user resource
supervisor | [master](https://github.com/poise/supervisor/commit/0806cb6fccfdaf3da5959ce9c2bc42287ad50b26) |
supervisor | [master](https://github.com/poise/supervisor/commit/0806cb6fccfdaf3da5959ce9c2bc42287ad50b26) | ...
vagrant | [0.4.2](https://github.com/jtimberman/vagrant-cookbook/releases/tag/v0.4.2) | disabled dependency on dmg and windows, removed tests and matcher, removed vagrant_plugin
virtualbox | 1.0.3 | disabled dependency on yum, dmg, windows and apache2
xml| [1.2.4](https://github.com/opscode-cookbooks/xml/tree/v1.2.4) |
12 changes: 11 additions & 1 deletion fake-s3/recipes/default.rb
@@ -1,14 +1,24 @@
include_recipe 'supervisor'

unless is_aws
conf = node['fake-s3']

s3_bin = '/usr/local/bin/fakes3'

gem_package 'fakes3' do
version conf['version']
end

# installed chef inside vagrant box demands this
link s3_bin do
to '/opt/chef/embedded/bin/fakes3'
only_if { File.exist?('/opt/chef/embedded/bin/fakes3') }
end

supervisor_service 'fakes3' do
action :enable
autostart true
command "/usr/local/bin/fakes3 -r #{conf['storage']} -p #{conf['port']}"
command "#{s3_bin} -r #{conf['storage']} -p #{conf['port']}"
user 'nobody'
end
end
11 changes: 11 additions & 0 deletions fake-s3/spec/default_spec.rb
Expand Up @@ -6,11 +6,22 @@
end

let(:chef_run) { runner.converge(described_recipe) }
let(:chef_s3) { '/opt/chef/embedded/bin/fakes3' }

before do
File.stub(:exist?).and_call_original
File.stub(:exist?).with(chef_s3).and_return(true)
end

it 'installs the gem' do
expect(chef_run).to install_gem_package('fakes3')
end

it 'links fakes3 to /usr/local/bin' do
link = chef_run.link('/usr/local/bin/fakes3')
expect(link).to link_to(chef_s3)
end

it 'it starts the fake-s3 service via supervisord' do
expect(chef_run).to enable_supervisor_service('fakes3')
end
Expand Down
3 changes: 3 additions & 0 deletions fake-sqs/attributes/default.rb
@@ -0,0 +1,3 @@
default['fake-sqs'] = {
'version' => '0.3.1'
}
17 changes: 13 additions & 4 deletions fake-sqs/recipes/default.rb
@@ -1,15 +1,24 @@
include_recipe 'supervisor'

unless is_aws
::Chef::Log.info('SQS - installing fake_sqs...')
conf = node['fake-sqs']

sqs_bin = '/usr/local/bin/fake_sqs'

gem_package 'fake_sqs' do
version '0.3.1'
version conf['version']
end
::Chef::Log.info('SQS - configuring supervisor...')

# installed chef inside vagrant box demands this
link sqs_bin do
to '/opt/chef/embedded/bin/fake_sqs'
only_if { File.exist?('/opt/chef/embedded/bin/fake_sqs') }
end

supervisor_service 'fake_sqs' do
action :enable
autostart true
command '/usr/local/bin/fake_sqs'
command sqs_bin
user 'nobody'
end
end
11 changes: 11 additions & 0 deletions fake-sqs/spec/default_spec.rb
Expand Up @@ -6,6 +6,17 @@
end

let(:chef_run) { runner.converge(described_recipe) }
let(:chef_sqs) { '/opt/chef/embedded/bin/fake_sqs' }

before do
File.stub(:exist?).and_call_original
File.stub(:exist?).with(chef_sqs).and_return(true)
end

it 'links fakesqs to /usr/local/bin' do
link = chef_run.link('/usr/local/bin/fake_sqs')
expect(link).to link_to(chef_sqs)
end

it 'it starts the fakesqs service via supervisord' do
expect(chef_run).to enable_supervisor_service('fake_sqs')
Expand Down
3 changes: 3 additions & 0 deletions ies-mysql/files/default/grant57.sql
@@ -0,0 +1,3 @@
CREATE USER IF NOT EXISTS 'vagrant'@'%';
GRANT ALL PRIVILEGES ON *.* TO 'vagrant'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
8 changes: 7 additions & 1 deletion ies-mysql/recipes/default.rb
Expand Up @@ -2,12 +2,18 @@

server_config = node['ies-mysql']['server-config']

mysql_service_provider = if node['platform_version'] == '16.04'
Chef::Provider::MysqlServiceSystemd
else
Chef::Provider::MysqlServiceUpstart
end

mysql_service server_config['instance-name'] do
version mysql_version
bind_address server_config['bind-address']
port server_config['port']
initial_root_password server_config['password']
provider Chef::Provider::MysqlServiceUpstart
provider mysql_service_provider
action [:create, :start]
end

Expand Down
16 changes: 12 additions & 4 deletions ies-mysql/recipes/dev.rb
@@ -1,8 +1,16 @@
# Grant root access from *!
# Obviously not a good idea in production.

cookbook_file '/tmp/grant.sql' do
source 'grant.sql'
mysql_version = node['ies-mysql']['version']

grant_file = if mysql_version == '5.6'
'grant.sql'
else
'grant57.sql'
end

cookbook_file "/tmp/#{grant_file}" do
source grant_file
mode '0600'
not_if { is_aws(node) }
end
Expand All @@ -11,8 +19,8 @@

mysql_command = "mysql -u #{server_config['user']}"
mysql_command += " -p#{server_config['password']}" unless server_config['password'].empty?
mysql_command += ' -h 127.0.0.1'
mysql_command += ' < /tmp/grant.sql'
mysql_command += ' -h 127.0.0.1' if mysql_version == '5.6'
mysql_command += " < /tmp/#{grant_file}"

execute 'open mysql to the world' do
command mysql_command
Expand Down
10 changes: 10 additions & 0 deletions ies-mysql/spec/dev_spec.rb
Expand Up @@ -15,6 +15,16 @@
end
end

describe 'MySQL 5.7' do
before do
node.set['ies-mysql']['version'] = '5.7'
end

it 'renders new grants' do
expect(chef_run).to create_cookbook_file('/tmp/grant57.sql')
end
end

describe 'AWS' do
before do
node.set['opsworks'] = {}
Expand Down
4 changes: 4 additions & 0 deletions mysql/libraries/helpers.rb
Expand Up @@ -280,6 +280,10 @@ def self.pkginfo
@pkginfo.set['debian']['14.10']['5.6']['server_package'] = 'mysql-server-5.6'
@pkginfo.set['debian']['15.04']['5.6']['client_package'] = %w(mysql-client-5.6 libmysqlclient-dev)
@pkginfo.set['debian']['15.04']['5.6']['server_package'] = 'mysql-server-5.6'
@pkginfo.set['debian']['16.04']['5.6']['client_package'] = %w(mysql-client libmysqlclient-dev)
@pkginfo.set['debian']['16.04']['5.6']['server_package'] = 'mysql-server'
@pkginfo.set['debian']['16.04']['5.7']['client_package'] = %w(mysql-client-5.7 libmysqlclient-dev)
@pkginfo.set['debian']['16.04']['5.7']['server_package'] = 'mysql-server-5.7'
@pkginfo.set['debian']['6']['5.1']['client_package'] = %w(mysql-client libmysqlclient-dev)
@pkginfo.set['debian']['6']['5.1']['server_package'] = 'mysql-server-5.1'
@pkginfo.set['debian']['7']['5.5']['client_package'] = %w(mysql-client libmysqlclient-dev)
Expand Down
8 changes: 7 additions & 1 deletion nginx-app/recipes/service.rb
@@ -1,5 +1,11 @@
nginx_service_provider = if node['platform_version'] == '16.04'
Chef::Provider::Service::Systemd
else
Chef::Provider::Service::Upstart
end

service 'nginx' do
provider Chef::Provider::Service::Upstart
provider nginx_service_provider
supports :status => true, :restart => true, :reload => true
end

Expand Down
4 changes: 2 additions & 2 deletions php-fpm/recipes/default.rb
Expand Up @@ -45,8 +45,8 @@

include_recipe 'php-fpm::configure'
include_recipe 'php::module-apc'
include_recipe 'php::module-soap'
include_recipe 'php::module-tidy'
include_recipe 'php::module-soap' if node['php-fpm']['packages'].include?('soap')
include_recipe 'php::module-tidy' if node['php-fpm']['packages'].include?('tidy')

expected_prefix = '/usr/local/bin'
install_prefix = "#{node['php-fpm']['exec_prefix']}/bin"
Expand Down
4 changes: 4 additions & 0 deletions php-fpm/spec/default_spec.rb
Expand Up @@ -26,6 +26,10 @@
end

describe 'php.ini refactoring' do
before do
node.set['php-fpm']['packages'] = 'php5-easybib-soap,php5-easybib-tidy'
end

it 'includes module recipes for soap & tidy' do
expect(chef_run).to include_recipe 'php::module-soap'
expect(chef_run).to include_recipe 'php::module-tidy'
Expand Down
8 changes: 7 additions & 1 deletion rsyslogd/recipes/default.rb
@@ -1,5 +1,11 @@
rsyslog_service_provider = if node['platform_version'] == '16.04'
Chef::Provider::Service::Systemd
else
Chef::Provider::Service::Upstart
end

service 'rsyslog' do
provider Chef::Provider::Service::Upstart
provider rsyslog_service_provider
supports :status => true, :restart => true, :reload => true
action [:nothing]
end
Expand Down
6 changes: 6 additions & 0 deletions stack-wpt/metadata.rb
Expand Up @@ -4,3 +4,9 @@

depends 'fake-sqs'
depends 'fake-s3'
depends 'ies-mysql'
depends 'nginx-app'
depends 'ohai'
depends 'php'
depends 'stack-scholar'
depends 'supervisor'
18 changes: 18 additions & 0 deletions stack-wpt/recipes/role-vagrant.rb
@@ -1,2 +1,20 @@
include_recipe 'ohai'
include_recipe 'supervisor'

include_recipe 'ies-mysql'
include_recipe 'ies-mysql::dev'

include_recipe 'fake-sqs'

node.set['fake-s3']['storage'] = '/vagrant_wpt/var/s3'
include_recipe 'fake-s3'

# frontend
# include_recipe 'nodejs'
# include_recipe 'nodejs::npm'
# package 'build-essential'
# package 'g++'

include_recipe 'stack-scholar::role-scholar'
include_recipe 'php::module-pdo_sqlite'
include_recipe 'nginx-app::vagrant-silex'

0 comments on commit b4c9da6

Please sign in to comment.