Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit dfd82ad0bd33d892e0025d76a70997e2f1ebb1f2 1 parent 1607550
@QuinnyPig QuinnyPig authored
Showing with 305 additions and 133 deletions.
  1. +8 −2 conf/minion.template
  2. +1 −1  debian/changelog
  3. +29 −21 debian/control
  4. +3 −3 debian/copyright
  5. +3 −0  debian/lintian-overrides
  6. +2 −3 debian/rules
  7. +25 −9 debian/salt-common.install
  8. +1 −0  debian/salt-common.manpages
  9. +6 −1 debian/salt-master.install
  10. +0 −3  debian/{links → salt-master.links}
  11. +2 −3 debian/salt-master.manpages
  12. +4 −4 debian/salt-minion.install
  13. +2 −0  debian/salt-minion.links
  14. +1 −0  debian/salt-syndic.install
  15. +1 −0  debian/salt-syndic.links
  16. +0 −9 debian/salt.manpages
  17. +3 −3 doc/man/salt-cp.1
  18. +6 −7 doc/man/salt.7
  19. +3 −3 doc/ref/cli/salt-cp.rst
  20. +19 −0 doc/ref/configuration/minion.rst
  21. +2 −1  doc/topics/index.rst
  22. 0  salt/__init__.py
  23. +1 −0  salt/config.py
  24. 0  salt/log.py
  25. +45 −18 salt/minion.py
  26. +11 −0 salt/modules/apache.py
  27. +1 −1  salt/modules/cmd.py
  28. 0  salt/modules/mysql.py
  29. +16 −2 salt/modules/nginx.py
  30. +8 −9 salt/modules/solr.py
  31. +1 −1  salt/returners/cassandra_return.py
  32. +8 −0 salt/state.py
  33. +85 −21 salt/states/file.py
  34. 0  salt/states/mysql_database.py
  35. 0  salt/states/mysql_user.py
  36. 0  salt/utils/find.py
  37. +1 −1  scripts/salt
  38. +1 −1  scripts/salt-call
  39. +1 −1  scripts/salt-cp
  40. +1 −1  scripts/salt-key
  41. +1 −1  scripts/salt-master
  42. +1 −1  scripts/salt-minion
  43. +1 −1  scripts/salt-run
  44. +1 −1  scripts/salt-syndic
View
10 conf/minion.template
@@ -29,10 +29,16 @@
# 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
+#acceptance_wait_time = 10
View
2  debian/changelog
@@ -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)
View
50 debian/control
@@ -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
@@ -24,8 +21,20 @@ Homepage: http://saltstack.org
Package: salt-common
Architecture: any
-Depends: ${python:Depends},
- ${misc:Depends}
+Depends: ${python: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.
View
6 debian/copyright
@@ -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.
View
3  debian/lintian-overrides
@@ -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.
View
5 debian/rules
@@ -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"
View
34 debian/salt-common.install
@@ -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
View
1  debian/salt-common.manpages
@@ -0,0 +1 @@
+doc/man/salt.7
View
7 debian/salt-master.install
@@ -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
3  debian/links → debian/salt-master.links
@@ -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
View
5 debian/salt-master.manpages
@@ -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
View
8 debian/salt-minion.install
@@ -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
View
2  debian/salt-minion.links
@@ -0,0 +1,2 @@
+usr/share/salt/salt-minion /usr/bin/salt-minion
+usr/share/salt/salt-call /usr/bin/salt-call
View
1  debian/salt-syndic.install
@@ -0,0 +1 @@
+scripts/salt-syndic /usr/share/salt
View
1  debian/salt-syndic.links
@@ -0,0 +1 @@
+usr/share/salt/salt-syndic /usr/bin/salt-syndic
View
9 debian/salt.manpages
@@ -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
6 doc/man/salt-cp.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
View
13 doc/man/salt.7
@@ -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.
-.\"
.
View
6 doc/ref/cli/salt-cp.rst
@@ -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
View
19 doc/ref/configuration/minion.rst
@@ -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
View
3  doc/topics/index.rst
@@ -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
=======================
View
0  salt/__init__.py 100755 → 100644
File mode changed
View
1  salt/config.py
@@ -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,
View
0  salt/log.py 100755 → 100644
File mode changed
View
63 salt/minion.py
@@ -226,14 +226,19 @@ def _thread_return(self, data):
ret['jid'] = data['jid']
ret['fun'] = data['fun']
+ self._return_pub(ret)
if data['ret']:
- ret['id'] = self.opts['id']
- try:
- self.returners[data['ret']](ret)
- except Exception as exc:
- log.error('The return failed for job %s %s', data['jid'], exc)
- else:
- self._return_pub(ret)
+ for returner in set(data['ret'].split(',')):
+ ret['id'] = self.opts['id']
+ try:
+ self.returners[returner](ret)
+ except Exception as exc:
+ log.error(
+ 'The return failed for job {0} {1}'.format(
+ data['jid'],
+ exc
+ )
+ )
def _thread_multi_return(self, data):
'''
@@ -259,23 +264,32 @@ def _thread_multi_return(self, data):
= 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']:
- ret['id'] = self.opts['id']
- try:
- self.returners[data['ret']](ret)
- except Exception as exc:
- log.error('The return failed for job %s %s', data['jid'], exc)
- else:
- self._return_pub(ret)
+ for returner in set(data['ret'].split(',')):
+ ret['id'] = self.opts['id']
+ try:
+ self.returners[returner](ret)
+ except Exception as exc:
+ 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 @@ def _return_pub(self, ret, ret_cmd='_return'):
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):
'''
View
11 salt/modules/apache.py 100755 → 100644
@@ -3,12 +3,23 @@
'''
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
View
2  salt/modules/cmd.py
@@ -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):
View
0  salt/modules/mysql.py 100755 → 100644
File mode changed
View
18 salt/modules/nginx.py 100755 → 100644
@@ -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
View
17 salt/modules/solr.py
@@ -59,11 +59,15 @@
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?
'''
- return 'solr'
- names = ['solr', 'apache-solr']
- for name in names:
- if __salt__['pkg.version'](name):
- return 'solr'
-
+ if salt.utils.which('solr'):
+ return 'solr'
+ if salt.utils.which('apache-solr'):
+ return 'solr'
return False
def _get_none_or_value(value):
View
2  salt/returners/cassandra_return.py
@@ -43,5 +43,5 @@ def returner(ret):
else:
columns['return'] = str(ret['return'])
- log.debug(back)
+ log.debug(columns)
cf.insert(ret['jid'], columns)
View
8 salt/state.py
@@ -989,6 +989,14 @@ def call_highstate(self):
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):
View
106 salt/states/file.py
@@ -69,6 +69,7 @@
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,11 +383,21 @@ 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
+ 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
@@ -432,24 +480,40 @@ def managed(name,
ret['comment'] = 'Source file {0} not found'.format(source)
return ret
elif source_hash:
- hash_fn = __salt__['cp.cache_file'](source_hash)
- if not hash_fn:
- ret['result'] = False
- ret['comment'] = 'Source hash file {0} not found'.format(
- source_hash
- )
- return ret
- comps = open(hash_fn, 'r').read().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]
- source_sum['hash_type'] = comps[0]
+ 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
+ ret['comment'] = 'Source hash file {0} not found'.format(
+ source_hash
+ )
+ return ret
+ comps = open(hash_fn, 'r').read().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:
+ # 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'
View
0  salt/states/mysql_database.py 100755 → 100644
File mode changed
View
0  salt/states/mysql_user.py 100755 → 100644
File mode changed
View
0  salt/utils/find.py 100755 → 100644
File mode changed
View
2  scripts/salt
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/python
'''
Publish commands to the salt system from the command line on the master.
'''
View
2  scripts/salt-call
@@ -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.
View
2  scripts/salt-cp
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/python
'''
Publish commands to the salt system from the command line on the master.
'''
View
2  scripts/salt-key
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/python
'''
Manage the authentication keys with salt-key
'''
View
2  scripts/salt-master
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/python
'''
Start the salt-master
'''
View
2  scripts/salt-minion
@@ -1,4 +1,4 @@
-#!/usr/bin/python2
+#!/usr/bin/python
'''
This script is used to kick off a salt minion daemon
'''
View
2  scripts/salt-run
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/python
'''
Execute a salt convenience routine
'''
View
2  scripts/salt-syndic
@@ -1,4 +1,4 @@
-#!/usr/bin/python2
+#!/usr/bin/python
'''
This script is used to kick off a salt syndic daemon
'''
Please sign in to comment.
Something went wrong with that request. Please try again.