The combination of Saltstack and Python programs

Source: Internet
Author: User
Tags saltstack

Modules in the Saltstack library:

in Saltstack, each subsystem plug-in (plug-in) is a Python Module. Therefore, the Module in the Saltstack library can be seen as a set of functions (for example: aka command); it can be seen as an application (e.g. MySQL, Docker); can be seen as a system component (e.g. disk, file) ; it can also be seen as an external system (GITFS). There are a few things to keep in mind when using Modules in the Saltstack Library: (1). All modules are in the Salt directory, each subsystem is differentiated by a different subdirectory, and each specific modile will be presented in a separate. py file, (2). Each module isSalt . Subsystem.module The format named, where SubsystemRepresents a subsystem, ModuleRepresents the Subsystem module name. Note:Because the Execute (execution) module is the first module in the Salt, itSalt.module(3). Each module contains the functions we need. Functions in the Saltstack library:in Saltstack, Functions is the equivalent of a verb.   Functions parameter (Arguments) in the Saltstack library: 1. Specify the Functions parameter in the command line modeIn general, the required shape arguments in Functions are first specified and arranged in a particular order. Rather than the required formal parameter all with default values。 When calling Function in a Salt named row mode, if the parameter does not have aArgument=valueis specified in the form of a value only, we need to separate the parameters with a space and specify them in a specific order. If theArgument=valueThe form is irrelevant. For example: Define the following function>>>Salt.modules.useradd.add (name, Uid=none, Gid=none, Groups=none, Home=none,Shell=none, Unique=true, System=false, fullname= ", oomnumber=",workphone= ", homephone=", Createhome=true, Loginclass=none)The following is called in command-line mode. >>>Salt ' * ' User.add Fred Shell=/bin/zsh Note:When you use the deformable parameter ( Variable nameless parameter *args and variable keyword parameters **kw), the variable-name parameter is directly filled in as a value, and the variable-keyword argument isArgument=valuespecified in the form. For example: 1 variable nameless parameters and 3 variable key glyph parameters are specified. >>>Salt ' * ' network.connect google-public-dns-a.google.com port=53 proto=udp timeout=3 2. Formal parameter designation for State systemThe formal parameters of the state system are stored in the state file, based on YAML's syntax. For example, salt.states.user.present is defined as follows. >>>salt.states.user.present (name, Uid=none, Gid=none, Gid_from_name=false,Groups=none, Optional_groups=none, Remove_groups=true, Home=none,createhome=true, Password=none, Hash_password=false, Enforce_password=true,Empty_password=false, Shell=none, Unique=true, System=false, Fullname=none,Roomnumber=none, Workphone=none, Homephone=none, Loginclass=none, Date=none,Mindays=none, Maxdays=none, Inactdays=none, Warndays=none, Expire=none,Win_homedrive=none, Win_profile=none, Win_logonscript=none,Win_description=none)In the state file, the YAML syntax is specified similar to the following.A state example that calls User.present:user.present:-name:fred-Shell:/bin/zsh Reference Connection:Https://docs.saltstack.com/en/getstarted/system/python.html

Saltstack in conjunction with Python programs

Related Article

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.