Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Only allow certain linux systems to run keyboard module #11013

Merged
merged 2 commits into from

3 participants

@rallytime
Owner

Previously, all non-windows systems were allowed to run this module, but it doesn't work with OS X.

I confirmed with @techhat that he wrote this module to only work for Arch, Redhat, Debian, and Gentoo families.

@rallytime
Owner

@techhat I changed the docstring to reflect POSIX-like systems :)

@techhat techhat merged commit c42cb6b into saltstack:develop
@salt-jenkins
Owner

Test FAILed.
Refer to this link for build results: http://jenkins.saltstack.com/job/salt-pr-build/2100/

@salt-jenkins
Owner

Test FAILed.
Refer to this link for build results: http://jenkins.saltstack.com/job/salt-pr-build/2102/

@rallytime rallytime deleted the rallytime:keyboard_fix branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 10 deletions.
  1. +15 −10 salt/modules/keyboard.py
View
25 salt/modules/keyboard.py
@@ -1,24 +1,23 @@
# -*- coding: utf-8 -*-
'''
-Module for managing keyboards on POSIX-like systems.
+Module for managing keyboards on supported POSIX-like systems such as
+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 supported POSIX-like systems
'''
- 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 +57,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
Something went wrong with that request. Please try again.