Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Only allow certain linux systems to run keyboard module #11013

merged 2 commits into from

3 participants


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.


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

@techhat techhat merged commit c42cb6b into saltstack:develop

Test FAILed.
Refer to this link for build results:


Test FAILed.
Refer to this link for build results:

@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/
25 salt/modules/
@@ -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__['']('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.