diff --git a/.kitchen.yml b/.kitchen.yml index 25bc2a8..6cf20c0 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -1,15 +1,3 @@ -<% - # Use the runlist, attributes and other settings defined in node.json to - # ensure .kitchen.yml runs against the exact same configuration as Vagrantfile. - require 'json' - if !File.exist?('install_cypress_cvu.json') - puts 'Aborting .kitchen.yml: required install_cypress_cvu.json does not exist' - exit - else - node = JSON.parse(File.read('install_cypress_cvu.json')) - end -%> ---- driver: name: vagrant customize: diff --git a/README.md b/README.md index 800e62a..9ed73cd 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ ## About -This recipe is designed to make it easier to deploy cypress quickly. +This recipe is designed to make it easier to deploy RabbitMQ and Js-Ecqm-Engine quickly. ### What it doesn't do: -- It will not download and import the measure bundle (see section on Importing Measure Bundle below) -- It will not set up proxy settings -- Does not configure networking +- It will not download and install popHealth + ## Installation Options This recipe has been tested to work on Ubuntu 16.04 using the following install method: @@ -14,38 +13,15 @@ This recipe has been tested to work on Ubuntu 16.04 using the following install sudo apt-get update sudo apt-get -y install git-core wget - wget https://packages.chef.io/files/stable/chefdk/1.5.0/ubuntu/16.04/chefdk_1.5.0-1_amd64.deb - sudo dpkg -i chefdk_1.5.0-1_amd64.deb - git clone https://github.com/projectcypress/cypress-recipe.git - cd cypress-recipe + wget https://packages.chef.io/files/stable/chefdk/2.0.26/ubuntu/16.04/chefdk_2.0.26-1_amd64.deb + sudo dpkg -i chefdk_2.0.26-1_amd64.deb + git clone https://github.com/giriraj0209/js-ecqm-engine-recipe.git + cd js-ecqm-engine-recipe berks vendor cookbooks -You will now need to decide between whether you want to install cypress and the cypress validation utility, only cypress, or only the cypress validation utility. - -To install Cypress + Cypress Validation Utility run - - sudo chef-client -z -j install_cypress_cvu.json - -To install Cypress only run - - sudo chef-client -z -j install_cypress.json - -To install the Cypress Validation Utility only run - - sudo chef-client -z -j install_cvu.json - -If you need to install both cypress and the cypress validation utility, make sure you run the first command, attempting to run the second and third installation commands in conjunction will not work properly. - -Instructions for importing a bundle can be found [here](https://github.com/projectcypress/cypress/wiki/Cypress-4-Initial-Setup). - -## Developing using Test Kitchen -If you wish to stand up a local copy of this recipe for testing, there is a test kitchen script included in this repository. If you have never installed test kitchen before, then you will need to do so along with downloading a few other tools. Please follow the steps below before running the `kitchen test` command from the directory you have this repository cloned into. +To install Js-Ecqm-Engine run -1. Install [Vagrant](http://www.vagrantup.com/downloads.html) ">= 1.5.2" -2. Install [Virtualbox](https://www.virtualbox.org/) ">= 4.3.14" -3. Install [ChefDK](https://downloads.chef.io/chefdk) ">= 0.2.0" -4. Run `bundle install` in the root of this repository. + sudo chef-client -z -j install_ecqmEngine.json -Once those steps are completed, you should be able to execute `bundle exec kitchen test` with no problems. diff --git a/attributes/default.rb b/attributes/default.rb index c7395b9..817eeee 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,33 +1,15 @@ -# ATL Version (cypress only) ENV Vars -default[:cypress][:cypress_env_vars] = +default[:ecqmEngine][:ecqmEngine_env_vars] = { "AUTO_APPROVE" => "false", "IGNORE_ROLES" => "false", "ENABLE_DEBUG_FEATURES" => "false", "DEFAULT_ROLE" => "", } -default[:cypress][:cypress_internal_port] = 8000 -# this is the path which Cypress will install itself to, this is not the -# place to configure it however! The Cypress package specifies itself -# where it will install to, so you will need to recompile to package -# to change it. The same applies to the cvu_install_path below. -default[:cypress][:cypress_install_path] = '/opt/cypress' -default[:cypress][:cvu_install_path] = '/opt/cypress-validation-utility' -default[:cypress][:js_ecqm_install_path] = '/opt/js-ecqm-engine' -default[:cypress][:cypress_repository] = 'https://dl.packager.io/srv/deb/projectcypress/cypress/cypress_v4/ubuntu' -default[:cypress][:cvu_repository] = 'https://dl.packager.io/srv/deb/projectcypress/cypress-validation-utility/cvu_v4/ubuntu' -default[:cypress][:js_ecqm_repository] = 'https://dl.packager.io/srv/deb/projectcypress/js-ecqm-engine/release/ubuntu' -default[:cypress][:cypress_repository_key] = 'https://dl.packager.io/srv/projectcypress/cypress/key' -default[:cypress][:cvu_repository_key] = 'https://dl.packager.io/srv/projectcypress/cypress-validation-utility/key' -default[:cypress][:js_ecqm_repository_key] = 'https://dl.packager.io/srv/projectcypress/js-ecqm-engine/key' -# Blank version means latest build, anything else will attempt to install -# a specific version from the repository. -default[:cypress][:cypress_version] = '' -default[:cypress][:cvu_version] = '' -default[:cypress][:js_ecqm_version] = '' -default[:cypress][:cvu_internal_port] = 8001 -default[:cypress][:cvu_external_port] = 8080 -default[:cypress][:generate_secrets_on_restart] = false + +default[:ecqmEngine][:js_ecqm_install_path] = '/opt/js-ecqm-engine' +default[:ecqmEngine][:js_ecqm_repository] = 'https://dl.packager.io/srv/deb/giriraj0209/js-ecqm-engine/master/ubuntu' +default[:ecqmEngine][:js_ecqm_repository_key] = 'https://dl.packager.io/srv/giriraj0209/js-ecqm-engine/key' +default[:ecqmEngine][:js_ecqm_version] = '' force_default['erlang']['install_method'] = "esl" force_default['erlang']['esl']['version'] = "1:20.3.6" diff --git a/files/default/mongod.conf b/files/default/mongod.conf index 7bad405..14dbe76 100644 --- a/files/default/mongod.conf +++ b/files/default/mongod.conf @@ -23,6 +23,6 @@ net: port: 27017 bindIp: 127.0.0.1 -# higher max bson depth is required for cypress + bonnie on mongo 3.4.4+ +# higher max bson depth is required on mongo 3.4.4+ setParameter: maxBSONDepth: 500 diff --git a/install_cvu.json b/install_cvu.json deleted file mode 100644 index 755664d..0000000 --- a/install_cvu.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "run_list": [ "recipe[apt]", "recipe[cypress::install_cvu]" ] -} diff --git a/install_cypress.json b/install_cypress.json deleted file mode 100644 index 5885dc7..0000000 --- a/install_cypress.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "run_list": [ "recipe[apt]", "recipe[cypress::install_cypress]" ] -} diff --git a/install_cypress_cvu.json b/install_cypress_cvu.json deleted file mode 100644 index e5bb591..0000000 --- a/install_cypress_cvu.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "run_list": [ "recipe[apt]", "recipe[cypress::default]" ] -} diff --git a/install_ecqmEngine.json b/install_ecqmEngine.json new file mode 100644 index 0000000..62fd82a --- /dev/null +++ b/install_ecqmEngine.json @@ -0,0 +1,3 @@ +{ + "run_list": [ "recipe[apt]", "recipe[ecqmEngine::install_ecqmEngine]" ] +} diff --git a/metadata.rb b/metadata.rb index cda52a5..86deae6 100644 --- a/metadata.rb +++ b/metadata.rb @@ -1,8 +1,8 @@ -name 'cypress' -maintainer 'MITRE' -maintainer_email 'mokeefe@mitre.org' +name 'ecqmEngine' +maintainer 'OSEHRA' +maintainer_email '' license 'All rights reserved' -description 'Installs/Configures Cypress' +description 'Installs/Configures Js-ecqm-engine' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version '2.0.0' depends "apt", "~> 6.1" diff --git a/providers/install_app.rb b/providers/install_app.rb index 2876e33..5f06712 100644 --- a/providers/install_app.rb +++ b/providers/install_app.rb @@ -52,9 +52,9 @@ # Lock the version to whatever is installed by # this Chef recipe in order to require the user - # to run the upgrade script to upgrade Cypress + # to run the upgrade script to upgrade ecqmEngine # and also protect the user from accidently - # upgrading Cypress when they did not intend to + # upgrading ecqmEngine when they did not intend to [ :install, :lock ].each do |install_action| package new_resource.name do action install_action @@ -71,63 +71,16 @@ # Set all ENV variables passed in through the env_vars hash # for the application new_resource.env_vars.each do |key, value| - cypress_pkgr_env new_resource.name do + ecqmEngine_pkgr_env new_resource.name do key key value value end end - # Configure the port which the application should run on - cypress_pkgr_env new_resource.name do - key "PORT" - value new_resource.unicorn_port.to_s - only_if { new_resource.frontend_worker_count > 0 } - end - - cypress_pkgr_env new_resource.name do - key "web" - value new_resource.frontend_worker_count.to_s - action :scale - end - - cypress_pkgr_env new_resource.name do + ecqmEngine_pkgr_env new_resource.name do key "worker" value new_resource.delayed_job_count.to_s action :scale end - package 'nginx' do - action :install - only_if { new_resource.frontend_worker_count > 0 } - end - - # Setup nginx configuration - template "/etc/nginx/sites-enabled/default" do - source "nginx.conf.erb" - mode "644" - variables({ - :primary_app_path => install_path, - :primary_app_port => new_resource.unicorn_port, - :enable_secondary_app => false - }) - only_if { new_resource.frontend_worker_count > 0 } - end - - template '/etc/systemd/system/regenerate-secrets.service' do - source "regenerate-secrets.service.erb" - variables({ - :service_names => [ new_resource.name ] - }) - only_if { new_resource.generate_secrets_on_restart } - end - - service "regenerate-secrets" do - action [:enable] - only_if { new_resource.generate_secrets_on_restart } - end - - service "nginx" do - action :restart - only_if { new_resource.frontend_worker_count > 0 } - end end diff --git a/recipes/default.rb b/recipes/default.rb deleted file mode 100644 index e034c83..0000000 --- a/recipes/default.rb +++ /dev/null @@ -1,44 +0,0 @@ -# precertification version (cypress+cvu) ENV vars -node.default[:cypress][:cypress_env_vars] = -{ - "AUTO_APPROVE" => "true", - "IGNORE_ROLES" => "true", - "ENABLE_DEBUG_FEATURES" => "true", - "DEFAULT_ROLE" => "", -} - -include_recipe "cypress::install_cypress" -include_recipe "cypress::install_cvu" - -template "/etc/nginx/sites-enabled/default" do - source "nginx.conf.erb" - mode "644" - variables({ - :primary_app_path => node[:cypress][:cypress_install_path], - :primary_app_port => node[:cypress][:cypress_internal_port], - :enable_secondary_app => true, - :secondary_app_path => node[:cypress][:cvu_install_path], - :secondary_app_port => node[:cypress][:cvu_internal_port], - :secondary_app_ext_port => node[:cypress][:cvu_external_port], - }) -end - -service "nginx" do - action :restart -end - -template '/etc/systemd/system/regenerate-secrets.service' do - source "regenerate-secrets.service.erb" - variables({ - :service_names => [ - node[:cypress][:cypress_install_path].split("/").last, - node[:cypress][:cvu_install_path].split("/").last - ] - }) - only_if { node[:cypress][:generate_secrets_on_restart] } -end - -service "regenerate-secrets" do - action [:enable] - only_if { node[:cypress][:generate_secrets_on_restart] } -end diff --git a/recipes/install_cvu.rb b/recipes/install_cvu.rb deleted file mode 100644 index 3a4852b..0000000 --- a/recipes/install_cvu.rb +++ /dev/null @@ -1,9 +0,0 @@ -cypress_install_app 'cypress-validation-utility' do - application_path node[:cypress][:cvu_install_path] - application_version node[:cypress][:cvu_version] - repository node[:cypress][:cvu_repository] - repository_key node[:cypress][:cvu_repository_key] - delayed_job_count 0 - unicorn_port node[:cypress][:cvu_internal_port] - generate_secrets_on_restart node[:cypress][:generate_secrets_on_restart] -end diff --git a/recipes/install_cypress.rb b/recipes/install_cypress.rb deleted file mode 100644 index 09218a9..0000000 --- a/recipes/install_cypress.rb +++ /dev/null @@ -1,26 +0,0 @@ -include_recipe 'rabbitmq' - -cypress_install_app 'js-ecqm-engine' do - application_path node[:cypress][:js_ecqm_install_path] - application_version node[:cypress][:js_ecqm_version] - repository node[:cypress][:js_ecqm_repository] - repository_key node[:cypress][:js_ecqm_repository_key] - frontend_worker_count 0 - generate_secrets_on_restart false -end - -# This is necessary due to https://github.com/rabbitmq/chef-cookbook/commit/c7a37ccfcfe2444d0ff8f567c33da0be055357f8 -package 'esl-erlang' do - action :lock - version node['erlang']['esl']['version'] -end - -cypress_install_app 'cypress' do - application_path node[:cypress][:cypress_install_path] - application_version node[:cypress][:cypress_version] - repository node[:cypress][:cypress_repository] - repository_key node[:cypress][:cypress_repository_key] - env_vars node[:cypress][:cypress_env_vars] - unicorn_port node[:cypress][:cypress_internal_port] - generate_secrets_on_restart node[:cypress][:generate_secrets_on_restart] -end diff --git a/recipes/install_ecqmEngine.rb b/recipes/install_ecqmEngine.rb new file mode 100644 index 0000000..240a7bc --- /dev/null +++ b/recipes/install_ecqmEngine.rb @@ -0,0 +1,14 @@ +include_recipe 'rabbitmq' + +ecqmEngine_install_app 'js-ecqm-engine' do + application_path node[:ecqmEngine][:js_ecqm_install_path] + application_version node[:ecqmEngine][:js_ecqm_version] + repository node[:ecqmEngine][:js_ecqm_repository] + repository_key node[:ecqmEngine][:js_ecqm_repository_key] +end + +# This is necessary due to https://github.com/rabbitmq/chef-cookbook/commit/c7a37ccfcfe2444d0ff8f567c33da0be055357f8 +package 'esl-erlang' do + action :lock + version node['erlang']['esl']['version'] +end \ No newline at end of file diff --git a/resources/install_app.rb b/resources/install_app.rb index 1dc6961..ceca6f3 100644 --- a/resources/install_app.rb +++ b/resources/install_app.rb @@ -1,16 +1,9 @@ default_action :create attribute :name, :kind_of => String -attribute :unicorn_port, :kind_of => Integer, :default => 8000 attribute :repository, :kind_of => String attribute :repository_key, :kind_of => String attribute :application_path, :kind_of => String attribute :application_version, :kind_of => String -# Set app to run with 1 frontend unicorn worker. Note that -# any setting inside of config/unicorn.rb in the application is -# still respected to 1 web worker is actually 1 web worker with -# 4 worker processes if worker_processes is set to 4, for example. -attribute :frontend_worker_count, :kind_of => Integer, :default => 1 attribute :delayed_job_count, :kind_of => Integer, :default => 3 attribute :env_vars, :kind_of => Hash, :default => {} -attribute :generate_secrets_on_restart, :kind_of => [TrueClass, FalseClass], :default => false diff --git a/templates/default/delayed_worker_systemd.conf.erb b/templates/default/delayed_worker_systemd.conf.erb deleted file mode 100644 index 97594d7..0000000 --- a/templates/default/delayed_worker_systemd.conf.erb +++ /dev/null @@ -1,18 +0,0 @@ -[Unit] -Description=delayed_worker_%i -After=mongod.service -Requires=mongod.service - -[Service] -Type=simple -User=<%= @username %> -Environment=RAILS_ENV=<%= @rails_env %> -WorkingDirectory=<%= @rails_app_path %> -ExecStart=/opt/ruby_build/builds<%= @rails_app_path %>/bin/bundle exec rake jobs:work -ExecStartPost=/bin/mkdir -p ./tmp/delayed_pids -ExecStartPost=-/usr/bin/touch ./tmp/delayed_pids/delayed_job.%i.running -ExecStopPost=/bin/rm ./tmp/delayed_pids/delayed_job.%i.running -TimeoutSec=120 - -[Install] -WantedBy=multi-user.target diff --git a/templates/default/nginx.conf.erb b/templates/default/nginx.conf.erb deleted file mode 100644 index 77430fe..0000000 --- a/templates/default/nginx.conf.erb +++ /dev/null @@ -1,58 +0,0 @@ -upstream primary { - server 127.0.0.1:<%= @primary_app_port %>; -} - -<% if @enable_secondary_app -%> -upstream secondary { - server 127.0.0.1:<%= @secondary_app_port %>; -} -<% end -%> - -server { - listen 80; - server_name _; - - root <%= @primary_app_path %>/public; - - try_files $uri/index.html $uri @app; - - location @app { - proxy_pass http://primary; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; - proxy_redirect off; - } - - <% if @enable_secondary_app -%> - location /cvu { - return 301 http://$host:<%= @secondary_app_ext_port %>; - } - <% end -%> - - error_page 500 502 503 504 /500.html; - client_max_body_size 4G; - keepalive_timeout 10; -} - -<% if @enable_secondary_app -%> -server { - listen <%= @secondary_app_ext_port %>; - server_name _; - - root <%= @secondary_app_path %>/public; - - try_files $uri/index.html $uri @app; - - location @app { - proxy_pass http://secondary; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; - proxy_redirect off; - } - - error_page 500 502 503 504 /500.html; - client_max_body_size 4G; - keepalive_timeout 10; -} -<% end -%> - diff --git a/templates/default/regenerate-secrets.service.erb b/templates/default/regenerate-secrets.service.erb deleted file mode 100644 index 63e59eb..0000000 --- a/templates/default/regenerate-secrets.service.erb +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=Regenerate <%= @service_names.join(', ') %> secret keys -<% @service_names.each do |service| %> -Before=<%= service %>.service -<% end %> - -[Service] -Type=oneshot -<% @service_names.each do |service| %> -ExecStart=/bin/sh -c "/usr/bin/<%= service %> config:set SECRET_KEY_BASE=$(/usr/bin/<%= service %> run rake secret)" -<% end %> -ExecStartPost=/bin/systemctl disable regenerate-secrets.service - -[Install] -WantedBy=multi-user.target diff --git a/test/integration/default/default_spec.rb b/test/integration/default/default_spec.rb index e662fbb..bcf1f32 100644 --- a/test/integration/default/default_spec.rb +++ b/test/integration/default/default_spec.rb @@ -1,37 +1,8 @@ -describe service 'nginx' do - it { should be_installed } - it { should be_running } -end - describe service 'mongod' do it { should be_enabled } it { should be_running } end -describe service 'cypress' do - it { should be_enabled } - it { should be_running } -end - -describe service 'cypress-validation-utility' do - it { should be_enabled } - it { should be_running } -end - -describe command 'curl localhost/users/sign_in' do - its('stdout') { should match /Sign In/ } - its('stdout') { should match /Sign up/ } - its('stdout') { should match /Cypress/ } -end - -describe port 80 do - it { should be_listening } -end - -describe port 8080 do - it { should be_listening } -end - describe command 'cat /sys/kernel/mm/transparent_hugepage/enabled' do its('stdout') { should match /\[never\]/ } end