mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
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:
parent
1607550633
commit
dfd82ad0bd
44 changed files with 305 additions and 133 deletions
|
@ -29,8 +29,14 @@
|
|||
# Where cache data goes
|
||||
#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
|
||||
# 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.
|
||||
#acceptance_wait_time = 10
|
||||
|
||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -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)
|
||||
|
||||
|
|
48
debian/control
vendored
48
debian/control
vendored
|
@ -7,14 +7,11 @@ Build-Depends: debhelper (>= 7.0.50~),
|
|||
cython,
|
||||
python-yaml,
|
||||
python-setuptools,
|
||||
python-yaml,
|
||||
python-crypto,
|
||||
python-m2crypto,
|
||||
python-zmq (>= 2.1.9),
|
||||
libzmq1 (>= 2.1.9),
|
||||
libzmq-dev (>= 2.1.9),
|
||||
python (>= 2.6),
|
||||
python-dev (>= 2.6),
|
||||
python-all-dev,
|
||||
python-jinja2
|
||||
Standards-Version: 3.9.2
|
||||
Homepage: http://saltstack.org
|
||||
|
@ -25,7 +22,19 @@ Homepage: http://saltstack.org
|
|||
Package: salt-common
|
||||
Architecture: any
|
||||
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
|
||||
This package is a powerful remote execution manager that can be used
|
||||
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
|
||||
the backbone of cloud and data center management.
|
||||
.
|
||||
This particular package provides shared libraries that salt-master, salt-minion,
|
||||
and salt-syndic require to function.
|
||||
|
||||
This particular package provides shared libraries that salt-master,
|
||||
salt-minion, and salt-syndic require to function.
|
||||
|
||||
Package: salt-master
|
||||
Architecture: all
|
||||
Depends: ${python:Depends},
|
||||
${misc:Depends},
|
||||
salt-common
|
||||
Depends: ${misc:Depends},
|
||||
python,
|
||||
salt-common (>= ${source:Version})
|
||||
Description: This package provides a remote manager to administer servers via salt
|
||||
This package is a powerful remote execution manager that can be used
|
||||
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
|
||||
Architecture: all
|
||||
Depends: ${python:Depends},
|
||||
${misc:Depends},
|
||||
salt-common
|
||||
Depends: ${misc:Depends},
|
||||
python,
|
||||
salt-common (>= ${source:Version})
|
||||
Description: This package represents the client package for salt
|
||||
This package is a powerful remote execution manager that can be used
|
||||
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
|
||||
Architecture: all
|
||||
Depends: ${python:Depends},
|
||||
${misc:Depends},
|
||||
salt-master
|
||||
Description: salt-syndic represents the master-of-masters for salt
|
||||
Depends: ${misc:Depends},
|
||||
python,
|
||||
salt-master (>= ${source:Version})
|
||||
Description: This package represents the master-of-masters for salt
|
||||
This package is a powerful remote execution manager that can be used
|
||||
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
|
||||
the backbone of cloud and data center management.
|
||||
.
|
||||
This particular package provides the master of masters for salt-- it enables the management
|
||||
of multiple masters at a time.
|
||||
This particular package provides the master of masters for salt-- it enables
|
||||
the management of multiple masters at a time.
|
||||
|
|
6
debian/copyright
vendored
6
debian/copyright
vendored
|
@ -1,10 +1,10 @@
|
|||
Format: http://dep.debian.net/deps/dep5
|
||||
Upstream-Name: salt
|
||||
Upstream-Contact: Aaron Toponce <aaron.toponce@gmail.com>
|
||||
Source: http://github.com/thatch45/salt/
|
||||
Upstream-Contact: salt-users@googlegroups.com
|
||||
Source: https://github.com/downloads/saltstack/salt/salt-0.9.5.tar.gz
|
||||
|
||||
Files: *
|
||||
Copyright: 2011 Thomas S Hatch <thatch45@gmail.com>
|
||||
Copyright: 2012 Thomas S Hatch <thatch45@gmail.com>
|
||||
License: Apache-2.0
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
3
debian/lintian-overrides
vendored
Normal file
3
debian/lintian-overrides
vendored
Normal 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
5
debian/rules
vendored
|
@ -1,8 +1,7 @@
|
|||
#!/usr/bin/make -f
|
||||
|
||||
#export DH_VERBOSE=1
|
||||
%:
|
||||
dh $@
|
||||
|
||||
dh $@ --buildsystem=python_distutils
|
||||
#override_dh_installinit:
|
||||
# dh_installinit --no-start --name="salt-master"
|
||||
# dh_installinit --no-start --name="salt-minion"
|
||||
|
|
34
debian/salt-common.install
vendored
34
debian/salt-common.install
vendored
|
@ -1,9 +1,25 @@
|
|||
usr/share/man/man1/salt-minion.1
|
||||
usr/share/man/man1/salt-call.1
|
||||
usr/share/man/man1/salt-key.1
|
||||
usr/share/man/man1/salt-master.1
|
||||
usr/share/man/man1/salt-syndic.1
|
||||
usr/share/man/man1/salt-cp.1
|
||||
usr/share/man/man1/salt.1
|
||||
conf/minion /etc/salt/minion
|
||||
salt/* /usr/share/salt/
|
||||
salt/exceptions.py /usr/share/salt
|
||||
salt/loader.py /usr/share/salt
|
||||
salt/master.py /usr/share/salt
|
||||
salt/client.py /usr/share/salt
|
||||
salt/runner.py /usr/share/salt
|
||||
salt/output.py /usr/share/salt
|
||||
salt/minion.py /usr/share/salt
|
||||
salt/version.py /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
1
debian/salt-common.manpages
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
doc/man/salt.7
|
7
debian/salt-master.install
vendored
7
debian/salt-master.install
vendored
|
@ -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
|
||||
|
|
3
debian/links → debian/salt-master.links
vendored
3
debian/links → debian/salt-master.links
vendored
|
@ -1,8 +1,5 @@
|
|||
usr/share/salt/salt /usr/bin/salt
|
||||
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-key /usr/bin/salt-key
|
||||
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
|
5
debian/salt-master.manpages
vendored
5
debian/salt-master.manpages
vendored
|
@ -1,6 +1,5 @@
|
|||
doc/man/salt.7
|
||||
doc/man/salt.1
|
||||
doc/man/salt-master.1
|
||||
doc/man/salt-key.1
|
||||
doc/man/salt-cp.1
|
||||
doc/man/salt-key.1
|
||||
doc/man/salt-master.1
|
||||
doc/man/salt-run.1
|
||||
|
|
8
debian/salt-minion.install
vendored
8
debian/salt-minion.install
vendored
|
@ -1,4 +1,4 @@
|
|||
scripts/salt-minion /usr/share/salt/salt-minion
|
||||
scripts/salt-call /usr/share/salt/salt-call
|
||||
modules/* /usr/share/salt/modules/
|
||||
conf/minion /etc/salt/minion
|
||||
scripts/salt-minion /usr/share/salt
|
||||
scripts/salt-call /usr/share/salt
|
||||
salt/modules /usr/share/salt/modules
|
||||
conf/minion.template /etc/salt/minion
|
||||
|
|
2
debian/salt-minion.links
vendored
Normal file
2
debian/salt-minion.links
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
usr/share/salt/salt-minion /usr/bin/salt-minion
|
||||
usr/share/salt/salt-call /usr/bin/salt-call
|
1
debian/salt-syndic.install
vendored
1
debian/salt-syndic.install
vendored
|
@ -0,0 +1 @@
|
|||
scripts/salt-syndic /usr/share/salt
|
1
debian/salt-syndic.links
vendored
Normal file
1
debian/salt-syndic.links
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
usr/share/salt/salt-syndic /usr/bin/salt-syndic
|
9
debian/salt.manpages
vendored
9
debian/salt.manpages
vendored
|
@ -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
|
|
@ -61,7 +61,7 @@ The timeout in seconds to wait for replies from the salt minions.
|
|||
.INDENT 0.0
|
||||
.TP
|
||||
.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.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
|
@ -74,8 +74,8 @@ example: server1.foo.bar,server2.foo.bar,example7.quo.qux
|
|||
.TP
|
||||
.B \-G, \-\-grain
|
||||
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
|
||||
regular expresion>\(aq; example: \(aqos:Arch.*\(aq
|
||||
the minions. The target expression is in the format of \(aq<grain value>:<pcre
|
||||
regular expression>\(aq; example: \(aqos:Arch.*\(aq
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
|
|
|
@ -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.
|
||||
.SS Running the Syndic
|
||||
.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
|
||||
starting the other Salt daemons.
|
||||
.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
|
||||
# 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
|
||||
# to recieve commands from
|
||||
# to receive commands from
|
||||
#
|
||||
# Set the order_masters setting to True if this master will command lower
|
||||
# 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
|
||||
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
|
||||
to recieve commands from
|
||||
to receive commands from
|
||||
.SS \fBorder_masters\fP
|
||||
.sp
|
||||
Default: \fBFalse\fP
|
||||
|
@ -9443,7 +9443,7 @@ The timeout in seconds to wait for replies from the salt minions.
|
|||
.INDENT 0.0
|
||||
.TP
|
||||
.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.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
|
@ -9456,8 +9456,8 @@ example: server1.foo.bar,server2.foo.bar,example7.quo.qux
|
|||
.TP
|
||||
.B \-G, \-\-grain
|
||||
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
|
||||
regular expresion>\(aq; example: \(aqos:Arch.*\(aq
|
||||
the minions. The target expression is in the format of \(aq<grain value>:<pcre
|
||||
regular expression>\(aq; example: \(aqos:Arch.*\(aq
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
|
@ -11192,5 +11192,4 @@ Thomas S. Hatch <thatch@gmail.com> and many others, please see the Authors file
|
|||
.SH COPYRIGHT
|
||||
2011, Thomas S. Hatch
|
||||
.\" Generated by docutils manpage writer.
|
||||
.\"
|
||||
.
|
||||
|
|
|
@ -36,7 +36,7 @@ Options
|
|||
|
||||
.. 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.
|
||||
|
||||
.. option:: -L, --list
|
||||
|
@ -47,8 +47,8 @@ Options
|
|||
.. option:: -G, --grain
|
||||
|
||||
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
|
||||
regular expresion>'; example: 'os:Arch.*'
|
||||
the minions. The target expression is in the format of '<grain value>:<pcre
|
||||
regular expression>'; example: 'os:Arch.*'
|
||||
|
||||
.. option:: -Q, --query
|
||||
|
||||
|
|
|
@ -99,8 +99,27 @@ The location for minion cache data.
|
|||
|
||||
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
|
||||
|
||||
``acceptance_wait_time``
|
||||
------------------------
|
||||
|
||||
Default: ``10``
|
||||
|
||||
The number of seconds to wait until attempting to re-authenticate with the
|
||||
|
|
|
@ -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
|
||||
encryption for payload communication, this means that authentication and
|
||||
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/
|
||||
.. _`msgpack`: http://msgpack.org/
|
||||
|
||||
Python client interface
|
||||
=======================
|
||||
|
|
0
salt/__init__.py
Executable file → Normal file
0
salt/__init__.py
Executable file → Normal file
|
@ -80,6 +80,7 @@ def minion_config(path):
|
|||
'pki_dir': '/etc/salt/pki',
|
||||
'id': socket.getfqdn(),
|
||||
'cachedir': '/var/cache/salt',
|
||||
'cache_jobs': False,
|
||||
'conf_file': path,
|
||||
'renderer': 'yaml_jinja',
|
||||
'failhard': False,
|
||||
|
|
0
salt/log.py
Executable file → Normal file
0
salt/log.py
Executable file → Normal file
|
@ -226,14 +226,19 @@ class Minion(object):
|
|||
|
||||
ret['jid'] = data['jid']
|
||||
ret['fun'] = data['fun']
|
||||
self._return_pub(ret)
|
||||
if data['ret']:
|
||||
for returner in set(data['ret'].split(',')):
|
||||
ret['id'] = self.opts['id']
|
||||
try:
|
||||
self.returners[data['ret']](ret)
|
||||
self.returners[returner](ret)
|
||||
except Exception as exc:
|
||||
log.error('The return failed for job %s %s', data['jid'], exc)
|
||||
else:
|
||||
self._return_pub(ret)
|
||||
log.error(
|
||||
'The return failed for job {0} {1}'.format(
|
||||
data['jid'],
|
||||
exc
|
||||
)
|
||||
)
|
||||
|
||||
def _thread_multi_return(self, data):
|
||||
'''
|
||||
|
@ -259,23 +264,32 @@ class Minion(object):
|
|||
= self.functions[data['fun'][ind]](*data['arg'][ind])
|
||||
except Exception as 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['jid'] = data['jid']
|
||||
self._return_pub(ret)
|
||||
if data['ret']:
|
||||
for returner in set(data['ret'].split(',')):
|
||||
ret['id'] = self.opts['id']
|
||||
try:
|
||||
self.returners[data['ret']](ret)
|
||||
self.returners[returner](ret)
|
||||
except Exception as exc:
|
||||
log.error('The return failed for job %s %s', data['jid'], exc)
|
||||
else:
|
||||
self._return_pub(ret)
|
||||
log.error(
|
||||
'The return failed for job {0} {1}'.format(
|
||||
data['jid'],
|
||||
exc
|
||||
)
|
||||
)
|
||||
|
||||
def _return_pub(self, ret, ret_cmd='_return'):
|
||||
'''
|
||||
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()
|
||||
socket = context.socket(zmq.REQ)
|
||||
socket.connect(self.opts['master_uri'])
|
||||
|
@ -301,8 +315,21 @@ class Minion(object):
|
|||
except KeyError:
|
||||
pass
|
||||
payload['load'] = self.crypticle.dumps(load)
|
||||
socket.send(self.serial.dumps(payload))
|
||||
return socket.recv()
|
||||
data = self.serial.dumps(payload)
|
||||
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):
|
||||
'''
|
||||
|
|
11
salt/modules/apache.py
Executable file → Normal file
11
salt/modules/apache.py
Executable file → Normal file
|
@ -3,12 +3,23 @@ Support for Apache
|
|||
'''
|
||||
|
||||
import re
|
||||
import salt.utils
|
||||
|
||||
__outputter__ = {
|
||||
'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():
|
||||
'''
|
||||
Apache commands and paths differ depending on packaging
|
||||
|
|
|
@ -123,7 +123,7 @@ def retcode(cmd, cwd=DEFAULT_CWD):
|
|||
salt '*' cmd.retcode "file /bin/bash"
|
||||
'''
|
||||
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):
|
||||
|
|
0
salt/modules/mysql.py
Executable file → Normal file
0
salt/modules/mysql.py
Executable file → Normal file
18
salt/modules/nginx.py
Executable file → Normal file
18
salt/modules/nginx.py
Executable file → Normal file
|
@ -2,10 +2,24 @@
|
|||
Support for nginx
|
||||
'''
|
||||
|
||||
import salt.utils
|
||||
|
||||
__outputter__ = {
|
||||
'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():
|
||||
'''
|
||||
Return server version from nginx -v
|
||||
|
@ -14,7 +28,7 @@ def version():
|
|||
|
||||
salt '*' nginx.version
|
||||
'''
|
||||
cmd = 'nginx -v'
|
||||
cmd = __detect_os() + ' -v'
|
||||
out = __salt__['cmd.run'](cmd).split('\n')
|
||||
ret = out[0].split(': ')
|
||||
return ret[2]
|
||||
|
@ -37,7 +51,7 @@ def signal(signal=None):
|
|||
arguments = ' -s {0}'.format(signal)
|
||||
else:
|
||||
arguments = ' {0}'.format(signal)
|
||||
cmd = 'nginx' + arguments
|
||||
cmd = __detect_os() + arguments
|
||||
out = __salt__['cmd.run_all'](cmd)
|
||||
|
||||
# A non-zero return code means fail
|
||||
|
|
|
@ -59,11 +59,15 @@ verbose : True
|
|||
Get verbose output
|
||||
'''
|
||||
|
||||
# Import Python Libs
|
||||
import urllib2
|
||||
import json
|
||||
import socket
|
||||
import os
|
||||
|
||||
# Import Salt libs
|
||||
import salt.utils
|
||||
|
||||
#sane defaults
|
||||
__opts__ = {'solr.cores': [],
|
||||
'solr.host': 'localhost',
|
||||
|
@ -86,16 +90,11 @@ def __virtual__():
|
|||
Solr needs to be installed to use this.
|
||||
|
||||
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?
|
||||
'''
|
||||
if salt.utils.which('solr'):
|
||||
return 'solr'
|
||||
names = ['solr', 'apache-solr']
|
||||
for name in names:
|
||||
if __salt__['pkg.version'](name):
|
||||
if salt.utils.which('apache-solr'):
|
||||
return 'solr'
|
||||
|
||||
return False
|
||||
|
||||
def _get_none_or_value(value):
|
||||
|
|
|
@ -43,5 +43,5 @@ def returner(ret):
|
|||
else:
|
||||
columns['return'] = str(ret['return'])
|
||||
|
||||
log.debug(back)
|
||||
log.debug(columns)
|
||||
cf.insert(ret['jid'], columns)
|
||||
|
|
|
@ -989,6 +989,14 @@ class HighState(object):
|
|||
high, errors = self.render_highstate(matches)
|
||||
if 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)
|
||||
|
||||
def compile_highstate(self):
|
||||
|
|
|
@ -69,6 +69,7 @@ import os
|
|||
import shutil
|
||||
import difflib
|
||||
import hashlib
|
||||
import imp
|
||||
import logging
|
||||
import tempfile
|
||||
import traceback
|
||||
|
@ -223,6 +224,43 @@ def _jinja(sfn, name, source, user, group, mode, env, context=None):
|
|||
'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):
|
||||
'''
|
||||
Create a symlink
|
||||
|
@ -345,12 +383,22 @@ def managed(name,
|
|||
The location of the file to manage
|
||||
|
||||
source
|
||||
The source file, this file is located on the salt master file server
|
||||
and is specified with the salt:// protocol. If the file is located on
|
||||
The source file to download to the minion, this source file can be
|
||||
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
|
||||
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
|
||||
|
||||
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
|
||||
The user to own the file, this defaults to the user salt is running as
|
||||
on the minion
|
||||
|
@ -432,6 +480,9 @@ def managed(name,
|
|||
ret['comment'] = 'Source file {0} not found'.format(source)
|
||||
return ret
|
||||
elif source_hash:
|
||||
protos = ['salt', 'http', 'ftp']
|
||||
if urlparse.urlparse(source_hash).scheme in protos:
|
||||
# The sourc_hash is a file on a server
|
||||
hash_fn = __salt__['cp.cache_file'](source_hash)
|
||||
if not hash_fn:
|
||||
ret['result'] = False
|
||||
|
@ -448,8 +499,21 @@ def managed(name,
|
|||
source_hash
|
||||
)
|
||||
return ret
|
||||
source_sum['hsum'] = comps[1]
|
||||
source_sum['hash_type'] = comps[0]
|
||||
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:
|
||||
ret['result'] = False
|
||||
ret['comment'] = ('Unable to determine upstream hash of'
|
||||
|
|
0
salt/states/mysql_database.py
Executable file → Normal file
0
salt/states/mysql_database.py
Executable file → Normal file
0
salt/states/mysql_user.py
Executable file → Normal file
0
salt/states/mysql_user.py
Executable file → Normal file
0
salt/utils/find.py
Executable file → Normal file
0
salt/utils/find.py
Executable file → Normal 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.
|
||||
'''
|
||||
|
|
|
@ -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
|
||||
minion to run.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/python
|
||||
'''
|
||||
Publish commands to the salt system from the command line on the master.
|
||||
'''
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/python
|
||||
'''
|
||||
Manage the authentication keys with salt-key
|
||||
'''
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/python
|
||||
'''
|
||||
Start the salt-master
|
||||
'''
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/python2
|
||||
#!/usr/bin/python
|
||||
'''
|
||||
This script is used to kick off a salt minion daemon
|
||||
'''
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/python
|
||||
'''
|
||||
Execute a salt convenience routine
|
||||
'''
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/python2
|
||||
#!/usr/bin/python
|
||||
'''
|
||||
This script is used to kick off a salt syndic daemon
|
||||
'''
|
||||
|
|
Loading…
Add table
Reference in a new issue