forked from saltstack/salt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pecl.py
64 lines (52 loc) · 1.67 KB
/
pecl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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