Skip to content
Browse files

Only allow certain linux systems to run keyboard module functions

  • Loading branch information...
1 parent a5fe648 commit 264d8dfd4223e6c7b5267cc9a6e36e02164433a2 @rallytime rallytime committed Mar 6, 2014
Showing with 14 additions and 10 deletions.
  1. +14 −10 salt/modules/keyboard.py
View
24 salt/modules/keyboard.py
@@ -1,24 +1,22 @@
# -*- coding: utf-8 -*-
'''
-Module for managing keyboards on POSIX-like systems.
+Module for managing keyboards on Arch, Redhat, Debian, and Gentoo systems.
'''
# Import python libs
import logging
-# Import salt libs
-import salt.utils
-
log = logging.getLogger(__name__)
def __virtual__():
'''
- Only work on POSIX-like systems
+ Only work on Arch, Redhat, Debian, and Gentoo
'''
- if salt.utils.is_windows():
+ if __grains__['os_family'] in ('Arch', 'Redhat', 'Debian', 'Gentoo'):
+ return 'keyboard'
+ else:
return False
- return 'keyboard'
def get_sys():
@@ -58,11 +56,17 @@ def set_sys(layout):
if 'Arch' in __grains__['os_family']:
__salt__['cmd.run']('localectl set-keymap {0}'.format(layout))
elif 'RedHat' in __grains__['os_family']:
- __salt__['file.sed']('/etc/sysconfig/keyboard', '^LAYOUT=.*', 'LAYOUT={0}'.format(layout))
+ __salt__['file.sed']('/etc/sysconfig/keyboard',
+ '^LAYOUT=.*',
+ 'LAYOUT={0}'.format(layout))
elif 'Debian' in __grains__['os_family']:
- __salt__['file.sed']('/etc/default/keyboard', '^XKBLAYOUT=.*', 'XKBLAYOUT={0}'.format(layout))
+ __salt__['file.sed']('/etc/default/keyboard',
+ '^XKBLAYOUT=.*',
+ 'XKBLAYOUT={0}'.format(layout))
elif 'Gentoo' in __grains__['os_family']:
- __salt__['file.sed']('/etc/conf.d/keymaps', '^keymap=.*', 'keymap={0}'.format(layout))
+ __salt__['file.sed']('/etc/conf.d/keymaps',
+ '^keymap=.*',
+ 'keymap={0}'.format(layout))
return layout

0 comments on commit 264d8df

Please sign in to comment.
Something went wrong with that request. Please try again.