voxpupuli / puppet-mongodb

mongodb installation
Apache License 2.0
93 stars 451 forks source link

Service Fails on RH8 Due to Updated Systemd Forking Configuration #667

Open acooke91 opened 1 year ago

acooke91 commented 1 year ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

    class { 'mongodb::globals':
            manage_package_repo => false,
            server_package_name => 'mongodb-org-server',
            user => 'mongod',
            group => 'mongod',
    } ->

    class { 'mongodb::server':
            bind_ip => ['127.0.0.1'],
            dbpath => '/srv/mongodb',
            dbpath_fix => true,
    }
    selinux::port { 'mongodb':
        ensure    => 'present',
        seltype => 'mongod_port_t',
        protocol => 'tcp',
        port   => 27017,
    }

What are you seeing

Since the most recent mongodb 6 rpm on RHEL8 (mongodb-org-server-6.0.5-1.el8.x86_64), the default forking configuration has changed in mongod.conf to permit systemd to fully manage this by removing the lines below from the systemd unit file PIDFile=/var/run/mongodb/mongod.pid Type=forking

Where mongod.conf file is managed puppet-mongodb-4.2.0, the lines below remained in mongod.conf, causing the service to fail post-upgrade. processManagement: fork: true pidFilePath: /var/run/mongodb/mongod.pid

I managed to make it work by either:

  1. Changing 'fork: true' to 'fork:false' in the config file and modifying the $pidfilepath variable under the RedHat block in the case statement in manifests/params.pp around line 50, changing it from '/var/run/mongodb/mongod.pid' to undef OR
  2. Adding the lines below back in to the systemd unit file PIDFile=/var/run/mongodb/mongod.pid Type=forking

What behaviour did you expect instead

The default value for the $fork parameter should probably now be set to false in class mongodb::params for RHEL8 and possibly for other Enterpise Linux 8 based distributions.

Alternatively puppet-mongodb-4.2.0 should probably now manage the systemd unit file for mongdb to ensure the lines below are present, so that it will continue to work with the resultant mongd.conf file as it stands: PIDFile=/var/run/mongodb/mongod.pid Type=forking

Output log

Any additional information you'd like to impart

I have observed this breaking change since upgrading from mongodb-org-server-6.0.4-1.el8.x86_64 to mongodb-org-server-6.0.5-1.el8.x86_64 on Red Hat 8

acooke91 commented 1 year ago

To add to this,

The rpm-supplied config file in mongodb 6.0.5 drops the lines below from the config file: fork: true # fork and run in background pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile

The puppet module always sets the pidfilepath param to /var/run/mongodb/mongod.pid on redhat systems though, and the template file mongodb.conf.2.6.erb adds the below, resulting in a broken configuration for mongodb 6.0.5 onwards

<% if @fork or @pidfilepath -%> processManagement: <%- if @fork -%> fork: <%= @fork %> <%- end -%> <%- if @pidfilepath -%> pidFilePath: <%= @pidfilepath %> <%- end -%> <% end -%>

h-haaks commented 6 months ago

@acooke91 could you verify if this is solved by the 6.0.0 release?