Skip to content

Introduce way to declare services in the cookbook

DJ Mountney requested to merge services_object into master

Closes: https://gitlab.com/gitlab-org/omnibus-gitlab/issues/2255

Purpose

Allows us to disable/enable multiple services at once, disable/enable using group names, and using exceptions to simplify working with services.

Declaring services

A cookbook can define a class that extends from the Services::Config object in order to declare their services. This Services::Config class provides a services method to help define and store the service in the config, and a list method to list the currently stored service.

Services are defined at class load time for a cookbook, but are not included in the chef run's services. During recipe compile the cookbook services are added to the Services objects list of services. This currently happens in the gitlab/recipes/config.rb

Service Groups

When declaring a service, you can specify the 'service groups' that it is a part of. This makes it easier to enable disable like services. For example, when you enable redis you will often want to also enable the redis_exporter. I chose to do this in groups rather than declaring service dependencies because the only dependency that is shared among some of our services is that some of them depend on the configuration of gitlab-rails. This one dependency did not seem worth modelling.

Special Groups

We have some services we almost always want running, right now this is logrotate and node_exporter. I have given them a group called system that by default is always excluded from calls to disable. They can be disabled by passing an additional parameter to the disable functions, and they can still be explicitly disabled from gitlab.rb.

The other special group is 'default' It represents the services that are on by default in omnibus. This is not currently being used, but is part of my idea on how to work with roles in the next step of similifying the confguration. See https://gitlab.com/gitlab-org/omnibus-gitlab/issues/2560 for details on my intent.

What this doesn't do

  • Doesn't implement config changes to how roles are declared in this MR
  • Missing some convenience options on the groups disable/enable, like the fact that exceptions only work for groups, not service names. But until we need it I didn't want to implement it.
Edited by DJ Mountney

Merge request reports