Merge branch 'develop' of https://github.com/saltstack/salt into etcpkg

This commit is contained in:
Mike Chesnut 2012-05-09 10:43:37 -07:00
commit e31005f69a
3 changed files with 129 additions and 7 deletions

View File

@ -9,7 +9,7 @@
%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")} %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
Name: salt Name: salt
Version: 0.9.8 Version: 0.9.9.1
Release: 1%{?dist} Release: 1%{?dist}
Summary: A parallel remote execution system Summary: A parallel remote execution system
@ -28,7 +28,9 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch BuildArch: noarch
Requires: dmidecode %ifarch %{ix86} x86_64
Requires: dmidecode
%endif
%if 0%{?with_python26} %if 0%{?with_python26}
BuildRequires: python26-zmq BuildRequires: python26-zmq
@ -128,8 +130,11 @@ install -p -m 0644 %{SOURCE6} $RPM_BUILD_ROOT%{_unitdir}/
install -p %{SOURCE7} . install -p %{SOURCE7} .
install -p -m 0640 $RPM_BUILD_ROOT%{_sysconfdir}/salt/minion.template $RPM_BUILD_ROOT%{_sysconfdir}/salt/minion mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/salt/
install -p -m 0640 $RPM_BUILD_ROOT%{_sysconfdir}/salt/master.template $RPM_BUILD_ROOT%{_sysconfdir}/salt/master install -p -m 0640 conf/minion.template $RPM_BUILD_ROOT%{_sysconfdir}/salt/minion
install -p -m 0640 conf/minion.template $RPM_BUILD_ROOT%{_sysconfdir}/salt/minion.template
install -p -m 0640 conf/master.template $RPM_BUILD_ROOT%{_sysconfdir}/salt/master
install -p -m 0640 conf/master.template $RPM_BUILD_ROOT%{_sysconfdir}/salt/master.template
%clean %clean
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
@ -256,6 +261,12 @@ fi
%endif %endif
%changelog %changelog
* Sat Apr 28 2012 Clint Savage <herlo1@gmail.com> - 0.9.9.1-1
- Moved to upstream release 0.9.9.1
* Tue Apr 17 2012 Peter Robinson <pbrobinson@fedoraproject.org> - 0.9.8-2
- dmidecode is x86 only
* Wed Mar 21 2012 Clint Savage <herlo1@gmail.com> - 0.9.8-1 * Wed Mar 21 2012 Clint Savage <herlo1@gmail.com> - 0.9.8-1
- Moved to upstream release 0.9.8 - Moved to upstream release 0.9.8

View File

@ -239,13 +239,18 @@ def _virtual(osdata):
grains['virtual'] = 'kvm' grains['virtual'] = 'kvm'
elif osdata['kernel'] == 'FreeBSD': elif osdata['kernel'] == 'FreeBSD':
sysctl = salt.utils.which('sysctl') sysctl = salt.utils.which('sysctl')
kenv = salt.utils.which('kenv')
if kenv:
product = __salt__['cmd.run']('{0} smbios.system.product'.format(kenv)).strip()
if product.startswith('VMware'):
grains['virtual'] = 'VMware'
if sysctl: if sysctl:
model = __salt__['cmd.run']('{0} hw.model'.format(sysctl)).strip() model = __salt__['cmd.run']('{0} hw.model'.format(sysctl)).strip()
jail = __salt__['cmd.run']('{0} security.jail.jailed'.format(sysctl)).strip() jail = __salt__['cmd.run']('{0} -n security.jail.jailed'.format(sysctl)).strip()
if jail: if jail:
grains['virtual_subtype'] = 'jail' grains['virtual_subtype'] = 'jail'
if 'QEMU Virtual CPU' in model: if 'QEMU Virtual CPU' in model:
grains['virtual'] = 'kvm' grains['virtual'] = 'kvm'
return grains return grains
@ -596,6 +601,15 @@ def _hw_data(osdata):
}, },
} }
grains.update(_dmidecode_data(linux_dmi_regex)) grains.update(_dmidecode_data(linux_dmi_regex))
# On FreeBSD /bin/kenv (already in base system) can be used instead of dmidecode
elif osdata['kernel'] == 'FreeBSD':
kenv = salt.utils.which('kenv')
if kenv:
grains['biosreleasedate'] = __salt__['cmd.run']('{0} smbios.bios.reldate'.format(kenv)).strip()
grains['biosversion'] = __salt__['cmd.run']('{0} smbios.bios.version'.format(kenv)).strip()
grains['manufacturer'] = __salt__['cmd.run']('{0} smbios.system.maker'.format(kenv)).strip()
grains['serialnumber'] = __salt__['cmd.run']('{0} smbios.system.serial'.format(kenv)).strip()
grains['productname'] = __salt__['cmd.run']('{0} smbios.system.product'.format(kenv)).strip()
return grains return grains
def get_server_id(): def get_server_id():

View File

@ -0,0 +1,97 @@
'''
The jail module for FreeBSD
'''
import os
def __virtual__():
'''
Only runs on FreeBSD systems
'''
return 'jail' if __grains__['os'] == 'FreeBSD' else False
def start(jail=''):
'''
Start the specified jail or all, if none specified
CLI Example::
salt '*' jail.start [<jail name>]
'''
cmd = 'service jail onestart {0}'.format(jail)
return not __salt__['cmd.retcode'](cmd)
def stop(jail=''):
'''
Stop the specified jail or all, if none specified
CLI Example::
salt '*' jail.stop [<jail name>]
'''
cmd = 'service jail onestop {0}'.format(jail)
return not __salt__['cmd.retcode'](cmd)
def restart(jail=''):
'''
Restart the specified jail or all, if none specified
CLI Example::
salt '*' jail.restart [<jail name>]
'''
cmd = 'service jail onerestart {0}'.format(jail)
return not __salt__['cmd.retcode'](cmd)
def is_enabled():
'''
See if jail service is actually enabled on boot
'''
cmd='service -e | grep jail'
return not __salt__['cmd.retcode'](cmd)
def get_enabled():
'''
Return which jails are set to be run
'''
ret = []
for rconf in ('/etc/rc.conf', '/etc/rc.conf.local'):
if os.path.isfile(rconf):
for line in open(rconf, 'r').readlines():
if not line.strip():
continue
if not line.startswith('jail_list='):
continue
jails = line.split('"')[1].split()
for j in jails:
ret.append(j)
return ret
def show_config(jail):
'''
Display specified jail's configuration
CLI Example::
salt '*' jail.show_config <jail name>
'''
ret = {}
for rconf in ('/etc/rc.conf', '/etc/rc.conf.local'):
if os.path.isfile(rconf):
for line in open(rconf, 'r').readlines():
if not line.strip():
continue
if not line.startswith('jail_{0}_'.format(jail)):
continue
k, v = line.split('=')
ret[k.split('_',2)[2]] = v.split('"')[1]
return ret