mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge branch 'master' of github.com:thatch45/salt
This commit is contained in:
commit
0adf3caf50
14
conf/minion
14
conf/minion
@ -36,6 +36,20 @@
|
||||
#states_dirs: []
|
||||
#render_dirs: []
|
||||
|
||||
##### State Management Settings #####
|
||||
###########################################
|
||||
# The state management system executes all of the state templates on the minion
|
||||
# to enable more granular control of system state management. The type of
|
||||
# template and serialization used for state management needs to be configured
|
||||
# on the minion, the default renderer is yaml_jinja. This is a yaml file
|
||||
# rendered from a jinja template, the available options are:
|
||||
# yaml_jinja
|
||||
# yaml_mako
|
||||
# json_jinja
|
||||
# json_mako
|
||||
#
|
||||
#renderer: yaml_jinja
|
||||
|
||||
###### Security settings #####
|
||||
###########################################
|
||||
# Enable "open mode", this mode still maintains encryption, but turns off
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
{% for item in 'vim','emacs','nano','butter' %}
|
||||
{{ item }}: { "pkg": ["installed"] },
|
||||
"{{ item }}": { "pkg": ["installed"] },
|
||||
{% endfor %}
|
||||
"salt": {
|
||||
"pkg": ["installed"],
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
% for item in vim,emacs,nano,butter:
|
||||
% for item in 'vim', 'emacs', 'nano', 'butter':
|
||||
"${item}": { "pkg": ["installed"] },
|
||||
% endfor
|
||||
"salt": {
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% for item in 'vim','emacs','nano','butter' %}
|
||||
{% for item in 'vim','emacs','nano' %}
|
||||
{{ item }}:
|
||||
pkg:
|
||||
- installed
|
||||
@ -8,14 +8,16 @@ salt:
|
||||
- installed
|
||||
service:
|
||||
- running
|
||||
- enabled
|
||||
- require:
|
||||
- pkg: salt
|
||||
- names:
|
||||
- salt-master
|
||||
- salt-minion
|
||||
cron:
|
||||
cronie:
|
||||
pkg:
|
||||
- installed
|
||||
service:
|
||||
- running
|
||||
- enabled
|
||||
- name: cronie
|
||||
- require:
|
||||
- pkg: cronie
|
||||
- name: crond
|
||||
|
@ -1,4 +1,4 @@
|
||||
% for item in vim,emacs,nano,butter:
|
||||
% for item in 'vim', 'emacs', 'nano':
|
||||
${item}:
|
||||
pkg:
|
||||
- installed
|
||||
@ -8,14 +8,16 @@ salt:
|
||||
- installed
|
||||
service:
|
||||
- running
|
||||
- enabled
|
||||
- require:
|
||||
- pkg: salt
|
||||
- names:
|
||||
- salt-master
|
||||
- salt-minion
|
||||
cron:
|
||||
cronie:
|
||||
pkg:
|
||||
- installed
|
||||
service:
|
||||
- running
|
||||
- enabled
|
||||
- name: cronie
|
||||
- require:
|
||||
- pkg: cronie
|
||||
- name: crond
|
||||
|
@ -6,13 +6,12 @@ emacs:
|
||||
- installed
|
||||
nano:
|
||||
pkg:
|
||||
- installed
|
||||
- latest
|
||||
salt:
|
||||
pkg:
|
||||
- installed
|
||||
service:
|
||||
- running
|
||||
- enabled
|
||||
- require:
|
||||
- pkg: vim
|
||||
- pkg: salt
|
||||
@ -20,13 +19,9 @@ salt:
|
||||
- names:
|
||||
- salt-master
|
||||
- salt-minion
|
||||
butter:
|
||||
pkg:
|
||||
- installed
|
||||
cron:
|
||||
pkg:
|
||||
- installed
|
||||
service:
|
||||
- running
|
||||
- enabled
|
||||
- name: cronie
|
||||
|
@ -52,8 +52,8 @@ class State(object):
|
||||
deflen = 0
|
||||
if type(aspec[0]) == type(list()):
|
||||
arglen = len(aspec[0])
|
||||
if type(aspec[3]) == type(list()):
|
||||
arglen = len(aspec[3])
|
||||
if type(aspec[3]) == type(tuple()):
|
||||
deflen = len(aspec[3])
|
||||
for ind in range(arglen - deflen):
|
||||
if not data.has_key(aspec[0][ind]):
|
||||
errors.append('Missing paramater ' + aspec[0][ind]\
|
||||
@ -91,13 +91,12 @@ class State(object):
|
||||
deflen = 0
|
||||
if type(aspec[0]) == type(list()):
|
||||
arglen = len(aspec[0])
|
||||
if type(aspec[3]) == type(list()):
|
||||
arglen = len(aspec[3])
|
||||
if type(aspec[3]) == type(tuple()):
|
||||
deflen = len(aspec[3])
|
||||
kwargs = {}
|
||||
for ind in range(arglen - 1, 0, -1):
|
||||
def_minus = arglen - ind
|
||||
if deflen - def_minus > -1:
|
||||
minus = def_minus + 1
|
||||
minus = arglen - ind
|
||||
if deflen - minus > -1:
|
||||
kwargs[aspec[0][ind]] = aspec[3][-minus]
|
||||
for arg in kwargs:
|
||||
if data.has_key(arg):
|
||||
@ -232,13 +231,13 @@ class State(object):
|
||||
running = self.call_chunk(chunk, running, chunks)
|
||||
running = self.call_chunk(low, running, chunks)
|
||||
elif status == 'met':
|
||||
running[tag] = call(low)
|
||||
running[tag] = self.call(low)
|
||||
elif status == 'fail':
|
||||
running[tag] = {'changes': None,
|
||||
'result': False,
|
||||
'comment': 'One or more require failed'}
|
||||
else:
|
||||
running[tag] = call(low)
|
||||
running[tag] = self.call(low)
|
||||
return running
|
||||
|
||||
def call_high(self, high):
|
||||
@ -250,14 +249,8 @@ class State(object):
|
||||
chunks = self.compile_high_data(high)
|
||||
errors = self.verify_chunks(chunks)
|
||||
if errors:
|
||||
for err in errors:
|
||||
sys.stderr.write(err + '\n')
|
||||
sys.exit(2)
|
||||
for chunk in chunks:
|
||||
ret = self.call(chunk)
|
||||
print ret
|
||||
rets.append(ret)
|
||||
return rets
|
||||
return errors
|
||||
return self.call_chunks(chunks)
|
||||
|
||||
def call_template(self, template):
|
||||
'''
|
||||
|
@ -8,18 +8,20 @@ def installed(name):
|
||||
operation and a bool if the job was sucessfull
|
||||
'''
|
||||
if __salt__['pkg.version'](name):
|
||||
return {'changes': {},
|
||||
return {'name': name,
|
||||
'changes': {},
|
||||
'result': True,
|
||||
'comment': 'The package is already installed'}
|
||||
'comment': 'Package ' + name + ' is already installed'}
|
||||
changes = __salt__['pkg.install'](name)
|
||||
if not changes:
|
||||
return {'changes': changes,
|
||||
return {'name': name,
|
||||
'changes': changes,
|
||||
'result': False,
|
||||
'comment': 'The package failed to install'}
|
||||
'comment': 'Package ' + name + ' failed to install'}
|
||||
return {'name': name,
|
||||
'changes': changes,
|
||||
'result': True,
|
||||
'comment': 'Package installed'}
|
||||
'comment': 'Package ' + name + ' installed'}
|
||||
|
||||
def latest(name):
|
||||
'''
|
||||
@ -33,11 +35,11 @@ def latest(name):
|
||||
return {'name': name,
|
||||
'changes': changes,
|
||||
'result': False,
|
||||
'comment': 'The package failed to install'}
|
||||
'comment': 'Package ' + name + ' failed to install'}
|
||||
return {'name': name,
|
||||
'changes': changes,
|
||||
'result': True,
|
||||
'comment': 'Package installed'}
|
||||
'comment': 'Package ' + name + ' installed'}
|
||||
|
||||
def removed(name):
|
||||
'''
|
||||
@ -47,18 +49,18 @@ def removed(name):
|
||||
return {'name': name,
|
||||
'changes': {},
|
||||
'result': True,
|
||||
'comment': 'The package is not installed'}
|
||||
'comment': 'Package ' + name + ' is not installed'}
|
||||
else:
|
||||
changes = __salt__['pkg.remove'](name)
|
||||
if not changes:
|
||||
return {'name': name,
|
||||
'changes': changes,
|
||||
'result': False,
|
||||
'comment': 'The package failed to remove'}
|
||||
'comment': 'Package ' + name + ' failed to remove'}
|
||||
return {'name': name,
|
||||
'changes': changes,
|
||||
'result': True,
|
||||
'comment': 'Package removed'}
|
||||
'comment': 'Package ' + name + ' removed'}
|
||||
|
||||
def purged(name):
|
||||
'''
|
||||
@ -68,15 +70,15 @@ def purged(name):
|
||||
return {'name': name,
|
||||
'changes': {},
|
||||
'result': True,
|
||||
'comment': 'The package is not installed'}
|
||||
'comment': 'Package ' + name + ' is not installed'}
|
||||
else:
|
||||
changes = __salt__['pkg.purge'](name)
|
||||
if not changes:
|
||||
return {'name': name,
|
||||
'changes': changes,
|
||||
'result': False,
|
||||
'comment': 'The package failed to purge'}
|
||||
'comment': 'Package ' + name + ' failed to purge'}
|
||||
return {'name': name,
|
||||
'changes': changes,
|
||||
'result': True,
|
||||
'comment': 'Package purged'}
|
||||
'comment': 'Package ' + name + ' purged'}
|
||||
|
44
salt/states/service.py
Normal file
44
salt/states/service.py
Normal file
@ -0,0 +1,44 @@
|
||||
'''
|
||||
State enforcing for packages
|
||||
'''
|
||||
|
||||
def running(name, sig=None):
|
||||
'''
|
||||
Verify that the package is installed, return the packages changed in the
|
||||
operation and a bool if the job was sucessfull
|
||||
'''
|
||||
if __salt__['service.status'](name):
|
||||
return {'name': name,
|
||||
'changes': {},
|
||||
'result': True,
|
||||
'comment': 'The service is already running'}
|
||||
changes = __salt__['service.start'](name)
|
||||
if not changes:
|
||||
return {'name': name,
|
||||
'changes': changes,
|
||||
'result': False,
|
||||
'comment': 'Service ' + name + ' failed to start'}
|
||||
return {'name': name,
|
||||
'changes': changes,
|
||||
'result': True,
|
||||
'comment': 'Service ' + name + ' installed'}
|
||||
|
||||
def dead(name, sig=None):
|
||||
'''
|
||||
Ensure that the named service is dead
|
||||
'''
|
||||
if not __salt__['service.status'](name):
|
||||
return {'name': name,
|
||||
'changes': {},
|
||||
'result': True,
|
||||
'comment': 'Service ' + name + ' is already dead'}
|
||||
changes = __salt__['service.stop'](name)
|
||||
if not changes:
|
||||
return {'name': name,
|
||||
'changes': changes,
|
||||
'result': False,
|
||||
'comment': 'Service ' + name + ' failed to stop'}
|
||||
return {'name': name,
|
||||
'changes': changes,
|
||||
'result': True,
|
||||
'comment': 'Service ' + name + ' killed'}
|
5
setup.py
5
setup.py
@ -74,7 +74,10 @@ setup(name=NAME,
|
||||
(template_path,
|
||||
['doc/example/templates/yaml-jinja.yml',
|
||||
'doc/example/templates/yaml-mako.yml',
|
||||
'doc/example/templates/yaml.yml'
|
||||
'doc/example/templates/yaml.yml',
|
||||
'doc/example/templates/json-jinja.json',
|
||||
'doc/example/templates/json-mako.json',
|
||||
'doc/example/templates/json.json',
|
||||
]),
|
||||
],
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user