Debian/Ubuntu package for upstream acceptance

Applying latest changes for packaging

Fixed typos in man pages

Latest round of changes

More packaging fixups

Fixed salt-common typo

Fixed wildcarding in install files

Removed extra man pages

Removed trailing slash

Fixed links

Moved binaries to proper packages

Fixed man pages

Pathing

Perms tweak

Missing files

Fixed spacing

Fixed another lintian error

build the msgpack stuff

Updating rules and install files

Fixed shebang

Control updates

Fixed copyright file

Fixed lintian

Fixed overrides

cmd.retcode no longer uses subprocess.call since it is broken

fix issue with source_hash and trailing whitespace

Bye-bye pickle, hello msgpack

Add docs for new source powers

Add support for source_hash to be a source hash string

add pure python template type

add return clarifying that no states were found if no states are found

change some strings to use format

add code to cache jobs on the minion if option is set

serialize cache data

was caching the wrong line data

Add cache_jobs to the minion config template

add docs for new config param cache_jobs

make the minions return to the master in addition to returning to
returners

Add capability to designate multiple returns

only run the apache module if apachectl is installed

only load solr module if solr is installed

Debug statement used the wrong variable.

Only load nginx on machines that have nginx installed

Make it more like the apache module
This commit is contained in:
Corey Quinn 2012-01-16 15:36:59 -08:00
parent 1607550633
commit dfd82ad0bd
44 changed files with 305 additions and 133 deletions

View file

@ -29,10 +29,16 @@
# Where cache data goes # Where cache data goes
#cachedir: /var/cache/salt #cachedir: /var/cache/salt
# The minion can locally cache the return data from jobs sent to it, this
# can be a good way to keep track minion side of the jobs the minion has
# executed. By default this feature is disabled, to enable set cache_jobs
# to True
#cache_jobs: False
# When waiting for a master to accept the minion's public key, salt will # When waiting for a master to accept the minion's public key, salt will
# contiuously attempt to reconnect until successful. This is the time, in # continuously attempt to reconnect until successful. This is the time, in
# seconds, between those reconnection attempts. # seconds, between those reconnection attempts.
# acceptance_wait_time = 10 #acceptance_wait_time = 10

2
debian/changelog vendored
View file

@ -1,4 +1,4 @@
salt (0.9.5+git20111227.g8182e48-1) unstable; urgency=low salt (0.9.5-1) unstable; urgency=low
* First package release. (Closes: #643789) * First package release. (Closes: #643789)

50
debian/control vendored
View file

@ -7,14 +7,11 @@ Build-Depends: debhelper (>= 7.0.50~),
cython, cython,
python-yaml, python-yaml,
python-setuptools, python-setuptools,
python-yaml,
python-crypto, python-crypto,
python-m2crypto, python-m2crypto,
python-zmq (>= 2.1.9), python-zmq (>= 2.1.9),
libzmq1 (>= 2.1.9),
libzmq-dev (>= 2.1.9), libzmq-dev (>= 2.1.9),
python (>= 2.6), python-all-dev,
python-dev (>= 2.6),
python-jinja2 python-jinja2
Standards-Version: 3.9.2 Standards-Version: 3.9.2
Homepage: http://saltstack.org Homepage: http://saltstack.org
@ -24,8 +21,20 @@ Homepage: http://saltstack.org
Package: salt-common Package: salt-common
Architecture: any Architecture: any
Depends: ${python:Depends}, Depends: ${python:Depends},
${misc:Depends} ${misc:Depends},
${shlibs:Depends},
python-support,
cython,
python-setuptools,
python-yaml,
python-crypto,
python-m2crypto,
python-zmq (>= 2.1.9),
libzmq-dev (>= 2.1.9),
python,
python-dev,
python-jinja2
Description: Shared libraries that salt requires for all packages Description: Shared libraries that salt requires for all packages
This package is a powerful remote execution manager that can be used This package is a powerful remote execution manager that can be used
to administer servers in a fast and efficient way. to administer servers in a fast and efficient way.
@ -41,15 +50,14 @@ Description: Shared libraries that salt requires for all packages
Between the remote execution system, and state management Salt addresses Between the remote execution system, and state management Salt addresses
the backbone of cloud and data center management. the backbone of cloud and data center management.
. .
This particular package provides shared libraries that salt-master, salt-minion, This particular package provides shared libraries that salt-master,
and salt-syndic require to function. salt-minion, and salt-syndic require to function.
Package: salt-master Package: salt-master
Architecture: all Architecture: all
Depends: ${python:Depends}, Depends: ${misc:Depends},
${misc:Depends}, python,
salt-common salt-common (>= ${source:Version})
Description: This package provides a remote manager to administer servers via salt Description: This package provides a remote manager to administer servers via salt
This package is a powerful remote execution manager that can be used This package is a powerful remote execution manager that can be used
to administer servers in a fast and efficient way. to administer servers in a fast and efficient way.
@ -70,9 +78,9 @@ Description: This package provides a remote manager to administer servers via sa
Package: salt-minion Package: salt-minion
Architecture: all Architecture: all
Depends: ${python:Depends}, Depends: ${misc:Depends},
${misc:Depends}, python,
salt-common salt-common (>= ${source:Version})
Description: This package represents the client package for salt Description: This package represents the client package for salt
This package is a powerful remote execution manager that can be used This package is a powerful remote execution manager that can be used
to administer servers in a fast and efficient way. to administer servers in a fast and efficient way.
@ -93,10 +101,10 @@ Description: This package represents the client package for salt
Package: salt-syndic Package: salt-syndic
Architecture: all Architecture: all
Depends: ${python:Depends}, Depends: ${misc:Depends},
${misc:Depends}, python,
salt-master salt-master (>= ${source:Version})
Description: salt-syndic represents the master-of-masters for salt Description: This package represents the master-of-masters for salt
This package is a powerful remote execution manager that can be used This package is a powerful remote execution manager that can be used
to administer servers in a fast and efficient way. to administer servers in a fast and efficient way.
. .
@ -111,5 +119,5 @@ Description: salt-syndic represents the master-of-masters for salt
Between the remote execution system, and state management Salt addresses Between the remote execution system, and state management Salt addresses
the backbone of cloud and data center management. the backbone of cloud and data center management.
. .
This particular package provides the master of masters for salt-- it enables the management This particular package provides the master of masters for salt-- it enables
of multiple masters at a time. the management of multiple masters at a time.

6
debian/copyright vendored
View file

@ -1,10 +1,10 @@
Format: http://dep.debian.net/deps/dep5 Format: http://dep.debian.net/deps/dep5
Upstream-Name: salt Upstream-Name: salt
Upstream-Contact: Aaron Toponce <aaron.toponce@gmail.com> Upstream-Contact: salt-users@googlegroups.com
Source: http://github.com/thatch45/salt/ Source: https://github.com/downloads/saltstack/salt/salt-0.9.5.tar.gz
Files: * Files: *
Copyright: 2011 Thomas S Hatch <thatch45@gmail.com> Copyright: 2012 Thomas S Hatch <thatch45@gmail.com>
License: Apache-2.0 License: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

3
debian/lintian-overrides vendored Normal file
View file

@ -0,0 +1,3 @@
salt-common: manpage-has-errors-from-man usr/share/man/man7/salt.7.gz
# The man page renders correctly, no need for lintian to get upset about
# it.

5
debian/rules vendored
View file

@ -1,8 +1,7 @@
#!/usr/bin/make -f #!/usr/bin/make -f
#export DH_VERBOSE=1
%: %:
dh $@ dh $@ --buildsystem=python_distutils
#override_dh_installinit: #override_dh_installinit:
# dh_installinit --no-start --name="salt-master" # dh_installinit --no-start --name="salt-master"
# dh_installinit --no-start --name="salt-minion" # dh_installinit --no-start --name="salt-minion"

View file

@ -1,9 +1,25 @@
usr/share/man/man1/salt-minion.1 salt/exceptions.py /usr/share/salt
usr/share/man/man1/salt-call.1 salt/loader.py /usr/share/salt
usr/share/man/man1/salt-key.1 salt/master.py /usr/share/salt
usr/share/man/man1/salt-master.1 salt/client.py /usr/share/salt
usr/share/man/man1/salt-syndic.1 salt/runner.py /usr/share/salt
usr/share/man/man1/salt-cp.1 salt/output.py /usr/share/salt
usr/share/man/man1/salt.1 salt/minion.py /usr/share/salt
conf/minion /etc/salt/minion salt/version.py /usr/share/salt
salt/* /usr/share/salt/ salt/config.py /usr/share/salt
salt/state.py /usr/share/salt
salt/log.py /usr/share/salt
salt/__init__.py /usr/share/salt
salt/payload.py /usr/share/salt
salt/crypt.py /usr/share/salt
salt/runners /usr/share/salt/
salt/renderers /usr/share/salt/
salt/returners /usr/share/salt/
salt/ext /usr/share/salt/
salt/msgpack /usr/share/salt/
salt/grains /usr/share/salt/
salt/cli /usr/share/salt/
salt/states /usr/share/salt/
salt/utils /usr/share/salt/
usr/lib/python2*/dist-packages/salt/msgpack
debian/lintian-overrides /usr/share/lintian/overrides/salt-common

1
debian/salt-common.manpages vendored Normal file
View file

@ -0,0 +1 @@
doc/man/salt.7

View file

@ -1 +1,6 @@
conf/master /etc/salt/master conf/master.template /etc/salt/master
scripts/salt-key /usr/share/salt
scripts/salt /usr/share/salt
scripts/salt-run /usr/share/salt
scripts/salt-cp /usr/share/salt
scripts/salt-master /usr/share/salt

View file

@ -1,8 +1,5 @@
usr/share/salt/salt /usr/bin/salt usr/share/salt/salt /usr/bin/salt
usr/share/salt/salt-master /usr/bin/salt-master usr/share/salt/salt-master /usr/bin/salt-master
usr/share/salt/salt-syndic /usr/bin/salt-syndic
usr/share/salt/salt-cp /usr/bin/salt-cp usr/share/salt/salt-cp /usr/bin/salt-cp
usr/share/salt/salt-key /usr/bin/salt-key usr/share/salt/salt-key /usr/bin/salt-key
usr/share/salt/salt-run /usr/bin/salt-run usr/share/salt/salt-run /usr/bin/salt-run
usr/share/salt/salt-minion /usr/bin/salt-minion
usr/share/salt/salt-call /usr/bin/salt-call

View file

@ -1,6 +1,5 @@
doc/man/salt.7
doc/man/salt.1 doc/man/salt.1
doc/man/salt-master.1
doc/man/salt-key.1
doc/man/salt-cp.1 doc/man/salt-cp.1
doc/man/salt-key.1
doc/man/salt-master.1
doc/man/salt-run.1 doc/man/salt-run.1

View file

@ -1,4 +1,4 @@
scripts/salt-minion /usr/share/salt/salt-minion scripts/salt-minion /usr/share/salt
scripts/salt-call /usr/share/salt/salt-call scripts/salt-call /usr/share/salt
modules/* /usr/share/salt/modules/ salt/modules /usr/share/salt/modules
conf/minion /etc/salt/minion conf/minion.template /etc/salt/minion

2
debian/salt-minion.links vendored Normal file
View file

@ -0,0 +1,2 @@
usr/share/salt/salt-minion /usr/bin/salt-minion
usr/share/salt/salt-call /usr/bin/salt-call

View file

@ -0,0 +1 @@
scripts/salt-syndic /usr/share/salt

1
debian/salt-syndic.links vendored Normal file
View file

@ -0,0 +1 @@
usr/share/salt/salt-syndic /usr/bin/salt-syndic

View file

@ -1,9 +0,0 @@
doc/man/salt.1
doc/man/salt.7
doc/man/salt-call.1
doc/man/salt-cp.1
doc/man/salt-key.1
doc/man/salt-master.1
doc/man/salt-minion.1
doc/man/salt-run.1
doc/man/salt-syndic.1

View file

@ -61,7 +61,7 @@ The timeout in seconds to wait for replies from the salt minions.
.INDENT 0.0 .INDENT 0.0
.TP .TP
.B \-E, \-\-pcre .B \-E, \-\-pcre
The target expresion will be interpereted as a pcre regular expression The target expression will be interpereted as a pcre regular expression
rather than a shell glob. rather than a shell glob.
.UNINDENT .UNINDENT
.INDENT 0.0 .INDENT 0.0
@ -74,8 +74,8 @@ example: server1.foo.bar,server2.foo.bar,example7.quo.qux
.TP .TP
.B \-G, \-\-grain .B \-G, \-\-grain
The target expression matches values returned by the salt grains system on The target expression matches values returned by the salt grains system on
the minions. The target expresion is in the format of \(aq<grain value>:<pcre the minions. The target expression is in the format of \(aq<grain value>:<pcre
regular expresion>\(aq; example: \(aqos:Arch.*\(aq regular expression>\(aq; example: \(aqos:Arch.*\(aq
.UNINDENT .UNINDENT
.INDENT 0.0 .INDENT 0.0
.TP .TP

View file

@ -7827,7 +7827,7 @@ extra information needs to be sent with the publications, the order_masters
option makes sure that the extra data is sent out. option makes sure that the extra data is sent out.
.SS Running the Syndic .SS Running the Syndic
.sp .sp
The Syndic is a seperate daemon that needs to be started on the master that is The Syndic is a separate daemon that needs to be started on the master that is
controlled by a higher master. Starting the Syndic daemon is the same as controlled by a higher master. Starting the Syndic daemon is the same as
starting the other Salt daemons. starting the other Salt daemons.
.sp .sp
@ -8149,7 +8149,7 @@ def get_file(path, dest, env=\(aqbase\(aq):
# syndic servers(s) below it set the "order_masters" setting to True, if this # syndic servers(s) below it set the "order_masters" setting to True, if this
# is a master that will be running a syndic daemon for passthrough the # is a master that will be running a syndic daemon for passthrough the
# "syndic_master" setting needs to be set to the location of the master server # "syndic_master" setting needs to be set to the location of the master server
# to recieve commands from # to receive commands from
# #
# Set the order_masters setting to True if this master will command lower # Set the order_masters setting to True if this master will command lower
# masters\(aq syndic interfaces # masters\(aq syndic interfaces
@ -8608,7 +8608,7 @@ master. Using the syndic is simple, if this is a master that will have
syndic servers(s) below it set the "order_masters" setting to True, if this syndic servers(s) below it set the "order_masters" setting to True, if this
is a master that will be running a syndic daemon for passthrough the is a master that will be running a syndic daemon for passthrough the
"syndic_master" setting needs to be set to the location of the master server "syndic_master" setting needs to be set to the location of the master server
to recieve commands from to receive commands from
.SS \fBorder_masters\fP .SS \fBorder_masters\fP
.sp .sp
Default: \fBFalse\fP Default: \fBFalse\fP
@ -9443,7 +9443,7 @@ The timeout in seconds to wait for replies from the salt minions.
.INDENT 0.0 .INDENT 0.0
.TP .TP
.B \-E, \-\-pcre .B \-E, \-\-pcre
The target expresion will be interpereted as a pcre regular expression The target expression will be interpereted as a pcre regular expression
rather than a shell glob. rather than a shell glob.
.UNINDENT .UNINDENT
.INDENT 0.0 .INDENT 0.0
@ -9456,8 +9456,8 @@ example: server1.foo.bar,server2.foo.bar,example7.quo.qux
.TP .TP
.B \-G, \-\-grain .B \-G, \-\-grain
The target expression matches values returned by the salt grains system on The target expression matches values returned by the salt grains system on
the minions. The target expresion is in the format of \(aq<grain value>:<pcre the minions. The target expression is in the format of \(aq<grain value>:<pcre
regular expresion>\(aq; example: \(aqos:Arch.*\(aq regular expression>\(aq; example: \(aqos:Arch.*\(aq
.UNINDENT .UNINDENT
.INDENT 0.0 .INDENT 0.0
.TP .TP
@ -11192,5 +11192,4 @@ Thomas S. Hatch <thatch@gmail.com> and many others, please see the Authors file
.SH COPYRIGHT .SH COPYRIGHT
2011, Thomas S. Hatch 2011, Thomas S. Hatch
.\" Generated by docutils manpage writer. .\" Generated by docutils manpage writer.
.\"
. .

View file

@ -36,7 +36,7 @@ Options
.. option:: -E, --pcre .. option:: -E, --pcre
The target expresion will be interpereted as a pcre regular expression The target expression will be interpereted as a pcre regular expression
rather than a shell glob. rather than a shell glob.
.. option:: -L, --list .. option:: -L, --list
@ -47,8 +47,8 @@ Options
.. option:: -G, --grain .. option:: -G, --grain
The target expression matches values returned by the salt grains system on The target expression matches values returned by the salt grains system on
the minions. The target expresion is in the format of '<grain value>:<pcre the minions. The target expression is in the format of '<grain value>:<pcre
regular expresion>'; example: 'os:Arch.*' regular expression>'; example: 'os:Arch.*'
.. option:: -Q, --query .. option:: -Q, --query

View file

@ -99,8 +99,27 @@ The location for minion cache data.
cachedir: /var/cache/salt cachedir: /var/cache/salt
.. conf_minion:: cache_jobs
``cache_jobs``
--------------
Default: ``False``
The minion can locally cache the return data from jobs sent to it, this
can be a good way to keep track minion side of the jobs the minion has
executed. By default this feature is disabled, to enable set cache_jobs
to True
.. code-block:: yaml
cache_jobs: False
.. conf_minion:: acceptance_wait_time .. conf_minion:: acceptance_wait_time
``acceptance_wait_time``
------------------------
Default: ``10`` Default: ``10``
The number of seconds to wait until attempting to re-authenticate with the The number of seconds to wait until attempting to re-authenticate with the

View file

@ -45,9 +45,10 @@ contains a viable, and transparent, AMQ broker inside the daemon. Salt uses
public keys for authentication with the master daemon, then uses faster AES public keys for authentication with the master daemon, then uses faster AES
encryption for payload communication, this means that authentication and encryption for payload communication, this means that authentication and
encryption are also built into Salt. Salt takes advantage of communication via encryption are also built into Salt. Salt takes advantage of communication via
Python pickles, enabling fast and light network traffic. `msgpack`_, enabling fast and light network traffic.
.. _`ZeroMQ`: http://www.zeromq.org/ .. _`ZeroMQ`: http://www.zeromq.org/
.. _`msgpack`: http://msgpack.org/
Python client interface Python client interface
======================= =======================

0
salt/__init__.py Executable file → Normal file
View file

View file

@ -80,6 +80,7 @@ def minion_config(path):
'pki_dir': '/etc/salt/pki', 'pki_dir': '/etc/salt/pki',
'id': socket.getfqdn(), 'id': socket.getfqdn(),
'cachedir': '/var/cache/salt', 'cachedir': '/var/cache/salt',
'cache_jobs': False,
'conf_file': path, 'conf_file': path,
'renderer': 'yaml_jinja', 'renderer': 'yaml_jinja',
'failhard': False, 'failhard': False,

0
salt/log.py Executable file → Normal file
View file

View file

@ -226,14 +226,19 @@ class Minion(object):
ret['jid'] = data['jid'] ret['jid'] = data['jid']
ret['fun'] = data['fun'] ret['fun'] = data['fun']
self._return_pub(ret)
if data['ret']: if data['ret']:
ret['id'] = self.opts['id'] for returner in set(data['ret'].split(',')):
try: ret['id'] = self.opts['id']
self.returners[data['ret']](ret) try:
except Exception as exc: self.returners[returner](ret)
log.error('The return failed for job %s %s', data['jid'], exc) except Exception as exc:
else: log.error(
self._return_pub(ret) 'The return failed for job {0} {1}'.format(
data['jid'],
exc
)
)
def _thread_multi_return(self, data): def _thread_multi_return(self, data):
''' '''
@ -259,23 +264,32 @@ class Minion(object):
= self.functions[data['fun'][ind]](*data['arg'][ind]) = self.functions[data['fun'][ind]](*data['arg'][ind])
except Exception as exc: except Exception as exc:
trb = traceback.format_exc() trb = traceback.format_exc()
log.warning('The minion function caused an exception: %s', exc) log.warning(
'The minion function caused an exception: {0}'.format(
exc
)
)
ret['return'][data['fun'][ind]] = trb ret['return'][data['fun'][ind]] = trb
ret['jid'] = data['jid'] ret['jid'] = data['jid']
self._return_pub(ret)
if data['ret']: if data['ret']:
ret['id'] = self.opts['id'] for returner in set(data['ret'].split(',')):
try: ret['id'] = self.opts['id']
self.returners[data['ret']](ret) try:
except Exception as exc: self.returners[returner](ret)
log.error('The return failed for job %s %s', data['jid'], exc) except Exception as exc:
else: log.error(
self._return_pub(ret) 'The return failed for job {0} {1}'.format(
data['jid'],
exc
)
)
def _return_pub(self, ret, ret_cmd='_return'): def _return_pub(self, ret, ret_cmd='_return'):
''' '''
Return the data from the executed command to the master server Return the data from the executed command to the master server
''' '''
log.info('Returning information for job: %(jid)s', ret) log.info('Returning information for job: {0}'.format(ret['jid']))
context = zmq.Context() context = zmq.Context()
socket = context.socket(zmq.REQ) socket = context.socket(zmq.REQ)
socket.connect(self.opts['master_uri']) socket.connect(self.opts['master_uri'])
@ -301,8 +315,21 @@ class Minion(object):
except KeyError: except KeyError:
pass pass
payload['load'] = self.crypticle.dumps(load) payload['load'] = self.crypticle.dumps(load)
socket.send(self.serial.dumps(payload)) data = self.serial.dumps(payload)
return socket.recv() socket.send(data)
ret_val = socket.recv()
if self.opts['cache_jobs']:
# Local job cache has been enabled
fn_ = os.path.join(
self.opts['cachedir'],
'minion_jobs',
load['jid'],
'return.p')
jdir = os.path.dirname(fn_)
if not os.path.isdir(jdir):
os.makedirs(jdir)
open(fn_, 'w+').write(self.serial.dumps(ret))
return ret_val
def authenticate(self): def authenticate(self):
''' '''

11
salt/modules/apache.py Executable file → Normal file
View file

@ -3,12 +3,23 @@ Support for Apache
''' '''
import re import re
import salt.utils
__outputter__ = { __outputter__ = {
'signal': 'txt', 'signal': 'txt',
} }
def __virtual__():
'''
Only load the module if apache is installed
'''
cmd = __detect_os()
if salt.utils.which(cmd):
return 'apache'
return False
def __detect_os(): def __detect_os():
''' '''
Apache commands and paths differ depending on packaging Apache commands and paths differ depending on packaging

View file

@ -123,7 +123,7 @@ def retcode(cmd, cwd=DEFAULT_CWD):
salt '*' cmd.retcode "file /bin/bash" salt '*' cmd.retcode "file /bin/bash"
''' '''
log.info('Executing command {0} in directory {1}'.format(cmd, cwd)) log.info('Executing command {0} in directory {1}'.format(cmd, cwd))
return subprocess.call(cmd, shell=True, cwd=cwd) return _run(cmd, cwd=cwd)['retcode']
def has_exec(cmd): def has_exec(cmd):

0
salt/modules/mysql.py Executable file → Normal file
View file

18
salt/modules/nginx.py Executable file → Normal file
View file

@ -2,10 +2,24 @@
Support for nginx Support for nginx
''' '''
import salt.utils
__outputter__ = { __outputter__ = {
'signal': 'txt', 'signal': 'txt',
} }
def __virtual__():
'''
Only load the module if nginx is installed
'''
cmd = __detect_os()
if salt.utils.which(cmd):
return 'nginx'
return False
def __detect_os():
return 'nginx'
def version(): def version():
''' '''
Return server version from nginx -v Return server version from nginx -v
@ -14,7 +28,7 @@ def version():
salt '*' nginx.version salt '*' nginx.version
''' '''
cmd = 'nginx -v' cmd = __detect_os() + ' -v'
out = __salt__['cmd.run'](cmd).split('\n') out = __salt__['cmd.run'](cmd).split('\n')
ret = out[0].split(': ') ret = out[0].split(': ')
return ret[2] return ret[2]
@ -37,7 +51,7 @@ def signal(signal=None):
arguments = ' -s {0}'.format(signal) arguments = ' -s {0}'.format(signal)
else: else:
arguments = ' {0}'.format(signal) arguments = ' {0}'.format(signal)
cmd = 'nginx' + arguments cmd = __detect_os() + arguments
out = __salt__['cmd.run_all'](cmd) out = __salt__['cmd.run_all'](cmd)
# A non-zero return code means fail # A non-zero return code means fail

View file

@ -59,11 +59,15 @@ verbose : True
Get verbose output Get verbose output
''' '''
# Import Python Libs
import urllib2 import urllib2
import json import json
import socket import socket
import os import os
# Import Salt libs
import salt.utils
#sane defaults #sane defaults
__opts__ = {'solr.cores': [], __opts__ = {'solr.cores': [],
'solr.host': 'localhost', 'solr.host': 'localhost',
@ -86,16 +90,11 @@ def __virtual__():
Solr needs to be installed to use this. Solr needs to be installed to use this.
Return: str/bool:: Return: str/bool::
TODO:// currently __salt__ is not available to call in this method because
all the salt modules have not been loaded yet. Use a grains module?
''' '''
return 'solr' if salt.utils.which('solr'):
names = ['solr', 'apache-solr'] return 'solr'
for name in names: if salt.utils.which('apache-solr'):
if __salt__['pkg.version'](name): return 'solr'
return 'solr'
return False return False
def _get_none_or_value(value): def _get_none_or_value(value):

View file

@ -43,5 +43,5 @@ def returner(ret):
else: else:
columns['return'] = str(ret['return']) columns['return'] = str(ret['return'])
log.debug(back) log.debug(columns)
cf.insert(ret['jid'], columns) cf.insert(ret['jid'], columns)

View file

@ -989,6 +989,14 @@ class HighState(object):
high, errors = self.render_highstate(matches) high, errors = self.render_highstate(matches)
if errors: if errors:
return errors return errors
if not high:
return {'no.states': {
'result': False,
'comment': 'No states found for this minion',
'name': 'No States',
'changes': {}
}
}
return self.state.call_high(high) return self.state.call_high(high)
def compile_highstate(self): def compile_highstate(self):

View file

@ -69,6 +69,7 @@ import os
import shutil import shutil
import difflib import difflib
import hashlib import hashlib
import imp
import logging import logging
import tempfile import tempfile
import traceback import traceback
@ -223,6 +224,43 @@ def _jinja(sfn, name, source, user, group, mode, env, context=None):
'data': trb} 'data': trb}
def _py(sfn, name, source, user, group, mode, env, context=None):
'''
Render a template from a python source file
Returns::
{'result': bool,
'data': <Error data or rendered file path>}
'''
if not os.path.isfile(sfn):
return {}
mod = imp.load_source(
os.path.basename(sfn).split('.')[0],
sfn
)
mod.salt = __salt__
mod.grains = __grains__
mod.name = name
mod.source = source
mod.user = user
mod.group = group
mod.mode = mode
mod.env = env
mod.context = context
try:
tgt = tempfile.mkstemp()[1]
open(tgt, 'w+').write(mod.run())
return {'result': True,
'data': tgt}
except:
trb = traceback.format_exc()
return {'result': False,
'data': trb}
def symlink(name, target, force=False, makedirs=False): def symlink(name, target, force=False, makedirs=False):
''' '''
Create a symlink Create a symlink
@ -345,11 +383,21 @@ def managed(name,
The location of the file to manage The location of the file to manage
source source
The source file, this file is located on the salt master file server The source file to download to the minion, this source file can be
and is specified with the salt:// protocol. If the file is located on hosted on either the salt master server, or on an http or ftp server.
For files hosted on the salt file server, if the file is located on
the master in the directory named spam, and is called eggs, the source the master in the directory named spam, and is called eggs, the source
string is salt://spam/eggs. If source is left blank or None, the file string is salt://spam/eggs. If source is left blank or None, the file
will be created as an empty file and the content will not be managed will be created as an empty file and the content will not be managed
If the file is hosted on a http or ftp server then the source_hash
argument is also required
source_hash:
This can be either a file which contains a source hash string for
the source, or a source hash string. The source hash string is the
hash algorithm followed by the hash of the file:
md5=e138491e9d5b97023cea823fe17bac22
user user
The user to own the file, this defaults to the user salt is running as The user to own the file, this defaults to the user salt is running as
@ -432,24 +480,40 @@ def managed(name,
ret['comment'] = 'Source file {0} not found'.format(source) ret['comment'] = 'Source file {0} not found'.format(source)
return ret return ret
elif source_hash: elif source_hash:
hash_fn = __salt__['cp.cache_file'](source_hash) protos = ['salt', 'http', 'ftp']
if not hash_fn: if urlparse.urlparse(source_hash).scheme in protos:
ret['result'] = False # The sourc_hash is a file on a server
ret['comment'] = 'Source hash file {0} not found'.format( hash_fn = __salt__['cp.cache_file'](source_hash)
source_hash if not hash_fn:
) ret['result'] = False
return ret ret['comment'] = 'Source hash file {0} not found'.format(
comps = open(hash_fn, 'r').read().split('=') source_hash
if len(comps) < 2: )
ret['result'] = False return ret
ret['comment'] = ('Source hash file {0} contains an ' comps = open(hash_fn, 'r').read().split('=')
' invalid hash format, it must be in ' if len(comps) < 2:
' the format <hash type>=<hash>').format( ret['result'] = False
source_hash ret['comment'] = ('Source hash file {0} contains an '
) ' invalid hash format, it must be in '
return ret ' the format <hash type>=<hash>').format(
source_sum['hsum'] = comps[1] source_hash
source_sum['hash_type'] = comps[0] )
return ret
source_sum['hsum'] = comps[1].strip()
source_sum['hash_type'] = comps[0].strip()
else:
# The source_hash is a hash string
comps = source_hash.split('=')
if len(comps) < 2:
ret['result'] = False
ret['comment'] = ('Source hash file {0} contains an '
' invalid hash format, it must be in '
' the format <hash type>=<hash>').format(
source_hash
)
return ret
source_sum['hsum'] = comps[1].strip()
source_sum['hash_type'] = comps[0].strip()
else: else:
ret['result'] = False ret['result'] = False
ret['comment'] = ('Unable to determine upstream hash of' ret['comment'] = ('Unable to determine upstream hash of'

0
salt/states/mysql_database.py Executable file → Normal file
View file

0
salt/states/mysql_user.py Executable file → Normal file
View file

0
salt/utils/find.py Executable file → Normal file
View file

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/python
''' '''
Publish commands to the salt system from the command line on the master. Publish commands to the salt system from the command line on the master.
''' '''

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/python
''' '''
Directly call a salt command in the modules, does not require a running salt Directly call a salt command in the modules, does not require a running salt
minion to run. minion to run.

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/python
''' '''
Publish commands to the salt system from the command line on the master. Publish commands to the salt system from the command line on the master.
''' '''

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/python
''' '''
Manage the authentication keys with salt-key Manage the authentication keys with salt-key
''' '''

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/python
''' '''
Start the salt-master Start the salt-master
''' '''

View file

@ -1,4 +1,4 @@
#!/usr/bin/python2 #!/usr/bin/python
''' '''
This script is used to kick off a salt minion daemon This script is used to kick off a salt minion daemon
''' '''

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/python
''' '''
Execute a salt convenience routine Execute a salt convenience routine
''' '''

View file

@ -1,4 +1,4 @@
#!/usr/bin/python2 #!/usr/bin/python
''' '''
This script is used to kick off a salt syndic daemon This script is used to kick off a salt syndic daemon
''' '''