mirror of
https://github.com/valitydev/salt.git
synced 2024-11-09 01:36:48 +00:00
Merge branch '2014.7' into develop
This commit is contained in:
commit
8a07ac9213
99
debian/salt-api.init
vendored
Normal file
99
debian/salt-api.init
vendored
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: salt-api
|
||||||
|
# Required-Start: $remote_fs $network
|
||||||
|
# Required-Stop: $remote_fs $network
|
||||||
|
# Default-Start: 2 3 4 5
|
||||||
|
# Default-Stop: 0 1 6
|
||||||
|
# Short-Description: salt api control daemon
|
||||||
|
# Description: This is a daemon that controls the salt minions
|
||||||
|
### END INIT INFO
|
||||||
|
|
||||||
|
# Author: Michael Prokop <mika@debian.org>
|
||||||
|
|
||||||
|
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||||
|
DESC="salt api control daemon"
|
||||||
|
NAME=salt-api
|
||||||
|
DAEMON=/usr/bin/salt-api
|
||||||
|
DAEMON_ARGS="-d"
|
||||||
|
PIDFILE=/var/run/$NAME.pid
|
||||||
|
SCRIPTNAME=/etc/init.d/$NAME
|
||||||
|
|
||||||
|
# Exit if the package is not installed
|
||||||
|
[ -x "$DAEMON" ] || exit 0
|
||||||
|
|
||||||
|
# Read configuration variable file if it is present
|
||||||
|
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
|
||||||
|
|
||||||
|
. /lib/init/vars.sh
|
||||||
|
. /lib/lsb/init-functions
|
||||||
|
|
||||||
|
do_start() {
|
||||||
|
pid=$(pidofproc -p $PIDFILE $DAEMON)
|
||||||
|
if [ -n "$pid" ] ; then
|
||||||
|
log_begin_msg "$DESC already running."
|
||||||
|
log_end_msg 0
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
log_daemon_msg "Starting salt-api daemon: "
|
||||||
|
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS
|
||||||
|
log_end_msg $?
|
||||||
|
}
|
||||||
|
|
||||||
|
do_stop() {
|
||||||
|
log_begin_msg "Stopping $DESC ..."
|
||||||
|
start-stop-daemon --stop --retry TERM/5 --quiet --oknodo --pidfile $PIDFILE
|
||||||
|
RC=$?
|
||||||
|
[ $RC -eq 0 ] && rm -f $PIDFILE
|
||||||
|
log_end_msg $RC
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
|
||||||
|
do_start
|
||||||
|
case "$?" in
|
||||||
|
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||||
|
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
|
||||||
|
do_stop
|
||||||
|
case "$?" in
|
||||||
|
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||||
|
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
status)
|
||||||
|
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
|
||||||
|
;;
|
||||||
|
#reload)
|
||||||
|
# not implemented
|
||||||
|
#;;
|
||||||
|
restart|force-reload)
|
||||||
|
log_daemon_msg "Restarting $DESC" "$NAME"
|
||||||
|
do_stop
|
||||||
|
case "$?" in
|
||||||
|
0|1)
|
||||||
|
do_start
|
||||||
|
case "$?" in
|
||||||
|
0) log_end_msg 0 ;;
|
||||||
|
1) log_end_msg 1 ;; # Old process is still running
|
||||||
|
*) log_end_msg 1 ;; # Failed to start
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# Failed to stop
|
||||||
|
log_end_msg 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
|
||||||
|
exit 3
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
@ -1571,7 +1571,7 @@ def contains_glob(path, glob_expr):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def append(path, *args):
|
def append(path, *args, **kwargs):
|
||||||
'''
|
'''
|
||||||
.. versionadded:: 0.9.5
|
.. versionadded:: 0.9.5
|
||||||
|
|
||||||
@ -1590,9 +1590,28 @@ def append(path, *args):
|
|||||||
salt '*' file.append /etc/motd \\
|
salt '*' file.append /etc/motd \\
|
||||||
"With all thine offerings thou shalt offer salt." \\
|
"With all thine offerings thou shalt offer salt." \\
|
||||||
"Salt is what makes things taste bad when it isn't in them."
|
"Salt is what makes things taste bad when it isn't in them."
|
||||||
|
|
||||||
|
.. admonition:: Attention
|
||||||
|
|
||||||
|
If you need to pass a string to append and that string contains
|
||||||
|
an equal sign, you **must** include the argument name, args.
|
||||||
|
For example:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
salt '*' file.append /etc/motd args='cheese=spam'
|
||||||
|
|
||||||
|
salt '*' file.append /etc/motd args="['cheese=spam','spam=cheese']"
|
||||||
|
|
||||||
'''
|
'''
|
||||||
# Largely inspired by Fabric's contrib.files.append()
|
# Largely inspired by Fabric's contrib.files.append()
|
||||||
|
|
||||||
|
if 'args' in kwargs:
|
||||||
|
if isinstance(kwargs['args'], list):
|
||||||
|
args = kwargs['args']
|
||||||
|
else:
|
||||||
|
args = [kwargs['args']]
|
||||||
|
|
||||||
with salt.utils.fopen(path, "r+") as ofile:
|
with salt.utils.fopen(path, "r+") as ofile:
|
||||||
# Make sure we have a newline at the end of the file
|
# Make sure we have a newline at the end of the file
|
||||||
try:
|
try:
|
||||||
@ -1616,7 +1635,7 @@ def append(path, *args):
|
|||||||
return 'Wrote {0} lines to "{1}"'.format(len(args), path)
|
return 'Wrote {0} lines to "{1}"'.format(len(args), path)
|
||||||
|
|
||||||
|
|
||||||
def prepend(path, *args):
|
def prepend(path, *args, **kwargs):
|
||||||
'''
|
'''
|
||||||
.. versionadded:: 2014.7.0
|
.. versionadded:: 2014.7.0
|
||||||
|
|
||||||
@ -1635,7 +1654,27 @@ def prepend(path, *args):
|
|||||||
salt '*' file.prepend /etc/motd \\
|
salt '*' file.prepend /etc/motd \\
|
||||||
"With all thine offerings thou shalt offer salt." \\
|
"With all thine offerings thou shalt offer salt." \\
|
||||||
"Salt is what makes things taste bad when it isn't in them."
|
"Salt is what makes things taste bad when it isn't in them."
|
||||||
|
|
||||||
|
.. admonition:: Attention
|
||||||
|
|
||||||
|
If you need to pass a string to append and that string contains
|
||||||
|
an equal sign, you **must** include the argument name, args.
|
||||||
|
For example:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
salt '*' file.prepend /etc/motd args='cheese=spam'
|
||||||
|
|
||||||
|
salt '*' file.prepend /etc/motd args="['cheese=spam','spam=cheese']"
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
if 'args' in kwargs:
|
||||||
|
if isinstance(kwargs['args'], list):
|
||||||
|
args = kwargs['args']
|
||||||
|
else:
|
||||||
|
args = [kwargs['args']]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
contents = salt.utils.fopen(path).readlines()
|
contents = salt.utils.fopen(path).readlines()
|
||||||
except IOError:
|
except IOError:
|
||||||
@ -1651,7 +1690,7 @@ def prepend(path, *args):
|
|||||||
return 'Prepended {0} lines to "{1}"'.format(len(args), path)
|
return 'Prepended {0} lines to "{1}"'.format(len(args), path)
|
||||||
|
|
||||||
|
|
||||||
def write(path, *args):
|
def write(path, *args, **kwargs):
|
||||||
'''
|
'''
|
||||||
.. versionadded:: 2014.7.0
|
.. versionadded:: 2014.7.0
|
||||||
|
|
||||||
@ -1669,7 +1708,27 @@ def write(path, *args):
|
|||||||
|
|
||||||
salt '*' file.write /etc/motd \\
|
salt '*' file.write /etc/motd \\
|
||||||
"With all thine offerings thou shalt offer salt."
|
"With all thine offerings thou shalt offer salt."
|
||||||
|
|
||||||
|
.. admonition:: Attention
|
||||||
|
|
||||||
|
If you need to pass a string to append and that string contains
|
||||||
|
an equal sign, you **must** include the argument name, args.
|
||||||
|
For example:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
salt '*' file.write /etc/motd args='cheese=spam'
|
||||||
|
|
||||||
|
salt '*' file.write /etc/motd args="['cheese=spam','spam=cheese']"
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
if 'args' in kwargs:
|
||||||
|
if isinstance(kwargs['args'], list):
|
||||||
|
args = kwargs['args']
|
||||||
|
else:
|
||||||
|
args = [kwargs['args']]
|
||||||
|
|
||||||
contents = []
|
contents = []
|
||||||
for line in args:
|
for line in args:
|
||||||
contents.append('{0}\n'.format(line))
|
contents.append('{0}\n'.format(line))
|
||||||
|
@ -16,9 +16,6 @@ import salt.utils.odict
|
|||||||
|
|
||||||
__proxyenabled__ = ['*']
|
__proxyenabled__ = ['*']
|
||||||
|
|
||||||
import logging
|
|
||||||
log = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
__func_alias__ = {
|
__func_alias__ = {
|
||||||
'list_': 'list',
|
'list_': 'list',
|
||||||
'reload_': 'reload'
|
'reload_': 'reload'
|
||||||
|
@ -8,6 +8,8 @@ intended for use primarily from the state runner from the master.
|
|||||||
|
|
||||||
The salt.state declaration can call out a highstate or a list of sls:
|
The salt.state declaration can call out a highstate or a list of sls:
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
webservers:
|
webservers:
|
||||||
salt.state:
|
salt.state:
|
||||||
- tgt: 'web*'
|
- tgt: 'web*'
|
||||||
|
Loading…
Reference in New Issue
Block a user