mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
more documentation cleanup
This commit is contained in:
parent
015766d28b
commit
9a5d086bf3
4
doc/topics/tutorials/extend_with_require_watch.rst
Normal file
4
doc/topics/tutorials/extend_with_require_watch.rst
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
.. admonition:: Using extend with require or watch
|
||||||
|
|
||||||
|
The ``extend`` statement works differently for ``require`` or ``watch``.
|
||||||
|
It appends to, rather than replacing the requisite component.
|
@ -4,6 +4,7 @@ following the :doc:`installation </topics/installation/index>` and the :doc:`con
|
|||||||
|
|
||||||
.. admonition:: Stuck?
|
.. admonition:: Stuck?
|
||||||
|
|
||||||
If you get stuck at any point, there are many ways to :doc:`get help from
|
There are many ways to :doc:`get help from the Salt community
|
||||||
the Salt community </topics/community>` including our mailing list and our
|
</topics/community>` including our
|
||||||
IRC channel.
|
`mailing list <http://groups.google.com/group/salt-users/>`_
|
||||||
|
and our `IRC channel <http://webchat.freenode.net/>`_ #salt.
|
||||||
|
@ -273,10 +273,7 @@ to configure the banner.
|
|||||||
In the new mod_python SLS the mod_python package is added, but more importantly
|
In the new mod_python SLS the mod_python package is added, but more importantly
|
||||||
the apache service was extended to also watch the mod_python package.
|
the apache service was extended to also watch the mod_python package.
|
||||||
|
|
||||||
.. admonition:: Using extend with require or watch
|
.. include:: extend_with_require_watch.rst
|
||||||
|
|
||||||
The ``extend`` statement works differently for ``require`` or ``watch``.
|
|
||||||
It appends to, rather than replacing the requisite component.
|
|
||||||
|
|
||||||
Understanding the Render System
|
Understanding the Render System
|
||||||
===============================
|
===============================
|
||||||
|
@ -2,12 +2,14 @@
|
|||||||
States tutorial, part 2
|
States tutorial, part 2
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
This tutorial builds on the topic covered in :doc:`part 1 <states_pt1>`. It is
|
.. note::
|
||||||
recommended that you begin there.
|
|
||||||
|
|
||||||
In the last Salt States tutorial we covered the basics of installing a package.
|
This tutorial builds on the topic covered in :doc:`part 1 <states_pt1>`.
|
||||||
In this tutorial we will modify our ``webserver.sls`` file to be more
|
It is recommended that you begin there.
|
||||||
complicated, have requirements, and use even more Salt States.
|
|
||||||
|
In the :doc:`last part <states_pt1>` of the Salt States tutorial we covered
|
||||||
|
the basics of installing a package. We will now modify our ``webserver.sls``
|
||||||
|
file to have requirements, and use even more Salt States.
|
||||||
|
|
||||||
Call multiple States
|
Call multiple States
|
||||||
====================
|
====================
|
||||||
@ -158,4 +160,4 @@ Next steps
|
|||||||
==========
|
==========
|
||||||
|
|
||||||
In :doc:`part 3 <states_pt3>` we will discuss how to use includes, extends and
|
In :doc:`part 3 <states_pt3>` we will discuss how to use includes, extends and
|
||||||
templating to make hugely complicated State Tree configurations dead-simple.
|
templating to make a more complete State Tree configuration.
|
||||||
|
@ -2,26 +2,27 @@
|
|||||||
States tutorial, part 3
|
States tutorial, part 3
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
This tutorial builds on the topic covered in :doc:`part 2 <states_pt2>`. It is
|
.. note::
|
||||||
recommended that you begin there.
|
|
||||||
|
|
||||||
This tutorial will cover more advanced templating and configuration techniques
|
This tutorial builds on the topic covered in :doc:`part1 <states_pt1>` and
|
||||||
for ``sls`` files.
|
:doc:`part 2 <states_pt2>`. It is recommended that you begin there.
|
||||||
|
|
||||||
|
This part of the tutorial will cover more advanced templating and
|
||||||
|
configuration techniques for ``sls`` files.
|
||||||
|
|
||||||
Templating SLS modules
|
Templating SLS modules
|
||||||
======================
|
======================
|
||||||
|
|
||||||
SLS modules may require programming logic or inline executions. This is
|
SLS modules may require programming logic or inline execution. This is
|
||||||
accomplished with module templating. The default module templating system used
|
accomplished with module templating. The default module templating system used
|
||||||
is `Jinja2`_ and may be configured by changing the :conf_master:`renderer`
|
is `Jinja2`_ and may be configured by changing the :conf_master:`renderer`
|
||||||
value in the master config.
|
value in the master config.
|
||||||
|
|
||||||
.. _`Jinja2`: http://jinja.pocoo.org/
|
.. _`Jinja2`: http://jinja.pocoo.org/
|
||||||
|
|
||||||
All states are passed through a templating system when they are initially read,
|
All states are passed through a templating system when they are initially read.
|
||||||
so all that is required to make use of the templating system is to add some
|
To make use of the templating system, simple add some templating markup.
|
||||||
templating code. An example of an sls module with templating may look like
|
An example of an sls module with templating markup may look like this:
|
||||||
this:
|
|
||||||
|
|
||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
|
|
||||||
@ -45,8 +46,8 @@ Using Grains in SLS modules
|
|||||||
===========================
|
===========================
|
||||||
|
|
||||||
Often times a state will need to behave differently on different systems.
|
Often times a state will need to behave differently on different systems.
|
||||||
:doc:`Salt grains </topics/targeting/grains>` can be used from within sls modules. An object
|
:doc:`Salt grains </topics/targeting/grains>` objects are made available
|
||||||
called ``grains`` is made available in the template context:
|
in the template context. The `grains` can be used from within sls modules:
|
||||||
|
|
||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
|
|
||||||
@ -83,31 +84,31 @@ The Salt module functions are also made available in the template context as
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
Below is an example that uses the ``network.hwaddr`` function to retrieve the
|
Below is an example that uses the ``network.hwaddr`` function to retrieve the
|
||||||
MAC address for eth0:
|
MAC address for eth0::
|
||||||
|
|
||||||
salt['network.hwaddr']('eth0')
|
salt['network.hwaddr']('eth0')
|
||||||
|
|
||||||
Advanced SLS module syntax
|
Advanced SLS module syntax
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
Last we will cover some incredibly useful techniques for more complex State
|
Lastly, we will cover some incredibly useful techniques for more complex State
|
||||||
trees.
|
trees.
|
||||||
|
|
||||||
:term:`Include declaration`
|
:term:`Include declaration`
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
You have seen an example of how to spread a Salt tree across several files but
|
A previous example showed how to spread a Salt tree across several files.
|
||||||
in order to be able to have :term:`requisite references <requisite reference>`
|
Similarly, :term:`requisite references <requisite references>` span multiple
|
||||||
span multiple files you must use an :term:`include declaration`. For example:
|
files by using an :term:`include declaration`. For example:
|
||||||
|
|
||||||
``python-libs.sls``:
|
``python/python-libs.sls``:
|
||||||
|
|
||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
|
|
||||||
python-dateutil:
|
python-dateutil:
|
||||||
pkg.installed
|
pkg.installed
|
||||||
|
|
||||||
``django.sls``:
|
``python/django.sls``:
|
||||||
|
|
||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
|
|
||||||
@ -126,14 +127,14 @@ You can modify previous declarations by using an :term:`extend declaration`. For
|
|||||||
example the following modifies the Apache tree to also restart Apache when the
|
example the following modifies the Apache tree to also restart Apache when the
|
||||||
vhosts file is changed:
|
vhosts file is changed:
|
||||||
|
|
||||||
``apache.sls``:
|
``apache/apache.sls``:
|
||||||
|
|
||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
|
|
||||||
apache:
|
apache:
|
||||||
pkg.installed
|
pkg.installed
|
||||||
|
|
||||||
``mywebsite.sls``:
|
``apache/mywebsite.sls``:
|
||||||
|
|
||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
|
|
||||||
@ -148,8 +149,9 @@ vhosts file is changed:
|
|||||||
|
|
||||||
/etc/httpd/extra/httpd-vhosts.conf:
|
/etc/httpd/extra/httpd-vhosts.conf:
|
||||||
file.managed:
|
file.managed:
|
||||||
- source: salt://httpd-vhosts.conf
|
- source: salt://apache/httpd-vhosts.conf
|
||||||
|
|
||||||
|
.. include:: extend_with_require_watch.rst
|
||||||
|
|
||||||
:term:`Name declaration`
|
:term:`Name declaration`
|
||||||
------------------------
|
------------------------
|
||||||
@ -158,10 +160,10 @@ You can override the :term:`ID declaration` by using a :term:`name
|
|||||||
declaration`. For example, the previous example is a bit more maintainable if
|
declaration`. For example, the previous example is a bit more maintainable if
|
||||||
rewritten as follows:
|
rewritten as follows:
|
||||||
|
|
||||||
``mywebsite.sls``:
|
``apache/mywebsite.sls``:
|
||||||
|
|
||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
:emphasize-lines: 8,10,13
|
:emphasize-lines: 8,10,12
|
||||||
|
|
||||||
include:
|
include:
|
||||||
- apache
|
- apache
|
||||||
@ -175,7 +177,7 @@ rewritten as follows:
|
|||||||
mywebsite:
|
mywebsite:
|
||||||
file.managed:
|
file.managed:
|
||||||
- name: /etc/httpd/extra/httpd-vhosts.conf
|
- name: /etc/httpd/extra/httpd-vhosts.conf
|
||||||
- source: salt://httpd-vhosts.conf
|
- source: salt://apache/httpd-vhosts.conf
|
||||||
|
|
||||||
:term:`Names declaration`
|
:term:`Names declaration`
|
||||||
-------------------------
|
-------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user