diff --git a/salt/modules/cron.py b/salt/modules/cron.py index 04e34fb3f1..83baddd024 100644 --- a/salt/modules/cron.py +++ b/salt/modules/cron.py @@ -64,7 +64,7 @@ def _get_cron_cmdstr(user, path): Returns a platform-specific format string, to be used to build a crontab command. ''' - if __grains__['os_family'] == 'Solaris': + if __grains__.get('os_family') == 'Solaris': return 'su - {0} -c "crontab {1}"'.format(user, path) else: return 'crontab -u {0} {1}'.format(user, path) @@ -103,7 +103,7 @@ def _write_cron_lines(user, lines): path = salt.utils.mkstemp() with salt.utils.fopen(path, 'w+') as fp_: fp_.writelines(lines) - if __grains__['os_family'] == 'Solaris' and user != "root": + if __grains__.get('os_family') == 'Solaris' and user != "root": __salt__['cmd.run']('chown {0} {1}'.format(user, path)) ret = __salt__['cmd.run_all'](_get_cron_cmdstr(user, path)) os.remove(path) @@ -130,7 +130,7 @@ def raw_cron(user): salt '*' cron.raw_cron root ''' - if __grains__['os_family'] == 'Solaris': + if __grains__.get('os_family') == 'Solaris': cmd = 'crontab -l {0}'.format(user) else: cmd = 'crontab -l -u {0}'.format(user) diff --git a/salt/states/incron.py b/salt/states/incron.py index 856a899de3..f0f281f1ea 100644 --- a/salt/states/incron.py +++ b/salt/states/incron.py @@ -77,7 +77,7 @@ def _get_cron_info(): elif __grains__['os'] == 'OpenBSD': group = 'crontab' crontab_dir = '/var/spool/incron' - elif __grains__['os_family'] == 'Solaris': + elif __grains__.get('os_family') == 'Solaris': group = 'root' crontab_dir = '/var/spool/incron' else: