The deep-highstate concept of Saltstack

Source: Internet
Author: User
Tags saltstack

The deep-highstate concept of Saltstack

First, knowledge 1, highstate  data structure definition 1) SALT state tree (the salt state tree) state tree (State tree)   refers to the File_ Roots is defined in the directory under which SLS files are saved, which are used for modules (module) calls. 2) Entry file (Top file) an ingress status (state) file   can be indicated during the execution of the states  minions  Under what environment (ENV) and modules (module) use 3) contains a declaration (include declaration) to define a list, including the module name to be referenced. Entry into force: The top floor of highstate (Top level) Example:include:  - edit.vim  -  HTTP.SERVER4) module Reference (module reference) SLS module name. For example, the module name "Edit.vim" represents  salt://edit/vim.sls  this SLS file, located on Salt master on File_roots defined path (default is/srv/salt/)/srv /SALT/EDIT/VIM.SLS5) ID Declaration (id declaration) defines a separate  highstate  component (component), including state  The Key-value in declaration  and  requisite declaration can be name declaration  or  Names  Declaration covered. Entry into force: Located at the top level or below the extend declaration requirements: The entire state tree is unique, if there are multiple identical IDs, then the first one is matched to take effect. 6) Extension Declaration (extend declaration) expands the  name declaration in the SLS module to include, The key in this extension is consistent with the id declaration in the SLS module that you want to include. Effective: Located at the top level, defines a wordNote: You can only be extended once when a single state is running. 7) Status declaration (state declaration) a list that includes a string representing the function declaration (function declaration), and a parameter declaration for multiple functions (Function arg  declaration) dictionary (dict) can include a number of add-ons (component), such as the name overlay component (name and names), the necessary condition declaration (requisite  Declarations) entry into force: Located below the id declaration layer 8) The requirements declaration (Requisite declaration) includes a set of necessary conditions for establishing a behavior-dependent tree (the  Action dependency tree). The state of Salt is synchronously executed when there is a definite order, which determines the order, depends on and observes ( requiring and watching ) other states (salt  States) in effect: Located below the id declaration layer, as a list of components or a Keyoccurs as a list component under  a State declaration or as a key under an ID  DECLARATION.9) Prerequisites Reference (requisite reference) a separate dictionary, key and state declaration consistent, value and id  DECLARATION in force: the function name (function declaration) to invoke is declared in the requisite declaration layer below 10). Entry into force: note: A status statement (State declaration) can only include a function declaration example: the function "Installed" is called in the state module (state module) pkg:httpd:   pkg.installed: [] &nThe function and state are briefly stated on one line (inline). In fact, the data structure is compiled like this: The httpd:  pkg:    - installed function is a state declaration (state  A string in the declaration). Technically, when the function is in dots notation "." When declared, the compiler translates into a string in the status Declaration list (state declaration list). The following is a false declaration: Httpd:  pkg.installed  service.running when there are no arguments to the function,  and there are other state declarations to follow, use the standard format. Otherwise, it will not be a valid data structure. This is the right: httpd:  pkg.installed: []  service.running: [] Effective: Located in state  DECLARATION below layer 11) function parameter declaration (function arg declaration) A dictionary passed to the function takes effect: located in function  Declaration The following layer example: in the following state declaration, user, group, and mode  passed as a parameter to the function "managed":/etc/http/conf/ http.conf:  file.managed:    - user: root    -  group: root    - mode: 64412) NAME Declaration (name  DECLARATION) overrides the name parameter in a state declaration, and if name is not specified, "Id declaration" is an example of the name parameter: overriding name is a lot of use, such as avoiding ID declaration conflicts, such as in the following example, 2 status statements You cannot declare/ETC/MOTD as an ID at the same time: motd_perms:  file.managed:&Nbsp;   - name: /etc/motd    - mode: 644motd_quote:   file.append:    - name: /etc/motd    - text :  "Of all smells, bread; of all tastes, salt." Another common reason is that if the ID declaration is long, it needs to be referenced in multiple places. For example, the following example, use mywebsite  to replace  /etc/apache2/sites-available/mywebsite.com can be:mywebsite:   file.managed:    - name: /etc/apache2/sites-available/mywebsite.com     - source: salt://mywebsite.coma2ensite mywebsite.com:  cmd.wait:     - unless: test -L /etc/apache2/sites-enabled/mywebsite.com     - watch:      - file: mywebsiteapache2:   service.running:    - watch:      - file:  MYWEBSITE13) NAMES Declaration (Names declaration) expands the content of the status statement into multiple state declarations, each with its own name example: there is such a declaration:python-pkgs:  pkg.installed:     - names:      - python-django       - python-crypto      - python-yaml conversion into lowstate data  The structure  becomes: Python-django:  pkg.installedpython-crypto:  pkg.installedpython-yaml:   pkg.installed   with an additional dictionary, you can overwrite some values when you expand, for example: New in version 2014.7.0.ius:   pkgrepo.managed:    - humanname: ius community packages  for Enterprise Linux 6 -  $basearch     - gpgcheck:  1    - baseurl: http://mirror.rackspace.com/ius/stable/centos/6/$basearch     - gpgkey: http://dl.iuscommunity.org/pub/ius/IUS-COMMUNITY-GPG-KEY     - names:        - ius        -  ius-devel:            - baseurl: http:// mirror.rackspace.com/ius/development/centos/6/$basearch 2, Large example This is a yaml layout:<include  Declaration>:  - <module reference>  - <module reference ><Extend Declaration>:  <ID Declaration>:    [< overrides>]#  Standard Statement (standard declaration) <ID Declaration>:  <State  Module>:    - <function>    - <function arg >    - <Function Arg>    - <Function  arg>    - <name>: <name>    - < requisite declaration>:       - <requisite reference>      -  <Requisite Reference>#  function Inline (inline function and names) <ID  declaration>:  <state module>.<function>:    - < function arg>    - <function arg>    -  <function arg>    - <names>:      -  <name>      - <name>      -  <name>    - <Requisite Declaration>:       - <requisite reference>      - <requisite  Reference># multiple states for single id<ID Declaration>:   <state module>:    - <function>    - <function arg>     - <Name>: <name>    - <Requisite  declaration>:      - <requisite reference>  < state module>:    - <function>    - < function arg>    - <names>:      -  <name>      - <name>    - < Requisite declaration>:      - <requisite reference>zyxw , reference 1, dochttp://docs.saltstack.com/en/latest/ref/states/highstate.html


The deep-highstate concept of Saltstack

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.