From e92704da1fb585f06ddef7e12daf8c65df22fa10 Mon Sep 17 00:00:00 2001 From: noelmcloughlin Date: Sat, 1 Aug 2020 13:52:38 +0100 Subject: [PATCH] feat(macos): add darwin support --- memcached/init.sls | 1 + memcached/map.jinja | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/memcached/init.sls b/memcached/init.sls index a97ffad..0545182 100644 --- a/memcached/init.sls +++ b/memcached/init.sls @@ -19,6 +19,7 @@ memcached: {%- else %} pkg.installed: - name: {{ memcached.server }} + - runas: {{ memcached.rootuser }} {%- endif %} - require_in: - service: memcached diff --git a/memcached/map.jinja b/memcached/map.jinja index cb70780..c7afc78 100644 --- a/memcached/map.jinja +++ b/memcached/map.jinja @@ -1,3 +1,9 @@ +{%- if grains.os == 'MacOS' %} + {%- set rootuser = salt['cmd.run']("stat -f '%Su' /dev/console") %} +{%- else %} + {%- set rootuser == 'root' %} +{%- endif %} + {% set defaults = { 'config':{ 'daemonize': True, @@ -15,18 +21,27 @@ } } %} {% set memcached = salt['grains.filter_by']({ + 'Default':{ + 'server': 'memcached', + 'service': 'memcached', + 'python': 'python-python-memcached', + 'config_file': '/etc/memcached.conf', + 'rootuser': {{ rootuser }}, + }, 'Suse':{ 'server': 'memcached', 'service': 'memcached', 'python': 'python-python-memcached', 'config_file': '/etc/memcached.conf', 'libmemcached': 'libmemcached-devel', + 'rootuser': {{ rootuser }}, }, 'FreeBSD':{ 'server': 'memcached', 'service': 'memcached', 'config_file': '/usr/local/etc/rc.d/memcached', 'libmemcached': 'libmemcached-devel', + 'rootuser': {{ rootuser }}, }, 'Debian':{ 'server': 'memcached', @@ -34,6 +49,7 @@ 'python': 'python-memcache', 'config_file': '/etc/memcached.conf', 'libmemcached': 'libmemcached-dev', + 'rootuser': {{ rootuser }}, }, 'RedHat': { 'server': 'memcached', @@ -41,6 +57,7 @@ 'python': 'python-memcached', 'config_file': '/etc/sysconfig/memcached', 'libmemcached': 'libmemcached-devel', + 'rootuser': {{ rootuser }}, }, 'Gentoo':{ 'server': 'net-misc/memcached', @@ -48,6 +65,7 @@ 'python': 'dev-python/python-memcache', 'config_file': '/etc/conf.d/memcached', 'libmemcached': 'dev-libs/libmemcached', + 'rootuser': {{ rootuser }}, }, 'Arch':{ 'server': 'memcached', @@ -55,5 +73,6 @@ 'python': 'python2-memcached', 'config_file': '/etc/memcached', 'libmemcached': 'libmemcached', + 'rootuser': {{ rootuser }}, }, }, merge=salt['pillar.get']('memcached:lookup')) %}