salt-formulas / salt-formula-redis

Other
2 stars 13 forks source link

Failed on installing redis in server mode #2

Open autumnw opened 7 years ago

autumnw commented 7 years ago

If I install redis in server mode. The pillar config as the following:

salt-call pillar.get redis local:

conf_dir:
    /etc
server:
    ----------
    bind:
        ----------
        address:
            0.0.0.0
        port:
            6379
        protocol:
            tcp
    enabled:
        True

I will get the following error:

      ID: /etc/redis.conf
Function: file.managed
  Result: False
 Comment: Unable to manage file: Jinja variable 'None' has no attribute 'enabled'
 Started: 21:25:45.446509
Duration: 138.781 ms
 Changes: 

The proposal fix is adding "if cluster != None" in redis.conf everywhere likes the following

{%- if cluster != None and cluster.enabled %}

BTW, this is on centos 7. Another issue is in map.jinja, we should make the default conf_dir work: 'RedHat': { 'version': '2.8', 'pkgs': ['redis'], 'service': 'redis', 'conf_dir': '/etc', 'enabled': True, 'bind': { 'address': '127.0.0.1', 'port': '6379' }

austinbenincasa commented 6 years ago

I can confirm this happening on CentOS 7 as well. The changes proposed fix the issue.

sethcenterbar commented 5 years ago

Same issue here ✌️

sethcenterbar commented 5 years ago

For others with this problem on centos7, i wrote a quick script to put in /srv/formulas that will fix it, basically automating @autumnw 's suggestion.

for file in $(grep -R 'cluster.enabled' salt-formula-redis/ | cut -d ':' -f 1 | uniq)
do
    echo "Fixing $file"
    sed -i 's/cluster\.enabled/cluster != None and cluster.enabled/g' $file
done

echo "Fixing configuration directory for rhel"
sed -i "s/\/etc\/redis\/redis.conf/\/etc/g" salt-formula-redis/redis/map.jinja