Bug 1269227

Summary: MongoDB logs are directed to incorrect location / incorrect selinux context
Product: Red Hat Satellite Reporter: Craig Donnelly <cdonnell>
Component: InstallerAssignee: Justin Sherrill <jsherril>
Status: CLOSED ERRATA QA Contact: Stephen Benjamin <stbenjam>
Severity: high Docs Contact:
Priority: high    
Version: 6.1.2CC: bbuckingham, bkearney, bugzilla_rhn, chorn, egolov, jsherril, mhrivnak, oshtaier, peter.vreman, rsawhill, sauchter, stbenjam, sthirugn
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-27 08:57:20 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 1122832, 1296845, 1317008    

Description Craig Donnelly 2015-10-06 18:05:12 UTC
Description of problem:

Upon installation of Satellite 6.1.2, MongoDB logs are directed to /var/lib/mongodb which automatically assigned them the selinux context: mongod_var_lib_t.
This prevents the logs from being managed by logrotate even though Satellite provides configuration for them to be rotated.

Version-Release number of selected component (if applicable): Satellite 6.1.2

How reproducible: 100%

Steps to Reproduce:
1. Install Satellite 6.1.2.
2. Observe that mongodb logs are placed in /var/lib/mongodb

Actual results: Logs for MongoDB placed in /var/lib/mongodb, wrong selinux context applied. logrotate is setup to control logs in /var/log/mongodb. To have correct logrotate, customer would need to configure the logpath correctly in /etc/mongodb.conf.

They receive selinux context based on this rule: 
/var/lib/mongo.*  all files  system_u:object_r:mongod_var_lib_t:s0
Rule for the logs:
/var/log/mongo.*  all files  system_u:object_r:mongod_log_t:s0

Expected results: MongoDB logs should be pushed to /var/log/mongodb, as this would solve any selinux context issues and work with the current implementation of /etc/logrotate.d/mongodb.

Additional info:

Appears that the logpatch is configured via puppet during install:
  class { 'mongodb':
    logpath     => '/var/lib/mongodb/mongodb.log',
    dbpath      => '/var/lib/mongodb',
    pidfilepath => $mongodb_pidfilepath,
  } ~>

Comment 7 Justin Sherrill 2016-03-14 13:35:47 UTC
This should now be handled properly with the newer pulp puppet module.  I verified on an installation it was logging to the correct place and log rotate was occuring.

Comment 8 Justin Sherrill 2016-03-14 13:44:10 UTC
Also to note, the files in this new location appear to have the correct selinux context:

[root@sat-r220-04 ~]# ls -lZ /var/log/mongodb/
-rw-r--r--. mongodb mongodb system_u:object_r:mongod_log_t:s0 mongodb.log
-rw-r--r--. mongodb mongodb system_u:object_r:mongod_log_t:s0 mongodb.log.2016-03-12T18-29-57
-rw-r--r--. mongodb mongodb system_u:object_r:mongod_log_t:s0 mongodb.log-20160313
-rw-r--r--. mongodb mongodb system_u:object_r:mongod_log_t:s0 mongodb.log.2016-03-13T07-14-03

Comment 9 Stephen Benjamin 2016-03-24 16:57:18 UTC
Logs go to right place, with right context:

[root@sat-r220-06 mongodb]# ls -lZ /var/log/mongodb/
-rw-r--r--. mongodb mongodb system_u:object_r:mongod_log_t:s0 mongodb.log
-rw-r--r--. mongodb mongodb system_u:object_r:mongod_log_t:s0 mongodb.log.2016-03-24T16-12-24

Comment 12 errata-xmlrpc 2016-07-27 08:57:20 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Comment 13 Michael Hrivnak 2017-01-04 21:31:46 UTC
*** Bug 1317479 has been marked as a duplicate of this bug. ***