mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge branch 'freebsd' of github.com:cedwards/salt into freebsd
This commit is contained in:
commit
34e5c6591b
@ -27401,7 +27401,7 @@ Hash all hostnames and addresses in the output.
|
||||
.SS salt.states.stateconf
|
||||
.SS Stateconf System
|
||||
.sp
|
||||
The stateconf system is inteded for use only with the stateconf renderer. This
|
||||
The stateconf system is intended for use only with the stateconf renderer. This
|
||||
State module presents the set function. This function does not execute any
|
||||
functionality, but is used to interact with the stateconf renderer.
|
||||
.INDENT 0.0
|
||||
|
@ -177,7 +177,7 @@ of matches you can perform:
|
||||
- match: grain
|
||||
- repos.ubuntu
|
||||
|
||||
'os:(RedHat|CentOS)'
|
||||
'os:(RedHat|CentOS)':
|
||||
- match: grain_pcre
|
||||
- repos.epel
|
||||
|
||||
@ -185,7 +185,7 @@ of matches you can perform:
|
||||
- match: list
|
||||
- database
|
||||
|
||||
'somekey:abc'
|
||||
'somekey:abc':
|
||||
- match: pillar
|
||||
- xyz
|
||||
|
||||
|
@ -4,22 +4,24 @@ Debian
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
Salt is currently available in in the Debian package tree:
|
||||
|
||||
http://packages.debian.org/source/salt
|
||||
|
||||
To install Salt on Wheezy or later use:
|
||||
If you're running a Debian release more recent than Wheezy use:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
apt-get install salt-master
|
||||
apt-get install salt-minion
|
||||
|
||||
As of this writing salt is only available in Debian unstable.
|
||||
|
||||
Squeeze
|
||||
=======
|
||||
|
||||
Salt is available for squeeze in the Debian backports repository, and may be
|
||||
installed as follows:
|
||||
To build your own salt Debian packages on squeeze use:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
@ -27,8 +29,32 @@ installed as follows:
|
||||
deb http://backports.debian.org/debian-backports squeeze-backports main
|
||||
EOF
|
||||
apt-get update
|
||||
apt-get -t squeeze-backports install salt-master
|
||||
apt-get -t squeeze-backports install salt-minion
|
||||
apt-get install build-essential fakeroot
|
||||
apt-get install python-argparse python-zmq
|
||||
apt-get -t squeeze-backports install debhelper python-sphinx
|
||||
|
||||
After installing the necessary dependencies build the packages with:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
git clone https://github.com/saltstack/salt.git
|
||||
cd salt
|
||||
fakeroot debian/rules binary
|
||||
|
||||
You will need to install the salt-common package along with the salt-minion or
|
||||
salt-master packages. For example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
dpkg -i salt-common_<version>.deb salt-minion<version>.deb
|
||||
apt-get -f install
|
||||
|
||||
The last command pulls in the required dependencies for your salt packages.
|
||||
|
||||
Wheezy
|
||||
======
|
||||
|
||||
Backports for Wheezy should be available shortly after it's release.
|
||||
|
||||
For more information how to use debian-backports see
|
||||
http://backports-master.debian.org/Instructions/
|
||||
|
@ -5,16 +5,28 @@ Ubuntu Installation
|
||||
Add repository
|
||||
--------------
|
||||
|
||||
The latest packages for Ubuntu are published in the saltstack PPA. Add the
|
||||
repository, import the PPA key, and refresh the package data with the following
|
||||
commands:
|
||||
The latest packages for Ubuntu are published in the saltstack PPA. If you have
|
||||
the ``add-apt-repository`` utility, you can add the repository and import the
|
||||
key in one step:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sudo add-apt-repository ppa:saltstack/salt
|
||||
|
||||
Alternately, manually add the repository and import the PPA key with these commands:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
echo deb http://ppa.launchpad.net/saltstack/salt/ubuntu `lsb_release -sc` main | sudo tee /etc/apt/sources.list.d/saltstack.list
|
||||
wget -q -O- "http://keyserver.ubuntu.com:11371/pks/lookup?op=get&search=0x4759FA960E27C0A6" | sudo apt-key add -
|
||||
|
||||
After adding the repository, update the package management database:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sudo apt-get update
|
||||
|
||||
|
||||
Install packages
|
||||
----------------
|
||||
|
||||
|
@ -2,17 +2,16 @@
|
||||
Reactor System
|
||||
==============
|
||||
|
||||
Salt version 0.11.0 introduced the reactor system. The premice behind the
|
||||
reactor system is that with Salt's events and the ability to execute commands
|
||||
a logic engine could be put in place to allow events to trigger actions, or
|
||||
more accurately, reactions.
|
||||
Salt version 0.11.0 introduced the reactor system. The premise behind the
|
||||
reactor system is that with Salt's events and the ability to execute commands a
|
||||
logic engine could be put in place to allow events to trigger actions, or more
|
||||
accurately, reactions.
|
||||
|
||||
This system binds sls files to event tags on the master which define
|
||||
executions. This means that the reactor system is two part, first in the master
|
||||
configuration file the reactor option needs to be set. The reactor option
|
||||
allows for event tags to be associated with sls reaction files. These reaction
|
||||
files are the second component, they define, using highdata, reactions to be
|
||||
executed.
|
||||
This system binds sls files to event tags on the master. These sls files then
|
||||
define reactions. This means that the reactor system has two parts. First, the
|
||||
reactor option needs to be set in the master configuration file. The reactor
|
||||
option allows for event tags to be associated with sls reaction files. Second,
|
||||
these reaction files use highdata to define reactions to be executed.
|
||||
|
||||
Event System
|
||||
============
|
||||
@ -22,17 +21,18 @@ The event system is a local ZeroMQ PUB interface which fires salt events. This
|
||||
event bus is an open system used for sending information notifying Salt and
|
||||
other systems about operations.
|
||||
|
||||
The event systsem fires events with a very specific criteria, every event has a
|
||||
`tag` which is comprised of a maximum of 20 charachters. Event tags can be
|
||||
listened to for top level filtering of events. Past the tag an event has a data
|
||||
structure. This data structure is a dict of information about the event.
|
||||
The event system fires events with a very specific criteria. Every event has a
|
||||
`tag` which is comprised of a maximum of 20 characters. Event tags allow for
|
||||
fast top level filtering of events. In addition to the tag, an event has a data
|
||||
structure. This data structure is a dict containing information about the
|
||||
event.
|
||||
|
||||
Mapping Events to Reactor SLS Files
|
||||
===================================
|
||||
|
||||
The event tag and data are both critical when working with the reactor system.
|
||||
In the master configuration under the reactor option, tags are associated with
|
||||
lists of reactor sls files (globs can be used for matching):
|
||||
In the master configuration file under the reactor option, tags are associated
|
||||
with lists of reactor sls files (globs can be used for matching):
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
@ -47,7 +47,7 @@ When an event with a tag of auth is fired the reactor will catch the event and
|
||||
render the two listed files. The rendered files are standard sls files, so by
|
||||
default they are yaml + jinja. The jinja is packed with a few data structures
|
||||
similar to state and pillar sls files. The data available is found in the `tag`
|
||||
and `data` variables. The `tag` variable is just the tag in the fired event,
|
||||
and `data` variables. The `tag` variable is just the tag in the fired event
|
||||
and the `data` variable is the event's data dict. Here is a simple reactor sls:
|
||||
|
||||
.. code-block:: yaml
|
||||
@ -58,13 +58,13 @@ and the `data` variable is the event's data dict. Here is a simple reactor sls:
|
||||
- tgt: mysql1
|
||||
{% endif %}
|
||||
|
||||
This simple reactor file uses jinja to further refine the execution to be made.
|
||||
The data is searched for `id` in the event data, if the minion is named mysql1
|
||||
then the following event is defined. The same data structure and compiler is
|
||||
used for reactors that is used for the state system. The difference is that
|
||||
the data matched up to the salt command api and the runner system. Is this
|
||||
This simple reactor file uses jinja to further refine the reaction to be made.
|
||||
If the `id` in the event data is mysql1 (if the name of the minion is mysql1) then
|
||||
the following reaction is defined. The same data structure and compiler used
|
||||
for the state system is used for the reactor system. The only difference is that the
|
||||
data is matched up to the salt command api and the runner system. In this
|
||||
example a command is published to the mysql1 minion with a function of
|
||||
state.highstate. Similarly a runner can be called:
|
||||
state.highstate. Similarly, a runner can be called:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
|
167
doc/topics/style.rst
Normal file
167
doc/topics/style.rst
Normal file
@ -0,0 +1,167 @@
|
||||
=================
|
||||
Salt Coding Style
|
||||
=================
|
||||
|
||||
Salt is developed with a certain coding style, while the style is dominantly
|
||||
PEP-08 it is not completely PEP-08. It is also noteworthy that a few
|
||||
development techniques are also employed which should be adhered to. In the
|
||||
end, the code is made to be "Salty".
|
||||
|
||||
Most importantly though, we will accept code that violates the coding style and
|
||||
KINDLY ask the contributor to fix it, or go ahead and fix the code on behalf of
|
||||
the contributor. Coding style is NEVER grounds to reject code contributions,
|
||||
and is never grounds to talk down to another member of the community (There are
|
||||
no grounds to treat others without respect, especially people working to
|
||||
improve Salt)!!
|
||||
|
||||
|
||||
Strings
|
||||
=======
|
||||
|
||||
Salt follows a few rules when formatting strings:
|
||||
|
||||
Single Quotes
|
||||
-------------
|
||||
|
||||
In Salt, all strings use single quotes unless there is a good reason not to.
|
||||
This means that docstrings use single quotes, standard strings use single
|
||||
quotes etc.:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def foo():
|
||||
'''
|
||||
A function that does things
|
||||
'''
|
||||
name = 'A name'
|
||||
return name
|
||||
|
||||
Formatting Strings
|
||||
------------------
|
||||
|
||||
All strings which require formatting should use the `.format` string method:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
data = 'some text'
|
||||
more = '{0} and then some'.format(data)
|
||||
|
||||
Make sure to use indices or identifiers in the format brackets, since empty
|
||||
brackets are not supported by python 2.6.
|
||||
|
||||
Please do NOT use printf formatting.
|
||||
|
||||
Docstring Conventions
|
||||
---------------------
|
||||
|
||||
Docstrings should always add a newline, docutils takes care of the new line and
|
||||
it makes the code cleaner and more vertical:
|
||||
|
||||
`GOOD`:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def bar():
|
||||
'''
|
||||
Here lies a docstring with a newline after the quotes and is the salty
|
||||
way to handle it! Vertical code is the way to go!
|
||||
'''
|
||||
return
|
||||
|
||||
`BAD`:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def baz():
|
||||
'''This is not ok!'''
|
||||
return
|
||||
|
||||
Imports
|
||||
=======
|
||||
|
||||
Salt code prefers importing modules and not explicit functions. This is both a
|
||||
style and functional preference. The functional preference originates around
|
||||
the fact that the module import system used by pluggable modules will include
|
||||
callable objects (functions) that exist in the direct module namespace. This
|
||||
is not only messy, but may unintentionally expose code python libs to the Salt
|
||||
interface and pose a security problem.
|
||||
|
||||
To say this more directly with an example, this is `GOOD`:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import os
|
||||
|
||||
def minion_path():
|
||||
path = os.path.join(self.opts['cachedir'], 'minions')
|
||||
return path
|
||||
|
||||
This on the other hand is `DISCOURAGED`:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from os.path import join
|
||||
|
||||
def minion_path():
|
||||
path = join(self.opts['cachedir'], 'minions')
|
||||
return path
|
||||
|
||||
The time when this is changed is for importing exceptions, generally directly
|
||||
importing exceptions is preferred:
|
||||
|
||||
This is a good way to import exceptions:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from salt.exceptions import CommandExecutionError
|
||||
|
||||
Vertical is Better
|
||||
==================
|
||||
|
||||
When writing Salt code, vertical code is generally preferred. This is not a hard
|
||||
rule but more of a guideline. As PEP-08 specifies Salt code should not exceed 79
|
||||
characters on a line, but it is preferred to separate code out into more
|
||||
newlines in some cases for better readability:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import os
|
||||
|
||||
os.chmod(
|
||||
os.path.join(self.opts['sock_dir'],
|
||||
'minion_event_pub.ipc'),
|
||||
448
|
||||
)
|
||||
|
||||
Where there are more line breaks, this is also apparent when constructing a
|
||||
function with many arguments, something very common in state functions for
|
||||
instance:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def managed(name,
|
||||
source=None,
|
||||
source_hash='',
|
||||
user=None,
|
||||
group=None,
|
||||
mode=None,
|
||||
template=None,
|
||||
makedirs=False,
|
||||
context=None,
|
||||
replace=True,
|
||||
defaults=None,
|
||||
env=None,
|
||||
backup='',
|
||||
**kwargs):
|
||||
|
||||
Code Churn
|
||||
==========
|
||||
|
||||
Many pull requests have been submitted that only churn code in the name of
|
||||
PEP-08. Code churn is a leading source of bugs and is strongly discouraged.
|
||||
While style fixes are encouraged they should be isolated to a single file per
|
||||
commit, and the changes should be legitimate, if there are any questions about
|
||||
whether a style change is legitimate please reference this document and the
|
||||
official PEP-08 (http://www.python.org/dev/peps/pep-0008/) document before
|
||||
changing code. Many claims that a change is PEP-08 have been invalid, please
|
||||
double check before committing fixes.
|
@ -1,7 +1,7 @@
|
||||
# Maintainer: Thomas S Hatch <thatch45@gmail.com>
|
||||
# Maintainer: Christer Edwards <christer.edwards@gmail.com>
|
||||
|
||||
pkgname=salt
|
||||
pkgver=0.9.4
|
||||
pkgver=0.11.1
|
||||
pkgrel=1
|
||||
pkgdesc="A remote execution and communication system built on zeromq"
|
||||
arch=(any)
|
||||
@ -11,31 +11,51 @@ depends=('python2'
|
||||
'python2-pyzmq'
|
||||
'python-m2crypto'
|
||||
'python2-yaml'
|
||||
'pycrypto'
|
||||
'python2-crypto'
|
||||
'python2-psutil'
|
||||
'python2-jinja')
|
||||
backup=('etc/salt/master'
|
||||
'python2-jinja'
|
||||
'python2-msgpack')
|
||||
|
||||
backup=('etc/salt/master'
|
||||
'etc/salt/minion')
|
||||
|
||||
makedepends=()
|
||||
optdepends=()
|
||||
options=()
|
||||
source=("https://github.com/downloads/saltstack/salt/$pkgname-$pkgver.tar.gz"
|
||||
conflicts=('salt-git')
|
||||
|
||||
source=("http://pypi.python.org/packages/source/s/${pkgname}/${pkgname}-${pkgver}.tar.gz"
|
||||
"salt-master.service"
|
||||
"salt-syndic.service"
|
||||
"salt-minion.service"
|
||||
"salt-master"
|
||||
"salt-syndic"
|
||||
"salt-minion")
|
||||
md5sums=('c27837bac06dadfdb51b4a2b63fe6d35'
|
||||
'1594591acb0a266854186a694da21103'
|
||||
'09683ef4966e401761f7d2db6ad4b692'
|
||||
'21ab2eac231e9f61bf002ba5f16f8a3d')
|
||||
|
||||
md5sums=('0e96a361a5bfb9a208a6a30b2537a7c2'
|
||||
'3a2b032ec37077363c049969105b128e'
|
||||
'e4c6adce5087e947c26c5c9d9fc3c9bb'
|
||||
'833d31ebee69f5c0e2c0b6c8d345b6d7'
|
||||
'33bb43fa74f67da7675c093664d43159'
|
||||
'b4adb3a08871646c345f0050e3d55fae'
|
||||
'ce64b6fb207142465bb5e2855e27cd8a')
|
||||
|
||||
package() {
|
||||
cd $srcdir/$pkgname-$pkgver
|
||||
cd ${srcdir}/${pkgname}-${pkgver}
|
||||
|
||||
python2 setup.py install --root=$pkgdir/ --optimize=1
|
||||
python2 setup.py install --root=${pkgdir}/ --optimize=1
|
||||
|
||||
mkdir -p $pkgdir/etc/rc.d/
|
||||
cp $srcdir/salt-master $pkgdir/etc/rc.d/
|
||||
cp $srcdir/salt-minion $pkgdir/etc/rc.d/
|
||||
cp $srcdir/salt-syndic $pkgdir/etc/rc.d/
|
||||
chmod +x $pkgdir/etc/rc.d/*
|
||||
mkdir -p ${pkgdir}/etc/rc.d/
|
||||
cp ${srcdir}/salt-master ${pkgdir}/etc/rc.d/
|
||||
cp ${srcdir}/salt-minion ${pkgdir}/etc/rc.d/
|
||||
cp ${srcdir}/salt-syndic ${pkgdir}/etc/rc.d/
|
||||
chmod +x ${pkgdir}/etc/rc.d/salt-{master,minion,syndic}
|
||||
|
||||
install -Dm644 ${srcdir}/salt-master.service ${pkgdir}/usr/lib/systemd/system/salt-master.service
|
||||
install -Dm644 ${srcdir}/salt-syndic.service ${pkgdir}/usr/lib/systemd/system/salt-syndic.service
|
||||
install -Dm644 ${srcdir}/salt-minion.service ${pkgdir}/usr/lib/systemd/system/salt-minion.service
|
||||
|
||||
mkdir -p ${pkgdir}/etc/salt/
|
||||
cp ${srcdir}/${pkgname}-${pkgver}/conf/master ${pkgdir}/etc/salt/
|
||||
cp ${srcdir}/${pkgname}-${pkgver}/conf/minion ${pkgdir}/etc/salt/
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Maintainer: Christer Edwards <christer.edwards@gmail.com>
|
||||
pkgname=salt-git
|
||||
pkgver=$(date +%Y%m%d)
|
||||
pkgver=20121219
|
||||
pkgrel=1
|
||||
pkgdesc="A remote execution and communication system built on zeromq"
|
||||
arch=('any')
|
||||
@ -31,9 +31,9 @@ source=("salt-master.service"
|
||||
"salt-minion"
|
||||
"salt-syndic")
|
||||
|
||||
md5sums=('3be813f49bf5ab9580cfc23e915eea4b'
|
||||
'8ef6ab9bf9750f146d31bd8da9da963b'
|
||||
'97e1daa0f7232f48d109b62890b68d0e'
|
||||
md5sums=('3a2b032ec37077363c049969105b128e'
|
||||
'833d31ebee69f5c0e2c0b6c8d345b6d7'
|
||||
'e4c6adce5087e947c26c5c9d9fc3c9bb'
|
||||
'1594591acb0a266854186a694da21103'
|
||||
'21ab2eac231e9f61bf002ba5f16f8a3d'
|
||||
'09683ef4966e401761f7d2db6ad4b692')
|
||||
|
@ -9,7 +9,7 @@
|
||||
%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
|
||||
|
||||
Name: salt
|
||||
Version: 0.11.0
|
||||
Version: 0.11.1
|
||||
Release: 1%{?dist}
|
||||
Summary: A parallel remote execution system
|
||||
|
||||
@ -290,6 +290,10 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Fri Dec 14 2012 Clint Savage <herlo1@gmail.com> - 0.11.1-1
|
||||
- Upstream patch release 0.11.1
|
||||
- Fixes security vulnerability (https://github.com/saltstack/salt/issues/2916)
|
||||
|
||||
* Fri Dec 14 2012 Clint Savage <herlo1@gmail.com> - 0.11.0-1
|
||||
- Moved to upstream release 0.11.0
|
||||
|
||||
|
@ -25,6 +25,7 @@ except ImportError:
|
||||
import salt.utils
|
||||
import salt.payload
|
||||
import salt.utils.verify
|
||||
import salt.version
|
||||
from salt.exceptions import AuthenticationError, SaltClientError, SaltReqTimeoutError
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -295,11 +296,11 @@ class Auth(object):
|
||||
log.critical(
|
||||
'The Salt Master server\'s public key did not authenticate!\n'
|
||||
'The master may need to be updated if it is a version of Salt '
|
||||
'lower than 0.10.4, or\n'
|
||||
'lower than {0}, or\n'
|
||||
'If you are confident that you are connecting to a valid Salt '
|
||||
'Master, then remove the master public key and restart the '
|
||||
'Salt Minion.\nThe master public key can be found '
|
||||
'at:\n{0}'.format(m_pub_fn)
|
||||
'at:\n{1}'.format(salt.version.__version__, m_pub_fn)
|
||||
)
|
||||
sys.exit(42)
|
||||
if self.opts.get('master_finger', False):
|
||||
|
@ -15,7 +15,10 @@ __outputter__ = {
|
||||
'get_all': 'yaml',
|
||||
}
|
||||
|
||||
SERVICE_DIR = "/service"
|
||||
if os.path.exists('/service'):
|
||||
SERVICE_DIR = "/service"
|
||||
elif os.path.exists('/var/service'):
|
||||
SERVICE_DIR = "/var/service"
|
||||
|
||||
|
||||
def _service_path(name):
|
||||
|
@ -40,7 +40,7 @@ def _active_mountinfo(ret):
|
||||
|
||||
|
||||
def _active_mounts(ret):
|
||||
filename = '/proc/self/mountinfo'
|
||||
filename = '/proc/self/mounts'
|
||||
if not os.access(filename, os.R_OK):
|
||||
msg = 'File not readable {0}'
|
||||
raise CommandExecutionError(msg.format(filename))
|
||||
@ -65,7 +65,7 @@ def active():
|
||||
ret = {}
|
||||
try:
|
||||
_active_mountinfo(ret)
|
||||
except IOError:
|
||||
except CommandExecutionError:
|
||||
_active_mounts(ret)
|
||||
return ret
|
||||
|
||||
|
@ -5,20 +5,23 @@ The networking module for RHEL/Fedora based distros
|
||||
# Import python libs
|
||||
import logging
|
||||
import re
|
||||
from os.path import exists, join
|
||||
import os.path
|
||||
import os
|
||||
import StringIO
|
||||
|
||||
# import third party libs
|
||||
import jinja2
|
||||
from jinja2.exceptions import TemplateNotFound
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
from salt.modules import __path__ as saltmodpath
|
||||
|
||||
# Set up logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# Set up template environment
|
||||
env = jinja2.Environment(loader=jinja2.PackageLoader('salt.modules', 'rh_ip'))
|
||||
env = jinja2.Environment(loader=jinja2.FileSystemLoader(saltmodpath[0] + os.sep + 'rh_ip'))
|
||||
|
||||
|
||||
def __virtual__():
|
||||
@ -718,9 +721,9 @@ def _write_file_iface(iface, data, folder, pattern):
|
||||
'''
|
||||
Writes a file to disk
|
||||
'''
|
||||
filename = join(folder, pattern.format(iface))
|
||||
if not exists(folder):
|
||||
msg = '{0} cannot be written. {1} does not exists'
|
||||
filename = os.path.join(folder, pattern.format(iface))
|
||||
if not os.path.exists(folder):
|
||||
msg = '{0} cannot be written. {1} does not exist'
|
||||
msg = msg.format(filename, folder)
|
||||
log.error(msg)
|
||||
raise AttributeError(msg)
|
||||
@ -759,10 +762,14 @@ def build_bond(iface, settings):
|
||||
rh_major = __grains__['osrelease'][:1]
|
||||
|
||||
opts = _parse_settings_bond(settings, iface)
|
||||
template = env.get_template('conf.jinja')
|
||||
try:
|
||||
template = env.get_template('conf.jinja')
|
||||
except TemplateNotFound:
|
||||
log.error('Could not load template conf.jinja')
|
||||
return ''
|
||||
data = template.render({'name': iface, 'bonding': opts})
|
||||
_write_file_iface(iface, data, _RH_NETWORK_CONF_FILES, '{0}.conf')
|
||||
path = join(_RH_NETWORK_CONF_FILES, '{0}.conf'.format(iface))
|
||||
path = os.path.join(_RH_NETWORK_CONF_FILES, '{0}.conf'.format(iface))
|
||||
if rh_major == '5':
|
||||
__salt__['cmd.run'](
|
||||
'sed -i -e "/^alias\s{0}.*/d" /etc/modprobe.conf'.format(iface)
|
||||
@ -810,14 +817,18 @@ def build_interface(iface, iface_type, enabled, settings):
|
||||
|
||||
if iface_type in ['eth', 'bond', 'bridge', 'slave', 'vlan']:
|
||||
opts = _parse_settings_eth(settings, iface_type, enabled, iface)
|
||||
template = env.get_template('rh{0}_eth.jinja'.format(rh_major))
|
||||
try:
|
||||
template = env.get_template('rh{0}_eth.jinja'.format(rh_major))
|
||||
except TemplateNotFound:
|
||||
log.error('Could not load template rh{0}_eth.jinja'.format(rh_major))
|
||||
return ''
|
||||
ifcfg = template.render(opts)
|
||||
|
||||
if settings['test']:
|
||||
return _read_temp(ifcfg)
|
||||
|
||||
_write_file_iface(iface, ifcfg, _RH_NETWORK_SCRIPT_DIR, 'ifcfg-{0}')
|
||||
path = join(_RH_NETWORK_SCRIPT_DIR, 'ifcfg-{0}'.format(iface))
|
||||
path = os.path.join(_RH_NETWORK_SCRIPT_DIR, 'ifcfg-{0}'.format(iface))
|
||||
|
||||
return _read_file(path)
|
||||
|
||||
@ -844,7 +855,7 @@ def get_bond(iface):
|
||||
|
||||
salt '*' ip.get_bond bond0
|
||||
'''
|
||||
path = join(_RH_NETWORK_CONF_FILES, '{0}.conf'.format(iface))
|
||||
path = os.path.join(_RH_NETWORK_CONF_FILES, '{0}.conf'.format(iface))
|
||||
return _read_file(path)
|
||||
|
||||
|
||||
@ -856,7 +867,7 @@ def get_interface(iface):
|
||||
|
||||
salt '*' ip.get_interface eth0
|
||||
'''
|
||||
path = join(_RH_NETWORK_SCRIPT_DIR, 'ifcfg-{0}'.format(iface))
|
||||
path = os.path.join(_RH_NETWORK_SCRIPT_DIR, 'ifcfg-{0}'.format(iface))
|
||||
return _read_file(path)
|
||||
|
||||
|
||||
@ -919,7 +930,11 @@ def build_network_settings(settings):
|
||||
|
||||
# Build settings
|
||||
opts = _parse_network_settings(settings, current_network_settings)
|
||||
template = env.get_template('network.jinja')
|
||||
try:
|
||||
template = env.get_template('network.jinja')
|
||||
except TemplateNotFound:
|
||||
log.error('Could not load template network.jinja')
|
||||
return ''
|
||||
network = template.render(opts)
|
||||
|
||||
if settings['test']:
|
||||
|
@ -80,7 +80,8 @@ def set_zone(timezone):
|
||||
if not os.path.exists(zonepath):
|
||||
return 'Zone does not exist: {0}'.format(zonepath)
|
||||
|
||||
os.unlink('/etc/localtime')
|
||||
if os.path.exists('/etc/localtime'):
|
||||
os.unlink('/etc/localtime')
|
||||
os.symlink(zonepath, '/etc/localtime')
|
||||
|
||||
if 'Arch' in __grains__['os_family']:
|
||||
|
@ -10,6 +10,29 @@ rc scripts, services can be defined as running or dead.
|
||||
httpd:
|
||||
service:
|
||||
- running
|
||||
|
||||
The service can also be set to be started at runtime via the enable option:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
openvpn:
|
||||
service:
|
||||
- running
|
||||
- enable: True
|
||||
|
||||
By default if a service is triggered to refresh due to a watch statement the
|
||||
service is by default restarted. If the desired behaviour is to reload the
|
||||
service then set the reload value to True:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
redis:
|
||||
service:
|
||||
- running
|
||||
- enable: True
|
||||
- reload: True
|
||||
- watch:
|
||||
- pkg: redis
|
||||
'''
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
Stateconf System
|
||||
================
|
||||
|
||||
The stateconf system is inteded for use only with the stateconf renderer. This
|
||||
The stateconf system is intended for use only with the stateconf renderer. This
|
||||
State module presents the set function. This function does not execute any
|
||||
functionality, but is used to interact with the stateconf renderer.
|
||||
'''
|
||||
|
@ -41,7 +41,7 @@ def managed(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
/var/www/myvirtualenv.com:
|
||||
virtualenv.manage:
|
||||
virtualenv.managed:
|
||||
- no_site_packages: True
|
||||
- requirements: salt://REQUIREMENTS.txt
|
||||
'''
|
||||
|
Loading…
Reference in New Issue
Block a user