Skip to content

Commit cf56673

Browse files
committed
Updated states to describe newer dict format for a state definition
1 parent 2c54508 commit cf56673

File tree

1 file changed

+35
-22
lines changed

1 file changed

+35
-22
lines changed

docs/topics/states.rst

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ However, doing the same with a Salt state requires no check state, since the ins
106106
107107
install_tree_now:
108108
pkg.installed:
109-
- pkgs:
110-
- tree
109+
pkgs:
110+
- tree
111111
112112
.. code-block:: bash
113113
@@ -156,6 +156,19 @@ A state definition in a state file will have the following components:
156156

157157
An example of a single state layout in YAML, using the names of the high data components:
158158

159+
.. code-block:: sls
160+
:caption: /srv/salt/example.sls
161+
162+
identifier:
163+
module.function:
164+
name: name_value
165+
function_arg: arg_value
166+
function_arg: arg_value
167+
function_arg: arg_value
168+
169+
The name and arguments for the state definition can also be specified in the traditional format
170+
as yaml list of individual single key value dictionaries but the newer dictionary format above is preferred.
171+
159172
.. code-block:: sls
160173
:caption: /srv/salt/example.sls
161174
@@ -486,8 +499,8 @@ The Disable USB Storage State in the ``base`` environment will look like:
486499
487500
disable_usb:
488501
file.managed:
489-
- name: /etc/modprobe.d/blacklist-usbstorage
490-
- contents: |
502+
name: /etc/modprobe.d/blacklist-usbstorage
503+
contents: |
491504
# Blacklist USB storage
492505
blacklist usb-storage
493506
@@ -500,22 +513,22 @@ The SSH State file will look like:
500513
501514
install_openssh:
502515
pkg.installed:
503-
- name: openssh
516+
name: openssh
504517
505518
push_ssh_conf:
506519
file.managed:
507-
- name: /etc/ssh/ssh_config
508-
- source: salt://ssh/ssh_config
520+
name: /etc/ssh/ssh_config
521+
source: salt://ssh/ssh_config
509522
510523
push_sshd_conf:
511524
file.managed:
512-
- name: /etc/ssh/sshd_config
513-
- source: salt://ssh/sshd_config
525+
name: /etc/ssh/sshd_config
526+
source: salt://ssh/sshd_config
514527
515528
start_sshd:
516529
service.running:
517-
- name: sshd
518-
- enable: True
530+
name: sshd
531+
enable: True
519532
520533
Create the Apache state
521534
_______________________
@@ -527,17 +540,17 @@ The Apache State file will look like:
527540
528541
implement_httpd:
529542
pkg.installed:
530-
- name: httpd
543+
name: httpd
531544
532545
http_conf:
533546
file.managed:
534-
- name: /etc/httpd/conf/httpd.conf
535-
- source: salt://apache/httpd.conf
547+
name: /etc/httpd/conf/httpd.conf
548+
source: salt://apache/httpd.conf
536549
537550
start_httpd:
538551
service.running:
539-
- name: httpd
540-
- enable: True
552+
name: httpd
553+
enable: True
541554
542555
Create a ``firewalld`` state
543556
____________________________
@@ -547,15 +560,15 @@ ____________________________
547560
548561
install_firewalld:
549562
pkg.installed:
550-
- name: firewalld
563+
name: firewalld
551564
552565
firewalld_open_web:
553566
firewalld.present:
554-
- name: public
555-
- masquerade: False
556-
- ports:
557-
- 80/tcp
558-
- 443/tcp
567+
name: public
568+
masquerade: False
569+
ports:
570+
- 80/tcp
571+
- 443/tcp
559572
560573
Production build-out
561574
____________________

0 commit comments

Comments
 (0)