Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

CentOS 6: /var/run/redis directory not created #92

Open
NickMRamirez opened this issue Sep 29, 2016 · 3 comments
Open

CentOS 6: /var/run/redis directory not created #92

NickMRamirez opened this issue Sep 29, 2016 · 3 comments

Comments

@NickMRamirez
Copy link

Using a manifest like this:

  redis::server { "${env}-redis-${port}" :
    redis_memory => $memory,
    redis_ip     => $ip,
    redis_port   => $port,
    requirepass  => $password,
    running      => true,
    enabled      => true,
    redis_nr_dbs => 2
  }

On CentOS 6, the /var/run/redis directory is not created and the puppet agent run fails when it can't copy the /etc/redis.conf to that that directory. I fixed it by putting the following at the top of my manifest:

file { '/var/run/redis' :
    ensure => 'directory',
  }
@NickMRamirez NickMRamirez changed the title /var/run/redis directory not created CentOS 6: /var/run/redis directory not created Sep 29, 2016
@TiagoTT
Copy link

TiagoTT commented Sep 3, 2018

I have the same problem on Debian 8 and 9.
The workaround of having Puppet create the runtime directory is not an option for me because I need Redis service to start on boot and therefore before Puppet runs.

I think the problem is in the SystemD unit file:
https://github.com/echocat/puppet-redis/blob/master/templates/systemd/redis.service.erb#L8

The commands given in the ExecStartPre option will run as the User and Group selected, which can't create a directory inside /var/run because that is owned by root.
The creation of the redis_run_dir in an ExecStartPre only works if the service is ran as root.

According to the documentation:
https://www.freedesktop.org/software/systemd/man/systemd.exec.html#RuntimeDirectory=
The recommended way to manage runtime directories with SystemD is to use RuntimeDirectory option, which will create the directory and set ownership.

So I think the following block:
https://github.com/echocat/puppet-redis/blob/master/templates/systemd/redis.service.erb#L6-L12
Could simply be replaced with:

RuntimeDirectory=redis

TiagoTT added a commit to BrandwatchLtd/puppet-redis that referenced this issue Sep 5, 2018
…e runtime directories when possible.

When the service does not run as roo user and if the desired runtime directory is under /run or /var/run (which is a usually a symlink to /run), then the explicit creation of the directory in a ExecStartPre setting should be replaced by the RuntimeDirectory setting which will have expected outcome.
Otherwise, if the runtime directory is located somewhere else, the previous approach is preserved.

See: echocat#92
@TiagoTT
Copy link

TiagoTT commented Sep 5, 2018

Sorry, I had not noticed I was running an older version of this module which did not include the PermissionsStartOnly=true setting yet.
But still, I guess that using the RuntimeDirectory= setting would be cleaner.

@dwerder
Copy link
Member

dwerder commented Sep 11, 2018

If you want , send me a PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants