Skip to content

Commit

Permalink
Merge pull request #53632 from dhiltonp/some-pkgin
Browse files Browse the repository at this point in the history
pkgin is on Solaris...
  • Loading branch information
dhiltonp authored Jun 29, 2019
2 parents 55ab4f8 + fbfbaa9 commit 1dc8e30
Show file tree
Hide file tree
Showing 79 changed files with 88 additions and 96 deletions.
2 changes: 1 addition & 1 deletion salt/beacons/aix_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __virtual__():
'''
Only load if kernel is AIX
'''
if __grains__['kernel'] == ('AIX'):
if __grains__.get('kernel') == 'AIX':
return __virtualname__

return (False, 'The aix_account beacon module failed to load: '
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/aix_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __virtual__():
'''
Set the group module if the kernel is AIX
'''
if __grains__['kernel'] == 'AIX':
if __grains__.get('kernel') == 'AIX':
return __virtualname__
return (False, 'The aix_group execution module failed to load: '
'only available on AIX systems.')
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/aix_shadow.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __virtual__():
'''
Only load if kernel is AIX
'''
if __grains__['kernel'] == 'AIX':
if __grains__.get('kernel') == 'AIX':
return __virtualname__
return (False, 'The aix_shadow execution module failed to load: '
'only available on AIX systems.')
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/aixpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __virtual__():
'''
Set the virtual pkg module if the os is AIX
'''
if __grains__['os_family'] == 'AIX':
if __grains__.get('os_family') == 'AIX':
return __virtualname__
return (False,
'Did not load AIX module on non-AIX OS.')
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/apache.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _detect_os():
Apache commands and paths differ depending on packaging
'''
# TODO: Add pillar support for the apachectl location
os_family = __grains__['os_family']
os_family = __grains__.get('os_family')
if os_family == 'RedHat':
return 'apachectl'
elif os_family == 'Debian' or os_family == 'Suse':
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __virtual__():
'NetBSD': 'brconfig',
'OpenBSD': 'ifconfig'
}
cur_os = __grains__['kernel']
cur_os = __grains__.get('kernel')
for _os in supported_os_tool:
if cur_os == _os and salt.utils.path.which(supported_os_tool[cur_os]):
return True
Expand Down
6 changes: 3 additions & 3 deletions salt/modules/deb_apache.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __virtual__():
Only load the module if apache is installed
'''
cmd = _detect_os()
if salt.utils.path.which(cmd) and __grains__['os_family'] == 'Debian':
if salt.utils.path.which(cmd) and __grains__.get('os_family') == 'Debian':
return __virtualname__
return (False, 'apache execution module not loaded: apache not installed.')

Expand All @@ -38,9 +38,9 @@ def _detect_os():
Apache commands and paths differ depending on packaging
'''
# TODO: Add pillar support for the apachectl location
if __grains__['os_family'] == 'RedHat':
if __grains__.get('os_family') == 'RedHat':
return 'apachectl'
elif __grains__['os_family'] == 'Debian':
elif __grains__.get('os_family') == 'Debian':
return 'apache2ctl'
else:
return 'apachectl'
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/debconfmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __virtual__():
Confirm this module is on a Debian based system and that debconf-utils
is installed.
'''
if __grains__['os_family'] != 'Debian':
if __grains__.get('os_family') != 'Debian':
return (False, 'The debconfmod module could not be loaded: '
'unsupported OS family')

Expand Down
2 changes: 1 addition & 1 deletion salt/modules/debian_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __virtual__():
'''
Confine this module to Debian-based distros
'''
if __grains__['os_family'] == 'Debian':
if __grains__.get('os_family') == 'Debian':
return __virtualname__
return (False, 'The debian_ip module could not be loaded: '
'unsupported OS family')
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/debian_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __virtual__():
'''
Only work on Debian and when systemd isn't running
'''
if __grains__['os'] in ('Debian', 'Raspbian', 'Devuan', 'NILinuxRT') and not salt.utils.systemd.booted(__context__):
if __grains__.get('os') in ('Debian', 'Raspbian', 'Devuan', 'NILinuxRT') and not salt.utils.systemd.booted(__context__):
return __virtualname__
else:
return (False, 'The debian_service module could not be loaded: '
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/dpkg_lowpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __virtual__():
'''
Confirm this module is on a Debian based system
'''
if __grains__['os_family'] == 'Debian':
if __grains__.get('os_family') == 'Debian':
return __virtualname__
return (False, 'The dpkg execution module cannot be loaded: '
'only works on Debian family systems.')
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/ebuildpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __virtual__():
'''
Confirm this module is on a Gentoo based system
'''
if HAS_PORTAGE and __grains__['os_family'] == 'Gentoo':
if HAS_PORTAGE and __grains__.get('os_family') == 'Gentoo':
return __virtualname__
return (False, 'The ebuild execution module cannot be loaded: either the system is not Gentoo or the portage python library is not available.')

Expand Down
2 changes: 1 addition & 1 deletion salt/modules/eix.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __virtual__():
'''
Only works on Gentoo systems with eix installed
'''
if __grains__['os_family'] == 'Gentoo' and salt.utils.path.which('eix'):
if __grains__.get('os_family') == 'Gentoo' and salt.utils.path.which('eix'):
return 'eix'
return (False, 'The eix execution module cannot be loaded: either the system is not Gentoo or the eix binary is not in the path.')

Expand Down
2 changes: 1 addition & 1 deletion salt/modules/eselect.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __virtual__():
'''
Only work on Gentoo systems with eselect installed
'''
if __grains__['os_family'] == 'Gentoo' and salt.utils.path.which('eselect'):
if __grains__.get('os_family') == 'Gentoo' and salt.utils.path.which('eselect'):
return 'eselect'
return (False, 'The eselect execution module cannot be loaded: either the system is not Gentoo or the eselect binary is not in the path.')

Expand Down
2 changes: 1 addition & 1 deletion salt/modules/freebsd_sysctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __virtual__():
'''
Only runs on FreeBSD systems
'''
if __grains__['os'] == 'FreeBSD':
if __grains__.get('os') == 'FreeBSD':
return __virtualname__
return (False, 'The freebsd_sysctl execution module cannot be loaded: '
'only available on FreeBSD systems.')
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/freebsd_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __virtual__():
Only work on FreeBSD RELEASEs >= 6.2, where freebsd-update was introduced.
'''
if __grains__['os'] != 'FreeBSD':
if __grains__.get('os') != 'FreeBSD':
return (False, 'The freebsd_update execution module cannot be loaded: only available on FreeBSD systems.')
if float(__grains__['osrelease']) < 6.2:
return (False, 'freebsd_update is only available on FreeBSD versions >= 6.2-RELESE')
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/freebsdjail.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __virtual__():
'''
Only runs on FreeBSD systems
'''
if __grains__['os'] == 'FreeBSD':
if __grains__.get('os') == 'FreeBSD':
return __virtualname__
return (False, 'The freebsdjail execution module cannot be loaded: '
'only available on FreeBSD systems.')
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/freebsdkmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __virtual__():
'''
Only runs on FreeBSD systems
'''
if __grains__['kernel'] == 'FreeBSD':
if __grains__.get('kernel') == 'FreeBSD':
return __virtualname__
return (False, 'The freebsdkmod execution module cannot be loaded: only available on FreeBSD systems.')

Expand Down
2 changes: 1 addition & 1 deletion salt/modules/freebsdpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def __virtual__():
Don't load on FreeBSD 9 when the config option
``providers:pkg`` is set to 'pkgng'.
'''
if __grains__['os'] == 'FreeBSD' and float(__grains__['osrelease']) < 10:
if __grains__.get('os') == 'FreeBSD' and float(__grains__['osrelease']) < 10:
providers = {}
if 'providers' in __opts__:
providers = __opts__['providers']
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/freebsdports.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __virtual__():
'''
Only runs on FreeBSD systems
'''
if __grains__['os'] == 'FreeBSD':
if __grains__.get('os') == 'FreeBSD':
return __virtualname__
return (False, 'The freebsdports execution module cannot be loaded: '
'only available on FreeBSD systems.')
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/freebsdservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __virtual__():
Only work on FreeBSD
'''
# Disable on these platforms, specific service modules exist:
if __grains__['os'] == 'FreeBSD':
if __grains__.get('os') == 'FreeBSD':
return __virtualname__
return (False, 'The freebsdservice execution module cannot be loaded: only available on FreeBSD systems.')

Expand Down
4 changes: 2 additions & 2 deletions salt/modules/gentoo_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def __virtual__():
'''
Only work on systems which default to OpenRC
'''
if __grains__['os_family'] == 'Gentoo' and not salt.utils.systemd.booted(__context__):
if __grains__.get('os_family') == 'Gentoo' and not salt.utils.systemd.booted(__context__):
return __virtualname__
if __grains__['os'] == 'Alpine':
if __grains__.get('os') == 'Alpine':
return __virtualname__
return (False, 'The gentoo_service execution module cannot be loaded: '
'only available on Gentoo/Open-RC systems.')
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/gentoolkitmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __virtual__():
'''
Only work on Gentoo systems with gentoolkit installed
'''
if __grains__['os_family'] == 'Gentoo' and HAS_GENTOOLKIT:
if __grains__.get('os_family') == 'Gentoo' and HAS_GENTOOLKIT:
return __virtualname__
return (False, 'The gentoolkitmod execution module cannot be loaded: '
'either the system is not Gentoo or the gentoolkit.eclean python module not available')
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/groupadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __virtual__():
'''
Set the user module if the kernel is Linux or OpenBSD
'''
if __grains__['kernel'] in ('Linux', 'OpenBSD', 'NetBSD'):
if __grains__.get('kernel') in ('Linux', 'OpenBSD', 'NetBSD'):
return __virtualname__
return (False, 'The groupadd execution module cannot be loaded: '
' only available on Linux, OpenBSD and NetBSD')
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/grub_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _detect_conf():
'''
GRUB conf location differs depending on distro
'''
if __grains__['os_family'] == 'RedHat':
if __grains__.get('os_family') == 'RedHat':
return '/boot/grub/grub.conf'
# Defaults for Ubuntu, Debian, Arch, and others
return '/boot/grub/menu.lst'
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __virtual__():
Only works with systemd or on supported POSIX-like systems
'''
if salt.utils.path.which('localectl') \
or __grains__['os_family'] in ('RedHat', 'Debian', 'Gentoo'):
or __grains__.get('os_family') in ('RedHat', 'Debian', 'Gentoo'):
return True
return (False, 'The keyboard exeuction module cannot be loaded: '
'only works on Redhat, Debian or Gentoo systems or if localectl binary in path.')
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/kmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __virtual__():
'''
Only runs on Linux systems
'''
return __grains__['kernel'] == 'Linux'
return __grains__.get('kernel') == 'Linux'


def _new_mods(pre_mods, post_mods):
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/layman.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __virtual__():
'''
Only work on Gentoo systems with layman installed
'''
if __grains__['os_family'] == 'Gentoo' and salt.utils.path.which('layman'):
if __grains__.get('os_family') == 'Gentoo' and salt.utils.path.which('layman'):
return 'layman'
return (False, 'layman execution module cannot be loaded: only available on Gentoo with layman installed.')

Expand Down
6 changes: 3 additions & 3 deletions salt/modules/linux_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ def __virtual__():
'''
if salt.utils.platform.is_windows():
return (False, 'Module linux_ip: Windows systems are not supported.')
if __grains__['os_family'] == 'RedHat':
if __grains__.get('os_family') == 'RedHat':
return (False, 'Module linux_ip: RedHat systems are not supported.')
if __grains__['os_family'] == 'Debian':
if __grains__.get('os_family') == 'Debian':
return (False, 'Module linux_ip: Debian systems are not supported.')
if __grains__['os_family'] == 'NILinuxRT':
if __grains__.get('os_family') == 'NILinuxRT':
return (False, 'Module linux_ip: NILinuxRT systems are not supported.')
if not salt.utils.path.which('ip'):
return (False, 'The linux_ip execution module cannot be loaded: '
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/linux_sysctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __virtual__():
'''
Only run on Linux systems
'''
if __grains__['kernel'] != 'Linux':
if __grains__.get('kernel') != 'Linux':
return (False, 'The linux_sysctl execution module cannot be loaded: only available on Linux systems.')
return __virtualname__

Expand Down
2 changes: 1 addition & 1 deletion salt/modules/logadm.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __virtual__():
'''
Only work on Solaris based systems
'''
if 'Solaris' in __grains__['os_family']:
if 'Solaris' in __grains__.get('os_family'):
return True
return (False, 'The logadm execution module cannot be loaded: only available on Solaris.')

Expand Down
2 changes: 1 addition & 1 deletion salt/modules/mac_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
def __virtual__():
global _dscl, _flush_dscl_cache
if (__grains__.get('kernel') != 'Darwin' or
__grains__['osrelease_info'] < (10, 7)):
__grains__.get('osrelease_info') < (10, 7)):
return (False, 'The mac_group execution module cannot be loaded: only available on Darwin-based systems >= 10.7')
_dscl = salt.utils.functools.namespaced_function(_dscl, globals())
_flush_dscl_cache = salt.utils.functools.namespaced_function(
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/mac_sysctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __virtual__():
'''
Only run on Darwin (macOS) systems
'''
if __grains__['os'] == 'MacOS':
if __grains__.get('os') == 'MacOS':
return __virtualname__
return (False, 'The darwin_sysctl execution module cannot be loaded: '
'Only available on macOS systems.')
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/mac_xattr.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __virtual__():
'''
Only work on Mac OS
'''
if __grains__['os'] in ['MacOS', 'Darwin']:
if __grains__.get('os') in ['MacOS', 'Darwin']:
return __virtualname__
return False

Expand Down
2 changes: 1 addition & 1 deletion salt/modules/makeconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __virtual__():
'''
Only work on Gentoo
'''
if __grains__['os_family'] == 'Gentoo':
if __grains__.get('os_family') == 'Gentoo':
return 'makeconf'
return (False, 'The makeconf execution module cannot be loaded: only available on Gentoo systems.')

Expand Down
2 changes: 1 addition & 1 deletion salt/modules/mdadm_raid.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __virtual__():
'''
mdadm provides raid functions for Linux
'''
if __grains__['kernel'] != 'Linux':
if __grains__.get('kernel') != 'Linux':
return (False, 'The mdadm execution module cannot be loaded: only available on Linux.')
if not salt.utils.path.which('mdadm'):
return (False, 'The mdadm execution module cannot be loaded: the mdadm binary is not in the path.')
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/netbsd_sysctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __virtual__():
'''
Only run on NetBSD systems
'''
if __grains__['os'] == 'NetBSD':
if __grains__.get('os') == 'NetBSD':
return __virtualname__
return (False, 'The netbsd_sysctl execution module failed to load: '
'only available on NetBSD.')
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/netbsdservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __virtual__():
'''
Only work on NetBSD
'''
if __grains__['os'] == 'NetBSD' and os.path.exists('/etc/rc.subr'):
if __grains__.get('os') == 'NetBSD' and os.path.exists('/etc/rc.subr'):
return __virtualname__
return (False, 'The netbsdservice execution module failed to load: only available on NetBSD.')

Expand Down
2 changes: 1 addition & 1 deletion salt/modules/nilrt_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __virtual__():
'''
try:
msg = 'The nilrt_ip module could not be loaded: unsupported OS family'
_assume_condition(__grains__['os_family'] == 'NILinuxRT', msg)
_assume_condition(__grains__.get('os_family') == 'NILinuxRT', msg)
_assume_condition(CaseInsensitiveDict, 'The python package request is not installed')
_assume_condition(pyiface, 'The python pyiface package is not installed')
if __grains__['lsb_distrib_id'] != 'nilrt':
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/nspawn.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __virtual__():
'''
Only work on systems that have been booted with systemd
'''
if __grains__['kernel'] == 'Linux' \
if __grains__.get('kernel') == 'Linux' \
and salt.utils.systemd.booted(__context__):
if salt.utils.systemd.version() is None:
log.error('nspawn: Unable to determine systemd version')
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/openbsd_sysctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __virtual__():
'''
Only run on OpenBSD systems
'''
if __grains__['os'] == 'OpenBSD':
if __grains__.get('os') == 'OpenBSD':
return __virtualname__
return (False, 'The openbsd_sysctl execution module cannot be loaded: '
'only available on OpenBSD systems.')
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/openbsdpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __virtual__():
'''
Set the virtual pkg module if the os is OpenBSD
'''
if __grains__['os'] == 'OpenBSD':
if __grains__.get('os') == 'OpenBSD':
return __virtualname__
return (False, 'The openbsdpkg execution module cannot be loaded: '
'only available on OpenBSD systems.')
Expand Down
Loading

0 comments on commit 1dc8e30

Please sign in to comment.