[SOLVED] Gitlab-ctl reconfigure: Recipe Compile Error in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab-ee/recipes/default.rb

SOLUTION

The alertmanager configuration stanza suggested in /etc/gitlab/gitlab.rb is incorrect. Instead of using the hash key ‘alertmanager’ it should read ‘user’.

@@ -1493,9 +1493,9 @@ alertmanager['enable'] = false
 # alertmanager['log_directory'] = '/var/log/gitlab/alertmanager'
 # alertmanager['admin_email'] = 'admin@example.com'
 # alertmanager['flags'] = {
-#   'web.listen-address' => "#{node['gitlab']['alertmanager']['listen_address']}"
-#   'storage.path' => "#{node['gitlab']['alertmanager']['home']}/data"
-#   'config.file' => "#{node['gitlab']['alertmanager']['home']}/alertmanager.yml"
+#   'web.listen-address' => "#{node['gitlab']['user']['listen_address']}",
+#   'storage.path' => "#{node['gitlab']['user']['home']}/data",
+#   'config.file' => "#{node['gitlab']['user']['home']}/alertmanager.yml",
 # }
 # alertmanager['env_directory'] = '/opt/gitlab/etc/alertmanager/env'
 # alertmanager['env'] = {


This is the result of running gitlab-ctl reconfigure. This first occurred after attempting to upgrade gitlab with apt upgrade gitlab-ee.

As it stands, my GitLab instance is partially installed; dpkg --configure gitlab-ee fails and tells me that I need to run gitlab-ctl reconfigure because a JSON file named for my hostname under /opt/gitlab/embedded/nodes/ is missing attributes. But this error prevents gitlab-ctl reconfigure from completing, leaving an incomplete JSON file.

Can anybody help me get unstuck?

Starting Chef Client, version 14.13.11
resolving cookbooks for run list: ["gitlab-ee"]
Synchronizing Cookbooks:
  - package (0.1.0)
  - gitlab-ee (0.0.1)
  - gitlab (0.0.1)
  - consul (0.1.0)
  - runit (4.3.0)
  - repmgr (0.1.0)
  - postgresql (0.1.0)
  - redis (0.1.0)
  - monitoring (0.1.0)
  - registry (0.1.0)
  - mattermost (0.1.0)
  - gitaly (0.1.0)
  - letsencrypt (0.1.0)
  - nginx (0.1.0)
  - acme (4.0.0)
  - crond (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...

================================================================================
Recipe Compile Error in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab-ee/recipes/default.rb
================================================================================

NoMethodError
-------------
undefined method `[]' for nil:NilClass

Cookbook Trace:
---------------
  /opt/gitlab/embedded/cookbooks/cache/cookbooks/package/libraries/helpers/settings_helper.rb:100:in `block in from_file'
  /opt/gitlab/embedded/cookbooks/cache/cookbooks/package/libraries/config_mash.rb:28:in `auto_vivify'
  /opt/gitlab/embedded/cookbooks/cache/cookbooks/package/libraries/helpers/settings_helper.rb:100:in `from_file'
  /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/config.rb:23:in `from_file'
  /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/default.rb:26:in `from_file'
  /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab-ee/recipes/default.rb:20:in `from_file'

Relevant File Content:
----------------------
/opt/gitlab/embedded/cookbooks/cache/cookbooks/package/libraries/helpers/settings_helper.rb:

 93:    def ee_attribute(name, **config)
 94:      config = { ee: true }.merge(config)
 95:      attribute(name, **config)
 96:    end
 97:  
 98:    def from_file(_file_path)
 99:      # Allow auto mash creation during from_file call
100>>     Gitlab::ConfigMash.auto_vivify { super }
101:    end
102:  
103:    def method_missing(method_name, *arguments) # rubocop:disable Style/MethodMissing
104:      # Give better message for NilClass errors
105:      # If there are no arguments passed, this is a 'GET' call, and if
106:      # there is no matching key in the configuration, then it has not been set (not even to nil)
107:      # and we will output a nicer error above the exception
108:      if arguments.length.zero? && !configuration.key?(method_name)
109:        breaktxt = '=' * 80

System Info:
------------
chef_version=14.13.11
platform=ubuntu
platform_version=18.04
ruby=ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
program_name=/opt/gitlab/embedded/bin/chef-client
executable=/opt/gitlab/embedded/bin/chef-client


Running handlers:
There was an error running gitlab-ctl reconfigure:

undefined method `[]' for nil:NilClass

Running handlers complete
Chef Client failed. 0 resources updated in 02 seconds

Trying to connect LDAP to my Gitlab server, getting Similar. Anyone please help me fix this.

sudo gitlab-ctl reconfigure
[sudo] password for zybr-gitlab:
Starting Chef Infra Client, version 15.9.17
resolving cookbooks for run list: [“gitlab”]
Synchronizing Cookbooks:

  • gitlab (0.0.1)
  • package (0.1.0)
  • postgresql (0.1.0)
  • redis (0.1.0)
  • registry (0.1.0)
  • mattermost (0.1.0)
  • monitoring (0.1.0)
  • consul (0.1.0)
  • gitaly (0.1.0)
  • praefect (0.1.0)
  • letsencrypt (0.1.0)
  • nginx (0.1.0)
  • runit (5.1.3)
  • acme (4.1.1)
  • crond (0.1.0)
    Installing Cookbook Gems:
    Compiling Cookbooks…

================================================================================
Recipe Compile Error in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/default.rb

Psych::SyntaxError

(): did not find expected key while parsing a block mapping at line 1 column 4

Cookbook Trace:

/opt/gitlab/embedded/cookbooks/cache/cookbooks/package/libraries/helpers/settings_helper.rb:105:in block in from_file' /opt/gitlab/embedded/cookbooks/cache/cookbooks/package/libraries/config_mash.rb:29:in auto_vivify’
/opt/gitlab/embedded/cookbooks/cache/cookbooks/package/libraries/helpers/settings_helper.rb:105:in from_file' /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/config.rb:22:in from_file’
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/default.rb:26:in `from_file’

Relevant File Content:

/opt/gitlab/embedded/cookbooks/cache/cookbooks/package/libraries/helpers/settings_helper.rb:

98:
99: def from_file(_file_path)
100: # Throw errors for unrecognized top level calls (usually spelling mistakes)
101: config_strict_mode true
102: # Turn on node deprecation messages
103: Gitlab::Deprecations::NodeAttribute.log_deprecations = true
104: # Allow auto mash creation during from_file call
105>> Gitlab::ConfigMash.auto_vivify { super }
106: ensure
107: config_strict_mode false
108: Gitlab::Deprecations::NodeAttribute.log_deprecations = false
109: end
110:
111: # Enhance set so strict mode errors aren’t thrown as long as the setting is witin our defined config
112: def internal_set(symbol, value)
113: if configuration.key?(symbol)
114: configuration[symbol] = value

System Info:

chef_version=15.9.17
platform=ubuntu
platform_version=20.04
ruby=ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]
program_name=/opt/gitlab/embedded/bin/chef-client
executable=/opt/gitlab/embedded/bin/chef-client

Running handlers:
There was an error running gitlab-ctl reconfigure:

(): did not find expected key while parsing a block mapping at line 1 column 4

Running handlers complete
Chef Infra Client failed. 0 resources updated in 10 seconds