Self Hosting Primero v2 - issue with primero application container

Hello,

I’m trying to self host Primero following this tutorial: Self Hosting Primero v2 - Installation - everything works fine until the ansible-playbook application-primero.yml --tags configure,start step. All containers are created but the application container (primero_application_1) doesn’t properly start; this is the error from container logs:

! Unable to load application: NoMethodError: undefined method `each' for nil:NilClass
bundler: failed to load command: puma (/usr/local/bundle/bin/puma)
NoMethodError: undefined method `each' for nil:NilClass
  /usr/local/bundle/gems/i18n-1.12.0/lib/i18n/backend/fallbacks.rb:47:in `translate'
  /usr/local/bundle/gems/i18n-1.12.0/lib/i18n.rb:363:in `block in translate_key'
  /usr/local/bundle/gems/i18n-1.12.0/lib/i18n.rb:362:in `catch'
  /usr/local/bundle/gems/i18n-1.12.0/lib/i18n.rb:362:in `translate_key'
  /usr/local/bundle/gems/i18n-1.12.0/lib/i18n.rb:222:in `translate'
  /srv/primero/application/app/models/filter.rb:12:in `block in <class:Filter>'
  /srv/primero/application/app/models/filter.rb:11:in `map'
  /srv/primero/application/app/models/filter.rb:11:in `<class:Filter>'
  /srv/primero/application/app/models/filter.rb:5:in `<top (required)>'
  /usr/local/bundle/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:27:in `require'
  /usr/local/bundle/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:27:in `require'
  /usr/local/bundle/gems/zeitwerk-2.6.0/lib/zeitwerk/loader/helpers.rb:127:in `const_get'
  /usr/local/bundle/gems/zeitwerk-2.6.0/lib/zeitwerk/loader/helpers.rb:127:in `cget'
  /usr/local/bundle/gems/zeitwerk-2.6.0/lib/zeitwerk/loader.rb:239:in `block (2 levels) in eager_load'
  /usr/local/bundle/gems/zeitwerk-2.6.0/lib/zeitwerk/loader/helpers.rb:41:in `block in ls'
  /usr/local/bundle/gems/zeitwerk-2.6.0/lib/zeitwerk/loader/helpers.rb:27:in `each'
  /usr/local/bundle/gems/zeitwerk-2.6.0/lib/zeitwerk/loader/helpers.rb:27:in `ls'
  /usr/local/bundle/gems/zeitwerk-2.6.0/lib/zeitwerk/loader.rb:234:in `block in eager_load'
  /usr/local/bundle/gems/zeitwerk-2.6.0/lib/zeitwerk/loader.rb:219:in `synchronize'
  /usr/local/bundle/gems/zeitwerk-2.6.0/lib/zeitwerk/loader.rb:219:in `eager_load'
  /usr/local/bundle/gems/zeitwerk-2.6.0/lib/zeitwerk/loader.rb:318:in `each'
  /usr/local/bundle/gems/zeitwerk-2.6.0/lib/zeitwerk/loader.rb:318:in `eager_load_all'
  /usr/local/bundle/gems/railties-6.1.6.1/lib/rails/application/finisher.rb:133:in `block in <module:Finisher>'
  /usr/local/bundle/gems/railties-6.1.6.1/lib/rails/initializable.rb:32:in `instance_exec'
  /usr/local/bundle/gems/railties-6.1.6.1/lib/rails/initializable.rb:32:in `run'
  /usr/local/bundle/gems/railties-6.1.6.1/lib/rails/initializable.rb:61:in `block in run_initializers'
  /usr/local/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
  /usr/local/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
  /usr/local/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
  /usr/local/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
  /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `each'
  /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `call'
  /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
  /usr/local/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
  /usr/local/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
  /usr/local/bundle/gems/railties-6.1.6.1/lib/rails/initializable.rb:60:in `run_initializers'
  /usr/local/bundle/gems/railties-6.1.6.1/lib/rails/application.rb:391:in `initialize!'
  /srv/primero/application/config/environment.rb:7:in `<top (required)>'
  config.ru:8:in `require'
  config.ru:8:in `block in <main>'
  /usr/local/bundle/gems/rack-2.2.4/lib/rack/builder.rb:116:in `eval'
  /usr/local/bundle/gems/rack-2.2.4/lib/rack/builder.rb:116:in `new_from_string'
  /usr/local/bundle/gems/rack-2.2.4/lib/rack/builder.rb:105:in `load_file'
  /usr/local/bundle/gems/rack-2.2.4/lib/rack/builder.rb:66:in `parse_file'
  /usr/local/bundle/gems/puma-4.3.12/lib/puma/configuration.rb:321:in `load_rackup'
  /usr/local/bundle/gems/puma-4.3.12/lib/puma/configuration.rb:246:in `app'
  /usr/local/bundle/gems/puma-4.3.12/lib/puma/runner.rb:155:in `load_and_bind'
  /usr/local/bundle/gems/puma-4.3.12/lib/puma/single.rb:98:in `run'
  /usr/local/bundle/gems/puma-4.3.12/lib/puma/launcher.rb:172:in `run'
  /usr/local/bundle/gems/puma-4.3.12/lib/puma/cli.rb:80:in `run'
  /usr/local/bundle/gems/puma-4.3.12/bin/puma:10:in `<top (required)>'
  /usr/local/bundle/bin/puma:23:in `load'
  /usr/local/bundle/bin/puma:23:in `<top (required)>'

I would check that all the migrations ran correctly. There is a rake task to manually run the migrations.
Please also be aware that the version of postgresql installed currently with ansible (10) will be EOL in November. If this is a production system you are strongly advised to wait until we upgrade to postgresql 14 which is scheduled to happen with the 2.5.0 release. It should be up on the develop branch by next week if you want to take a look at that

I’ve started the entire installation process from the beginning and updated the locale_all field from inventory/inventory.yml file. Initially I’ve added the Ukrainian language which is not present in locales_fallbacks.rb file which caused the application container to crash.

Additionally I noticed that while following the installation steps from the tutorial there were some errors with SystemSettings model which I solved by manually creating additional columns in system_settings table:

ALTER TABLE system_settings  
ADD COLUMN notification_email_enabled boolean;
 
ALTER TABLE system_settings  
ADD COLUMN welcome_email_enabled boolean;
 
ALTER TABLE system_settings  
ADD COLUMN approvals_labels_ar jsonb;

Now that we have managed to install the production environment, what are the next steps to migrate the data to self hosted environment?

#1 how do we export and import all the data from the current production into the new environment
#2 how do we link the demo instance with the production instance so that we can deploy new configurations
#3 do you have any other documentation about migration besides this one Self Hosting Primero v2 - Installation

#1 There is definitely no tooling to move production data like that. It would need to follow kind of the same procedure as when doing a postgres upgrade. The issue is the access to the production data to do such a thing is obviously restricted so you would need to request someone do that for you.

#2 The prod host is set in a variable on the demo server like PRIMERO_PROMOTE_CONFIG_PROD_HOST: "your.host.gov". You also need to add promotion authentication to the secrets.yml and install that on the prod server using ansible

#3 This use case has not come up before. Tier 4 deployments →
https://support.primero.org/assets/books-v2/1BFkifvpZ_zUvHVLJRr7wUlj2secIopt0KF2VHmR6mPI/ need to be done by someone with permissioned access to the demo server. If you just want to see how the process works I would suggest setting up a demo and prod server and then setting the env variables on both and then see if you can get config promotion working