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

This commit is contained in:
Thomas S Hatch 2012-09-02 22:43:55 -06:00
commit cdff4bb149
5 changed files with 143 additions and 2 deletions

View File

@ -44,6 +44,7 @@ Jeffrey C. Ollie <jeff@ocjtech.us>
Jeff Schroeder <jeffschroeder@computer.org>
Jonas Buckner <buckner.jonas@gmail.com>
Joseph Hall <perlhoser@gmail.com>
Josmar Dias <josmarnet@gmail.com>
Kent Tenney <ktenney@gmail.com>
Marc Abramowitz <marc+github@marc-abramowitz.com>
Markus Gattol <markus.gattol@sunoano.org>

View File

@ -132,9 +132,11 @@ Check your file descriptor limit with::
ulimit -n
If it is less than 1024, you should increase it with::
If it is less than 2047, you should increase it with::
ulimit -n 2047
(or "limit descriptors 2047" for c-shell)
ulimit -n 1024
Running the tests
~~~~~~~~~~~~~~~~~

View File

@ -70,6 +70,7 @@ A few examples of salt states from the community:
* https://github.com/uggedal/states
* https://github.com/mattmcclean/salt-openstack/tree/master/salt
* https://github.com/rentalita/ubuntu-setup/
* https://github.com/brutasse/states
Follow on ohloh
===============

73
salt/modules/pecl.py Normal file
View File

@ -0,0 +1,73 @@
'''
Manage PHP pecl extensions.
'''
# Import python libs
import re
__opts__ = {}
__pillar__ = {}
def _pecl(command):
cmdline = 'pecl {0}'.format(command)
ret = __salt__['cmd.run_all'](cmdline)
if ret['retcode'] == 0:
return ret['stdout']
else:
return False
def install(pecls):
'''
Installs one or several pecl extensions.
pecls
The pecl extensions to install.
'''
return _pecl('install {0}'.format(pecls))
def uninstall(pecls):
'''
Uninstall one or several pecl extensions.
gems
The pecl extensions to uninstall.
'''
return _pecl('uninstall {0}'.format(pecls))
def update(pecls):
'''
Update one or several pecl exntesions.
gems
The pecl extensions to update.
'''
return _pecl('install -U {0}'.format(pecls))
def list():
'''
List installed pecl extensions.
'''
lines = _pecl('list').splitlines()
lines.pop(0)
lines.pop(0)
lines.pop(0)
lines.pop(0)
pecls = {}
for line in lines:
m = re.match('^([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)', line)
if m:
pecls[m.group(1)] = [m.group(2), m.group(3)]
return pecls

64
salt/states/pecl.py Normal file
View File

@ -0,0 +1,64 @@
'''
Installation of PHP pecl extensions.
==============================================
A state module to manage php pecl extensions.
.. code-block:: yaml
mongo:
pecl.installed
'''
def installed(name):
'''
Make sure that a pecl extension is installed.
name
The pecl extension name to install
'''
ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}
if name in __salt__['pecl.list']():
ret['result'] = True
ret['comment'] = 'Pecl is already installed.'
return ret
if __opts__['test']:
ret['comment'] = 'The pecl {0} would have been installed'.format(name)
return ret
if __salt__['pecl.install'](name):
ret['result'] = True
ret['changes'][name] = 'Installed'
ret['comment'] = 'Pecl was successfully installed'
else:
ret['result'] = False
ret['comment'] = 'Could not install pecl.'
return ret
def removed(name):
'''
Make sure that a pecl extension is not installed.
name
The pecl exntension name to uninstall
'''
ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}
if name not in __salt__['pecl.list']():
ret['result'] = True
ret['comment'] = 'Pecl is not installed.'
return ret
if __opts__['test']:
ret['comment'] = 'The pecl {0} would have been removed'.format(name)
return ret
if __salt__['pecl.uninstall'](name):
ret['result'] = True
ret['changes'][name] = 'Removed'
ret['comment'] = 'Pecl was successfully removed.'
else:
ret['result'] = False
ret['comment'] = 'Could not remove pecl.'
return ret