mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
use .get for os_family lookups
This commit is contained in:
parent
3ca6fee030
commit
e0bf4982a3
@ -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)
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user