mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
Change all state examples to use short-dec format for consistency
Closes #12419. The command used to search the docs for state examples is below. This generates a file in Vim's quickfix format that can be loaded with the -q flag. find . -type f \( -name '*.rst' -o -name '*.py' \) -print0 | xargs -0 -P10 -n1 awk ' BEGIN { RS=""; FS="\n" } { linenr = linect; linect += (NF + 1) } /^\s+[a-zA-Z0-9'\''_-]+:\n\s+[a-zA-Z0-9'\''_-]+:\n\s+- / { print FILENAME "|" linenr + 2 "|", $1 } ' > ./salt-states.quickfix
This commit is contained in:
parent
c0567bab0f
commit
51fa87c446
16
doc/faq.rst
16
doc/faq.rst
@ -203,8 +203,7 @@ Linux/Unix
|
||||
.. code-block:: yaml
|
||||
|
||||
salt-minion-reload:
|
||||
cmd:
|
||||
- run
|
||||
cmd.run:
|
||||
- name: echo service salt-minion restart | at now + 1 minute
|
||||
- order: last
|
||||
|
||||
@ -215,10 +214,9 @@ distro the minion is running, in case they differ from the example below.
|
||||
.. code-block:: yaml
|
||||
|
||||
at:
|
||||
pkg:
|
||||
- installed
|
||||
service:
|
||||
- running
|
||||
pkg.installed:
|
||||
- name: at
|
||||
service.running:
|
||||
- name: atd
|
||||
- enable: True
|
||||
|
||||
@ -240,13 +238,11 @@ Windows
|
||||
.. code-block:: yaml
|
||||
|
||||
schedule-start:
|
||||
cmd:
|
||||
- run
|
||||
cmd.run:
|
||||
- name: at (Get-Date).AddMinutes(1).ToString("HH:mm") cmd /c "net start salt-minion"
|
||||
- shell: powershell
|
||||
- order: last
|
||||
service:
|
||||
- dead
|
||||
service.dead:
|
||||
- name: salt-minion
|
||||
- require:
|
||||
- cmd: schedule-start
|
||||
|
@ -57,16 +57,17 @@ As an example, a state written thusly:
|
||||
.. code-block:: yaml
|
||||
|
||||
apache:
|
||||
pkg:
|
||||
- installed
|
||||
service:
|
||||
- running
|
||||
pkg.installed:
|
||||
- name: httpd
|
||||
service.running:
|
||||
- name: httpd
|
||||
- watch:
|
||||
- file: /etc/httpd/conf.d/httpd.conf
|
||||
- file: apache_conf
|
||||
- pkg: apache
|
||||
/etc/httpd/conf.d/httpd.conf:
|
||||
file:
|
||||
- managed
|
||||
|
||||
apache_conf:
|
||||
file.managed:
|
||||
- name: /etc/httpd/conf.d/httpd.conf
|
||||
- source: salt://apache/httpd.conf
|
||||
|
||||
Will have High Data which looks like this represented in json:
|
||||
@ -76,41 +77,50 @@ Will have High Data which looks like this represented in json:
|
||||
{
|
||||
"apache": {
|
||||
"pkg": [
|
||||
{
|
||||
"name": "httpd"
|
||||
},
|
||||
"installed",
|
||||
{
|
||||
"order": 10000
|
||||
}
|
||||
],
|
||||
"service": [
|
||||
"running",
|
||||
{
|
||||
"name": "httpd"
|
||||
},
|
||||
{
|
||||
"watch": [
|
||||
{
|
||||
"file": "/etc/httpd/conf.d/httpd.conf"
|
||||
"file": "apache_conf"
|
||||
},
|
||||
{
|
||||
"pkg": "apache"
|
||||
}
|
||||
]
|
||||
},
|
||||
"running",
|
||||
{
|
||||
"order": 10001
|
||||
}
|
||||
],
|
||||
"__sls__": "apache",
|
||||
"__sls__": "blah",
|
||||
"__env__": "base"
|
||||
},
|
||||
"/etc/httpd/conf.d/httpd.conf": {
|
||||
"apache_conf": {
|
||||
"file": [
|
||||
"managed",
|
||||
{
|
||||
"name": "/etc/httpd/conf.d/httpd.conf"
|
||||
},
|
||||
{
|
||||
"source": "salt://apache/httpd.conf"
|
||||
},
|
||||
"managed",
|
||||
{
|
||||
"order": 10002
|
||||
}
|
||||
],
|
||||
"__sls__": "apache",
|
||||
"__sls__": "blah",
|
||||
"__env__": "base"
|
||||
}
|
||||
}
|
||||
@ -121,19 +131,19 @@ The subsequent Low Data will look like this:
|
||||
|
||||
[
|
||||
{
|
||||
"name": "apache",
|
||||
"name": "httpd",
|
||||
"state": "pkg",
|
||||
"__id__": "apache",
|
||||
"fun": "installed",
|
||||
"__env__": "base",
|
||||
"__sls__": "apache",
|
||||
"__sls__": "blah",
|
||||
"order": 10000
|
||||
},
|
||||
{
|
||||
"name": "apache",
|
||||
"name": "httpd",
|
||||
"watch": [
|
||||
{
|
||||
"file": "/etc/httpd/conf.d/httpd.conf"
|
||||
"file": "apache_conf"
|
||||
},
|
||||
{
|
||||
"pkg": "apache"
|
||||
@ -143,22 +153,21 @@ The subsequent Low Data will look like this:
|
||||
"__id__": "apache",
|
||||
"fun": "running",
|
||||
"__env__": "base",
|
||||
"__sls__": "apache",
|
||||
"__sls__": "blah",
|
||||
"order": 10001
|
||||
},
|
||||
{
|
||||
"name": "/etc/httpd/conf.d/httpd.conf",
|
||||
"source": "salt://apache/httpd.conf",
|
||||
"state": "file",
|
||||
"__id__": "/etc/httpd/conf.d/httpd.conf",
|
||||
"__id__": "apache_conf",
|
||||
"fun": "managed",
|
||||
"__env__": "base",
|
||||
"__sls__": "apache",
|
||||
"__sls__": "blah",
|
||||
"order": 10002
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
This tutorial discusses the Low Data evaluation and the state runtime.
|
||||
|
||||
Ordering Layers
|
||||
@ -235,8 +244,8 @@ ordering can be explicitly overridden using the `order` flag in states:
|
||||
.. code-block:: yaml
|
||||
|
||||
apache:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed:
|
||||
- name: httpd
|
||||
- order: 1
|
||||
|
||||
This order flag will over ride the definition order, this makes it very
|
||||
|
@ -103,8 +103,8 @@ declaration that will restart Apache whenever the Apache configuration file,
|
||||
- file: mywebsite
|
||||
|
||||
mywebsite:
|
||||
file:
|
||||
- managed
|
||||
file.managed:
|
||||
- name: /var/www/mysite
|
||||
|
||||
.. seealso:: watch_in and require_in
|
||||
|
||||
@ -168,10 +168,10 @@ For example, the following state declaration calls the :mod:`installed
|
||||
.. code-block:: yaml
|
||||
|
||||
httpd:
|
||||
pkg.installed
|
||||
pkg.installed: []
|
||||
|
||||
The function can be declared inline with the state as a shortcut, but
|
||||
the actual data structure is better referenced in this form:
|
||||
The function can be declared inline with the state as a shortcut.
|
||||
The actual data structure is compiled to this form:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
@ -203,10 +203,8 @@ VALID:
|
||||
.. code-block:: yaml
|
||||
|
||||
httpd:
|
||||
pkg:
|
||||
- installed
|
||||
service:
|
||||
- running
|
||||
pkg.installed: []
|
||||
service.running: []
|
||||
|
||||
Occurs as the only index in the :ref:`state-declaration` list.
|
||||
|
||||
@ -280,8 +278,7 @@ easier to specify ``mywebsite`` than to specify
|
||||
- file: mywebsite
|
||||
|
||||
apache2:
|
||||
service:
|
||||
- running
|
||||
service.running:
|
||||
- watch:
|
||||
- file: mywebsite
|
||||
|
||||
|
@ -113,19 +113,17 @@ Here is an example of a Salt State:
|
||||
.. code-block:: yaml
|
||||
|
||||
vim:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed: []
|
||||
|
||||
salt:
|
||||
pkg:
|
||||
- latest
|
||||
pkg.latest:
|
||||
- name: salt
|
||||
service.running:
|
||||
- require:
|
||||
- file: /etc/salt/minion
|
||||
- pkg: salt
|
||||
- names:
|
||||
- salt-master
|
||||
- salt-minion
|
||||
- require:
|
||||
- pkg: salt
|
||||
- watch:
|
||||
- file: /etc/salt/minion
|
||||
|
||||
@ -196,15 +194,15 @@ the following state file which we'll call ``pep8.sls``:
|
||||
.. code-block:: yaml
|
||||
|
||||
python-pip:
|
||||
cmd:
|
||||
- run
|
||||
cmd.run:
|
||||
- name: |
|
||||
easy_install --script-dir=/usr/bin -U pip
|
||||
- cwd: /
|
||||
- name: easy_install --script-dir=/usr/bin -U pip
|
||||
|
||||
pep8:
|
||||
pip.installed
|
||||
requires:
|
||||
- cmd: python-pip
|
||||
pip.installed:
|
||||
- require:
|
||||
- cmd: python-pip
|
||||
|
||||
|
||||
The above example installs `pip`_ using ``easy_install`` from `setuptools`_ and
|
||||
@ -276,16 +274,16 @@ The modified state file would now be:
|
||||
.. code-block:: yaml
|
||||
|
||||
python-pip:
|
||||
cmd:
|
||||
- run
|
||||
cmd.run:
|
||||
- name: |
|
||||
easy_install --script-dir=/usr/bin -U pip
|
||||
- cwd: /
|
||||
- name: easy_install --script-dir=/usr/bin -U pip
|
||||
- reload_modules: true
|
||||
|
||||
pep8:
|
||||
pip.installed
|
||||
requires:
|
||||
- cmd: python-pip
|
||||
pip.installed:
|
||||
- require:
|
||||
- cmd: python-pip
|
||||
|
||||
|
||||
Let's run it, once:
|
||||
|
@ -61,8 +61,7 @@ These requisite statements are applied to a specific state declaration:
|
||||
.. code-block:: yaml
|
||||
|
||||
httpd:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed: []
|
||||
file.managed:
|
||||
- name: /etc/httpd/conf/httpd.conf
|
||||
- source: salt://httpd/httpd.conf
|
||||
@ -91,10 +90,8 @@ the discrete states are split or groups into separate sls files:
|
||||
- network
|
||||
|
||||
httpd:
|
||||
pkg:
|
||||
- installed
|
||||
service:
|
||||
- running
|
||||
pkg.installed: []
|
||||
service.running:
|
||||
- require:
|
||||
- pkg: httpd
|
||||
- sls: network
|
||||
@ -121,8 +118,7 @@ more requisites. Both requisite types can also be separately declared:
|
||||
.. code-block:: yaml
|
||||
|
||||
httpd:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed: []
|
||||
service.running:
|
||||
- enable: True
|
||||
- watch:
|
||||
@ -136,10 +132,8 @@ more requisites. Both requisite types can also be separately declared:
|
||||
- source: salt://httpd/httpd.conf
|
||||
- require:
|
||||
- pkg: httpd
|
||||
user:
|
||||
- present
|
||||
group:
|
||||
- present
|
||||
user.present: []
|
||||
group.present: []
|
||||
|
||||
In this example, the httpd service is only going to be started if the package,
|
||||
user, group and file are executed successfully.
|
||||
|
@ -20,7 +20,7 @@ the targeting state. The following example demonstrates a direct requisite:
|
||||
.. code-block:: yaml
|
||||
|
||||
vim:
|
||||
pkg.installed
|
||||
pkg.installed: []
|
||||
|
||||
/etc/vimrc:
|
||||
file.managed:
|
||||
@ -258,15 +258,13 @@ The ``onfail`` requisite is applied in the same way as ``require`` as ``watch``:
|
||||
.. code-block:: yaml
|
||||
|
||||
primary_mount:
|
||||
mount:
|
||||
- mounted
|
||||
mount.mounted:
|
||||
- name: /mnt/share
|
||||
- device: 10.0.0.45:/share
|
||||
- fstype: nfs
|
||||
|
||||
backup_mount:
|
||||
mount:
|
||||
- mounted
|
||||
mount.mounted:
|
||||
- name: /mnt/share
|
||||
- device: 192.168.40.34:/share
|
||||
- fstype: nfs
|
||||
@ -338,10 +336,8 @@ Using ``require``
|
||||
.. code-block:: yaml
|
||||
|
||||
httpd:
|
||||
pkg:
|
||||
- installed
|
||||
service:
|
||||
- running
|
||||
pkg.installed: []
|
||||
service.running:
|
||||
- require:
|
||||
- pkg: httpd
|
||||
|
||||
@ -350,12 +346,10 @@ Using ``require_in``
|
||||
.. code-block:: yaml
|
||||
|
||||
httpd:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed:
|
||||
- require_in:
|
||||
- service: httpd
|
||||
service:
|
||||
- running
|
||||
service.running: []
|
||||
|
||||
The ``require_in`` statement is particularly useful when assigning a require
|
||||
in a separate sls file. For instance it may be common for httpd to require
|
||||
@ -367,10 +361,8 @@ http.sls
|
||||
.. code-block:: yaml
|
||||
|
||||
httpd:
|
||||
pkg:
|
||||
- installed
|
||||
service:
|
||||
- running
|
||||
pkg.installed: []
|
||||
service.running:
|
||||
- require:
|
||||
- pkg: httpd
|
||||
|
||||
@ -382,8 +374,7 @@ php.sls
|
||||
- http
|
||||
|
||||
php:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed:
|
||||
- require_in:
|
||||
- service: httpd
|
||||
|
||||
@ -395,8 +386,7 @@ mod_python.sls
|
||||
- http
|
||||
|
||||
mod_python:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed:
|
||||
- require_in:
|
||||
- service: httpd
|
||||
|
||||
|
@ -192,8 +192,7 @@ preferred:
|
||||
- apache
|
||||
|
||||
apache_conf:
|
||||
file:
|
||||
- managed
|
||||
file.managed:
|
||||
- name: {{ name }}
|
||||
- source: {{ tmpl }}
|
||||
- template: jinja
|
||||
@ -224,8 +223,7 @@ locations within a single state:
|
||||
- apache
|
||||
|
||||
apache_conf:
|
||||
file:
|
||||
- managed
|
||||
file.managed:
|
||||
- name: {{ salt['pillar.get']('apache:lookup:name') }}
|
||||
- source: {{ salt['pillar.get']('apache:lookup:config:tmpl') }}
|
||||
- template: jinja
|
||||
@ -250,15 +248,12 @@ is not very modular to one that is:
|
||||
.. code-block:: yaml
|
||||
|
||||
httpd:
|
||||
pkg:
|
||||
- installed
|
||||
service:
|
||||
- running
|
||||
pkg.installed: []
|
||||
service.running:
|
||||
- enable: True
|
||||
|
||||
/etc/httpd/httpd.conf:
|
||||
file:
|
||||
- managed
|
||||
file.managed:
|
||||
- source: salt://apache/files/httpd.conf
|
||||
- template: jinja
|
||||
- watch_in:
|
||||
@ -286,17 +281,14 @@ opposed to direct ID references:
|
||||
.. code-block:: yaml
|
||||
|
||||
apache:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed:
|
||||
- name: httpd
|
||||
service:
|
||||
service.running:
|
||||
- name: httpd
|
||||
- enable: True
|
||||
- running
|
||||
|
||||
apache_conf:
|
||||
file:
|
||||
- managed
|
||||
file.managed:
|
||||
- name: /etc/httpd/httpd.conf
|
||||
- source: salt://apache/files/httpd.conf
|
||||
- template: jinja
|
||||
@ -351,17 +343,14 @@ modification of static values:
|
||||
{% from "apache/map.jinja" import apache with context %}
|
||||
|
||||
apache:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed:
|
||||
- name: {{ apache.server }}
|
||||
service:
|
||||
service.running:
|
||||
- name: {{ apache.service }}
|
||||
- enable: True
|
||||
- running
|
||||
|
||||
apache_conf:
|
||||
file:
|
||||
- managed
|
||||
file.managed:
|
||||
- name: {{ apache.conf }}
|
||||
- source: {{ salt['pillar.get']('apache:lookup:config:tmpl') }}
|
||||
- template: jinja
|
||||
@ -411,13 +400,11 @@ to be broken into two states.
|
||||
{% from "apache/map.jinja" import apache with context %}
|
||||
|
||||
apache:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed:
|
||||
- name: {{ apache.server }}
|
||||
service:
|
||||
service.running:
|
||||
- name: {{ apache.service }}
|
||||
- enable: True
|
||||
- running
|
||||
|
||||
``/srv/salt/apache/conf.sls``:
|
||||
|
||||
@ -429,8 +416,7 @@ to be broken into two states.
|
||||
- apache
|
||||
|
||||
apache_conf:
|
||||
file:
|
||||
- managed
|
||||
file.managed:
|
||||
- name: {{ apache.conf }}
|
||||
- source: {{ salt['pillar.get']('apache:lookup:config:tmpl') }}
|
||||
- template: jinja
|
||||
@ -463,8 +449,7 @@ accessible by the appropriate hosts:
|
||||
.. code-block:: yaml
|
||||
|
||||
testdb:
|
||||
mysql_database:
|
||||
- present:
|
||||
mysql_database.present::
|
||||
- name: testerdb
|
||||
|
||||
``/srv/salt/mysql/user.sls``:
|
||||
@ -475,8 +460,7 @@ accessible by the appropriate hosts:
|
||||
- mysql.testerdb
|
||||
|
||||
testdb_user:
|
||||
mysql_user:
|
||||
- present
|
||||
mysql_user.present:
|
||||
- name: frank
|
||||
- password: "test3rdb"
|
||||
- host: localhost
|
||||
@ -521,8 +505,7 @@ the associated pillar:
|
||||
.. code-block:: yaml
|
||||
|
||||
testdb:
|
||||
mysql_database:
|
||||
- present:
|
||||
mysql_database.present:
|
||||
- name: {{ salt['pillar.get']('mysql:lookup:name') }}
|
||||
|
||||
``/srv/salt/mysql/user.sls``:
|
||||
@ -533,8 +516,7 @@ the associated pillar:
|
||||
- mysql.testerdb
|
||||
|
||||
testdb_user:
|
||||
mysql_user:
|
||||
- present
|
||||
mysql_user.present:
|
||||
- name: {{ salt['pillar.get']('mysql:lookup:user') }}
|
||||
- password: {{ salt['pillar.get']('mysql:lookup:password') }}
|
||||
- host: {{ salt['pillar.get']('mysql:lookup:host') }}
|
||||
|
@ -116,8 +116,7 @@ package until after the EPEL repository has also been installed:
|
||||
- epel
|
||||
|
||||
python26:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed:
|
||||
- require:
|
||||
- pkg: epel
|
||||
|
||||
@ -767,11 +766,9 @@ state file using the following syntax:
|
||||
{% from "mysql/map.jinja" import mysql with context %}
|
||||
|
||||
mysql-server:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed:
|
||||
- name: {{ mysql.server }}
|
||||
service:
|
||||
- running
|
||||
service.running:
|
||||
- name: {{ mysql.service }}
|
||||
|
||||
Overriding values in the lookup table
|
||||
@ -973,11 +970,9 @@ skips platform-specific options for brevity. See the full
|
||||
|
||||
# apache/init.sls
|
||||
apache:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed:
|
||||
[...]
|
||||
service:
|
||||
- running
|
||||
service.running:
|
||||
[...]
|
||||
|
||||
# apache/mod_wsgi.sls
|
||||
@ -985,8 +980,7 @@ skips platform-specific options for brevity. See the full
|
||||
- apache
|
||||
|
||||
mod_wsgi:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed:
|
||||
[...]
|
||||
- require:
|
||||
- pkg: apache
|
||||
@ -996,8 +990,7 @@ skips platform-specific options for brevity. See the full
|
||||
- apache
|
||||
|
||||
apache_conf:
|
||||
file:
|
||||
- managed
|
||||
file.managed:
|
||||
[...]
|
||||
- watch_in:
|
||||
- service: apache
|
||||
@ -1088,8 +1081,7 @@ thousands of function calls across a large state tree.
|
||||
{% set settings = salt['pillar.get']('apache', {}) %}
|
||||
|
||||
mod_status:
|
||||
file:
|
||||
- managed
|
||||
file.managed:
|
||||
- name: {{ apache.conf_dir }}
|
||||
- source: {{ settings.get('mod_status_conf', 'salt://apache/mod_status.conf') }}
|
||||
- template: {{ settings.get('template_engine', 'jinja') }}
|
||||
|
@ -85,15 +85,14 @@ the minion:
|
||||
.. code-block:: yaml
|
||||
|
||||
update_zmq:
|
||||
pkg:
|
||||
- latest
|
||||
pkg.latest:
|
||||
- pkgs:
|
||||
- zeromq
|
||||
- python-zmq
|
||||
- order: last
|
||||
cmd:
|
||||
- wait
|
||||
- name: echo service salt-minion restart | at now + 1 minute
|
||||
cmd.wait:
|
||||
- name: |
|
||||
echo service salt-minion restart | at now + 1 minute
|
||||
- watch:
|
||||
- pkg: update_zmq
|
||||
|
||||
|
@ -96,8 +96,7 @@ to add them to the pool of load balanced servers.
|
||||
.. code-block:: yaml
|
||||
|
||||
haproxy_config:
|
||||
file:
|
||||
- managed
|
||||
file.managed:
|
||||
- name: /etc/haproxy/config
|
||||
- source: salt://haproxy_config
|
||||
- template: jinja
|
||||
|
@ -96,15 +96,13 @@ more via the shared pillar :ref:`dict <python2:typesmapping>`:
|
||||
.. code-block:: yaml
|
||||
|
||||
apache:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed:
|
||||
- name: {{ pillar['apache'] }}
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
git:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed:
|
||||
- name: {{ pillar['git'] }}
|
||||
|
||||
Finally, the above states can utilize the values provided to them via Pillar.
|
||||
|
@ -53,20 +53,16 @@ to set up the libvirt pki keys.
|
||||
.. code-block:: yaml
|
||||
|
||||
libvirt:
|
||||
pkg:
|
||||
- installed
|
||||
file:
|
||||
- managed
|
||||
pkg.installed: []
|
||||
file.managed:
|
||||
- name: /etc/sysconfig/libvirtd
|
||||
- contents: 'LIBVIRTD_ARGS="--listen"'
|
||||
- require:
|
||||
- pkg: libvirt
|
||||
libvirt:
|
||||
- keys
|
||||
libvirt.keys:
|
||||
- require:
|
||||
- pkg: libvirt
|
||||
service:
|
||||
- running
|
||||
service.running:
|
||||
- name: libvirtd
|
||||
- require:
|
||||
- pkg: libvirt
|
||||
@ -76,12 +72,10 @@ to set up the libvirt pki keys.
|
||||
- file: libvirt
|
||||
|
||||
libvirt-python:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed: []
|
||||
|
||||
libguestfs:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed:
|
||||
- pkgs:
|
||||
- libguestfs
|
||||
- libguestfs-tools
|
||||
|
@ -247,8 +247,7 @@ A simple formula:
|
||||
.. code-block:: yaml
|
||||
|
||||
vim:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed: []
|
||||
|
||||
/etc/vimrc:
|
||||
file.managed:
|
||||
@ -266,8 +265,7 @@ Can be easily transformed into a powerful, parameterized formula:
|
||||
.. code-block:: jinja
|
||||
|
||||
vim:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed:
|
||||
- name: {{ pillar['pkgs']['vim'] }}
|
||||
|
||||
/etc/vimrc:
|
||||
|
@ -67,10 +67,8 @@ A typical SLS file will often look like this in YAML:
|
||||
.. code-block:: yaml
|
||||
|
||||
apache:
|
||||
pkg:
|
||||
- installed
|
||||
service:
|
||||
- running
|
||||
pkg.installed: []
|
||||
service.running:
|
||||
- require:
|
||||
- pkg: apache
|
||||
|
||||
@ -107,10 +105,8 @@ and a user and group may need to be set up.
|
||||
.. code-block:: yaml
|
||||
|
||||
apache:
|
||||
pkg:
|
||||
- installed
|
||||
service:
|
||||
- running
|
||||
pkg.installed: []
|
||||
service.running:
|
||||
- watch:
|
||||
- pkg: apache
|
||||
- file: /etc/httpd/conf/httpd.conf
|
||||
@ -455,11 +451,9 @@ a MooseFS distributed filesystem chunkserver:
|
||||
- pkg: mfs-chunkserver
|
||||
|
||||
mfs-chunkserver:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed: []
|
||||
mfschunkserver:
|
||||
service:
|
||||
- running
|
||||
service.running:
|
||||
- require:
|
||||
{% for mnt in salt['cmd.run']('ls /dev/data/moose*') %}
|
||||
- mount: /mnt/moose{{ mnt[-1] }}
|
||||
|
@ -23,10 +23,8 @@ You can specify multiple :ref:`state-declaration` under an
|
||||
:emphasize-lines: 4,5
|
||||
|
||||
apache:
|
||||
pkg:
|
||||
- installed
|
||||
service:
|
||||
- running
|
||||
pkg.installed: []
|
||||
service.running:
|
||||
- require:
|
||||
- pkg: apache
|
||||
|
||||
@ -47,10 +45,8 @@ installed and running. Include the following at the bottom of your
|
||||
:emphasize-lines: 7,11
|
||||
|
||||
apache:
|
||||
pkg:
|
||||
- installed
|
||||
service:
|
||||
- running
|
||||
pkg.installed: []
|
||||
service.running:
|
||||
- require:
|
||||
- pkg: apache
|
||||
|
||||
@ -121,15 +117,12 @@ Verify that Apache is now serving your custom HTML.
|
||||
:emphasize-lines: 1,2,3,4,11,12
|
||||
|
||||
/etc/httpd/extra/httpd-vhosts.conf:
|
||||
file:
|
||||
- managed
|
||||
file.managed:
|
||||
- source: salt://webserver/httpd-vhosts.conf
|
||||
|
||||
apache:
|
||||
pkg:
|
||||
- installed
|
||||
service:
|
||||
- running
|
||||
pkg.installed: []
|
||||
service.running:
|
||||
- watch:
|
||||
- file: /etc/httpd/extra/httpd-vhosts.conf
|
||||
- require:
|
||||
|
@ -88,8 +88,7 @@ The Salt module functions are also made available in the template context as
|
||||
.. code-block:: jinja
|
||||
|
||||
moe:
|
||||
user:
|
||||
- present
|
||||
user.present:
|
||||
- gid: {{ salt['file.group_to_gid']('some_group_that_exists') }}
|
||||
|
||||
Note that for the above example to work, ``some_group_that_exists`` must exist
|
||||
|
@ -519,7 +519,7 @@ Now, to beef up the vim SLS formula, a ``vimrc`` can be added:
|
||||
.. code-block:: yaml
|
||||
|
||||
vim:
|
||||
pkg.installed
|
||||
pkg.installed: []
|
||||
|
||||
/etc/vimrc:
|
||||
file.managed:
|
||||
@ -553,10 +553,8 @@ make an nginx subdirectory and add an init.sls file:
|
||||
.. code-block:: yaml
|
||||
|
||||
nginx:
|
||||
pkg:
|
||||
- installed
|
||||
service:
|
||||
- running
|
||||
pkg.installed: []
|
||||
service.running:
|
||||
- require:
|
||||
- pkg: nginx
|
||||
|
||||
|
@ -158,11 +158,9 @@ def filter_by(lookup_dict, grain='os_family', merge=None):
|
||||
}) %}
|
||||
|
||||
myapache:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed:
|
||||
- name: {{ apache.pkg }}
|
||||
service:
|
||||
- running
|
||||
service.running:
|
||||
- name: {{ apache.srv }}
|
||||
|
||||
Values in the lookup table may be overridden by values in Pillar. An
|
||||
|
@ -9,8 +9,7 @@ so it can be used to maintain services using the ``provider`` argument:
|
||||
.. code-block:: yaml
|
||||
|
||||
myservice:
|
||||
service:
|
||||
- running
|
||||
service.running:
|
||||
- provider: daemontools
|
||||
'''
|
||||
|
||||
|
@ -366,11 +366,9 @@ def filter_by(lookup_dict, grain='os_family', merge=None, default='default'):
|
||||
}), default='Debian' %}
|
||||
|
||||
myapache:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed:
|
||||
- name: {{ apache.pkg }}
|
||||
service:
|
||||
- running
|
||||
service.running:
|
||||
- name: {{ apache.srv }}
|
||||
|
||||
Values in the lookup table may be overridden by values in Pillar. An
|
||||
|
@ -47,8 +47,7 @@ def extracted(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
graylog2-server:
|
||||
archive:
|
||||
- extracted
|
||||
archive.extracted:
|
||||
- name: /opt/
|
||||
- source: https://github.com/downloads/Graylog2/graylog2-server/graylog2-server-0.9.6p1.tar.lzma
|
||||
- source_hash: md5=499ae16dcae71eeb7c3a30c75ea7a1a6
|
||||
@ -59,8 +58,7 @@ def extracted(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
graylog2-server:
|
||||
archive:
|
||||
- extracted
|
||||
archive.extracted:
|
||||
- name: /opt/
|
||||
- source: https://github.com/downloads/Graylog2/graylog2-server/graylog2-server-0.9.6p1.tar.gz
|
||||
- source_hash: md5=499ae16dcae71eeb7c3a30c75ea7a1a6
|
||||
|
@ -13,8 +13,7 @@ A state module to manage blockdevices
|
||||
- read-only: True
|
||||
|
||||
master-data:
|
||||
blockdev:
|
||||
- tuned:
|
||||
blockdev.tuned::
|
||||
- name : /dev/vg/master-data
|
||||
- read-only: True
|
||||
- read-ahead: 1024
|
||||
|
@ -147,17 +147,14 @@ executed when the state it is watching changes. Example:
|
||||
.. code-block:: yaml
|
||||
|
||||
/usr/local/bin/postinstall.sh:
|
||||
cmd:
|
||||
- wait
|
||||
cmd.wait:
|
||||
- watch:
|
||||
- pkg: mycustompkg
|
||||
file:
|
||||
- managed
|
||||
file.managed:
|
||||
- source: salt://utils/scripts/postinstall.sh
|
||||
|
||||
mycustompkg:
|
||||
pkg:
|
||||
- installed
|
||||
pkg.installed:
|
||||
- require:
|
||||
- file: /usr/local/bin/postinstall.sh
|
||||
|
||||
|
@ -167,8 +167,7 @@ def started(name):
|
||||
.. code-block:: yaml
|
||||
|
||||
mycluster:
|
||||
glusterfs:
|
||||
- started
|
||||
glusterfs.started: []
|
||||
'''
|
||||
ret = {'name': name,
|
||||
'changes': {},
|
||||
|
@ -46,13 +46,11 @@ def installed(name,
|
||||
.. code-block:: yaml
|
||||
|
||||
coffee-script:
|
||||
npm:
|
||||
- installed
|
||||
npm.installed:
|
||||
- user: someuser
|
||||
|
||||
coffee-script@1.0.1:
|
||||
npm:
|
||||
- installed
|
||||
npm.installed: []
|
||||
|
||||
name
|
||||
The package to install
|
||||
|
@ -10,8 +10,7 @@ typically rather simple:
|
||||
.. code-block:: yaml
|
||||
|
||||
pkgng_clients:
|
||||
pkgng:
|
||||
- update_packaging_site
|
||||
pkgng.update_packaging_site:
|
||||
- name: "http://192.168.0.2"
|
||||
'''
|
||||
|
||||
|
@ -9,8 +9,7 @@ only addition/deletion of licenses is supported.
|
||||
.. code-block:: yaml
|
||||
|
||||
key:
|
||||
powerpath:
|
||||
- license_present
|
||||
powerpath.license_present: []
|
||||
'''
|
||||
|
||||
|
||||
|
@ -10,8 +10,7 @@ Example:
|
||||
.. code-block:: yaml
|
||||
|
||||
some_plugin:
|
||||
rabbitmq_plugin:
|
||||
- enabled
|
||||
rabbitmq_plugin.enabled: []
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
|
@ -15,8 +15,7 @@ configuration could look like:
|
||||
.. code-block:: yaml
|
||||
|
||||
rvm:
|
||||
group:
|
||||
- present
|
||||
group.present: []
|
||||
user.present:
|
||||
- gid: rvm
|
||||
- home: /home/rvm
|
||||
@ -25,7 +24,7 @@ configuration could look like:
|
||||
|
||||
rvm-deps:
|
||||
pkg.installed:
|
||||
- names:
|
||||
- pkgs:
|
||||
- bash
|
||||
- coreutils
|
||||
- gzip
|
||||
@ -38,7 +37,7 @@ configuration could look like:
|
||||
|
||||
mri-deps:
|
||||
pkg.installed:
|
||||
- names:
|
||||
- pkgs:
|
||||
- build-essential
|
||||
- openssl
|
||||
- libreadline6
|
||||
@ -65,7 +64,7 @@ configuration could look like:
|
||||
|
||||
jruby-deps:
|
||||
pkg.installed:
|
||||
- names:
|
||||
- pkgs:
|
||||
- curl
|
||||
- g++
|
||||
- openjdk-6-jre-headless
|
||||
|
@ -9,16 +9,14 @@ rc scripts, services can be defined as running or dead.
|
||||
.. code-block:: yaml
|
||||
|
||||
httpd:
|
||||
service:
|
||||
- running
|
||||
service.running: []
|
||||
|
||||
The service can also be set to be started at runtime via the enable option:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
openvpn:
|
||||
service:
|
||||
- running
|
||||
service.running:
|
||||
- enable: True
|
||||
|
||||
By default if a service is triggered to refresh due to a watch statement the
|
||||
@ -28,8 +26,7 @@ service, then set the reload value to True:
|
||||
.. code-block:: yaml
|
||||
|
||||
redis:
|
||||
service:
|
||||
- running
|
||||
service.running:
|
||||
- enable: True
|
||||
- reload: True
|
||||
- watch:
|
||||
|
@ -15,27 +15,23 @@ to use a YAML 'explicit key', as demonstrated in the second example below.
|
||||
.. code-block:: yaml
|
||||
|
||||
AAAAB3NzaC1kc3MAAACBAL0sQ9fJ5bYTEyY==:
|
||||
ssh_auth:
|
||||
- present
|
||||
ssh_auth.present:
|
||||
- user: root
|
||||
- enc: ssh-dss
|
||||
|
||||
? AAAAB3NzaC1kc3MAAACBAL0sQ9fJ5bYTEyY==...
|
||||
:
|
||||
ssh_auth:
|
||||
- present
|
||||
ssh_auth.present:
|
||||
- user: root
|
||||
- enc: ssh-dss
|
||||
|
||||
thatch:
|
||||
ssh_auth:
|
||||
- present
|
||||
ssh_auth.present:
|
||||
- user: root
|
||||
- source: salt://ssh_keys/thatch.id_rsa.pub
|
||||
|
||||
sshkeys:
|
||||
ssh_auth:
|
||||
- present
|
||||
ssh_auth.present:
|
||||
- user: root
|
||||
- enc: ssh-rsa
|
||||
- options:
|
||||
|
@ -6,8 +6,7 @@ Interaction with the Supervisor daemon
|
||||
.. code-block:: yaml
|
||||
|
||||
wsgi_server:
|
||||
supervisord:
|
||||
- running
|
||||
supervisord.running:
|
||||
- require:
|
||||
- pkg: supervisor
|
||||
- watch:
|
||||
|
@ -187,21 +187,18 @@ def wait(name, url='http://localhost:8080/manager', timeout=180):
|
||||
.. code-block:: yaml
|
||||
|
||||
tomcat-service:
|
||||
service:
|
||||
- running
|
||||
service.running:
|
||||
- name: tomcat
|
||||
- enable: True
|
||||
|
||||
wait-for-tomcatmanager:
|
||||
tomcat:
|
||||
- wait
|
||||
tomcat.wait:
|
||||
- timeout: 300
|
||||
- require:
|
||||
- service: tomcat-service
|
||||
|
||||
jenkins:
|
||||
tomcat:
|
||||
- war_deployed
|
||||
tomcat.war_deployed:
|
||||
- name: /ran
|
||||
- war: salt://jenkins-1.2.4.war
|
||||
- require:
|
||||
|
@ -11,12 +11,10 @@ description.
|
||||
.. code-block:: yaml
|
||||
|
||||
ERIK-WORKSTATION:
|
||||
system:
|
||||
- computer_name
|
||||
system.computer_name: []
|
||||
|
||||
This is Erik's computer, don't touch!:
|
||||
system:
|
||||
- computer_desc
|
||||
system.computer_desc: []
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
|
Loading…
Reference in New Issue
Block a user