'] = ip_bracket (self. config ['interface']) migrations. migrate_paths (self. config) # Late import so logging works correctly import salt. master self. master = salt. master. master (self. config) self. daemonize_if_required () self. set_pidfile () def start (Self): ''' start the actual master. if sub-classed, don't ** ever ** forget to run: Super (yoursubclass, self ). start () Note: run any required code before calling 'super ()'. '''self. prepare () # Call your own prepare method here if che
Salt Introduction:Salt (saltstack) is an infrastructure automation and configuration management tool, according to the official documentation, salt is a configuration management system capable of maintaining a remote node to a specified state (for example, to ensure that the specified package is installed and that the specified service is running). And can be distributed on the remote node to execute command and query data.InstallationThis document is
creates as many minions as is defined in the Master option and binds EAC H Minion object to a respective master. " " #Timeout for one of the minions to Auth with a masterMinion_connect_timeout = 5def __init__(Self, opts): Super (Multiminion, self).__init__(opts)defMinions (self):" "Return a dict of minion generators bound to the Tune_in method Dict of Master, Minion_mapping, the Mapping contains:opts:options used to create the Minion Last:last Auth attempt time a Uth_wait:time to wait for
Install installation Epel as a Yum source for installing ansible (CentOS6.4)RPM-UVH http://ftp.linux.ncsu.edu/pub/epel/6/i386/epel-release-6-8.noarch.rpmInstall Saltstack:Main control side:Yum Install salt-mastster-ychkconfig Salt-master onservice Salt-master startControlled End:Yum Install salt-minion-ychkconfig Salt-minion Onservice Salt-minion startFirewall:The main control side adds TCP 4505, 4506 port rules, the controlled side does not need to be configured, the principle is the control si
uses _ return to first perform fire_event on the local event interface, the results are stored locally on the master.
8. because fire_event is carried out in 7, the get_cli_event_returns in 4 can be captured. Because the iterator is used, each received result can be immediately displayed, once the result of the captured minions is greater than or equal to the number of previously obtained minions, it means that all minions have returned results and quit.
Summary
Salt uses the flexible and eff
Saltstack Quick Start # Personal sortingGetting started using pip
Because Salt has already entered PyPI, pip can be used for installation, although most users prefer RPMs (which can be installed from EPEL ). Installing from pip is simple:
pip install saltWarning if you install from pip (or use
Setup. pyinstallFrom the source code), pay attention
Yum-utilsIt is depended on by Salt and used to manage software packages. Similarly, if Python dependencies
This article analyzes the running process of saltstack from the perspective of sal command line execution. The code analysis process is parsed by running logs.
Command Execution Process
Enter salt '*' cmd. run ls command on the terminal
#salt "*" cmd.run lscloudstack-agent_4.2.0_all.debcloudstack-common_4.2.0_all.debzmq
Let's take a look at the output log of the salt master.
14:28:36, 087 [master. py] [_ handle_clear] [640] [master] [-1221166
compression.Because gzip-cpu-intensive, this should only being used in scenarios whereThe compression ratio is very high (e.g. pretty-printed JSON or YAMLfiles).Use the *gzip* named argument to enable it. Valid values is 1..9, where 1Is the lightest compression and 9 the heaviest. 1 uses the least CPU onThe Master (and Minion), 9 uses the most.States1: View all States List: Salt ' jcfx-4 ' sys.list_state_modulesJcfx-4:-ACL-Alias-Alternatives-Apache-Archive-Artifactory-At-Beacon-Blockdev-Buildou
1. State moduleDescription format: Yaml format, file with. SLS EndUnderstanding yamlhttps://www.unixhot.com/docs/saltstack/topics/yaml/index.htmlYaml KickFirst: Indent. Note that it must be two spaces. Indentation represents a hierarchical relationship.Second: Colon. Combine with spaces to indicate indentation.The second use of a colon is to represent a key-value pairThird: The dash indicates the list. There are spaces behind the dash.[email protected
' State.sls nginx test=true The output information is omitted here summary------------succeeded:8failed: 0------------Total: When pushing the minion above, the general Salt ' sa10-003 ' state.sls this command; Of course, you can also perform salt sa10-003 state.highstate This command will match all of the STATE.SLS modules by default. where test=true refers to a test installation, that is, no actual operation, just to see the test results.
List of logical relationships for state:In
Saltstack Source Installation Zabbix_agent ClientInstallation and environment brief, directly on the topic:First, the tree-like chart.[Email protected] salt]# pwd/srv/salt[Email protected] salt]# tree. ├──init│└──init.sls├──top.sls└──zabbix├──conf.sls├──files│├──zabbix_agentd│├──zabbix_age NTD.CONF│└──ZABBIX.TAR.GZ├──INIT.SLS└──INSTALL.SLS3 directories, 8 filesSecond, initialize the system firstHere is just to tell the client to install vim-enhanced,
GrainsGrains is a collection of information that is collected at Minion startup, such as the operating system type, network card IP, and so on. Using CommandsSalt ' client.aming.com ' grains.ls lists all grains project namesSalt ' client.aming.com ' grains.items lists all grains items and valuesgrains information is not dynamic and is not always changed, it is only collected at minion startup. grains can do configuration management. Custom Grainsvim/etc/salt/minionAdd or change:Grains:role:-Ngin
1. Storage locationGrains:minion EndPillar:master End2. Data typeGrains: Static dataPillar: Dynamic Data3. Data collection and Update methodGrains:minion is collected at startup, or it can be refreshed with salt ' * ' saltutil.sync_grainsPillar: Defined on the master side, assigned to the corresponding minion. You can refresh with salt ' * ' saltutil.refresh_pillar4. ApplicationGrains: Storage Minion basic protective gear, such as for matching minion, its own receipts can be used to do asset man
machineState moduleSLS methodApache indicates which state file needs to be executed############################################################################################################### ########################################################################################################################################################################### ####################################################################################################################################
Scenario: The company has 10 servers need to install lamp test environment, using Saltstack to write state files for batch deployment, can improve work efficiency, reduce the possibility of human error, to ensure the consistency of the environment.Saltstack's configuration Management lamp actual case:1. Modify the master configuration file to specify the dev environment.4 ^file/etc/salt/master file_roots: base: -/srv/salt/base Dev: -/srv/salt
, then please use pillar, if it is very fixed, not changeable, please use grains . Grain and Pillar differences1.grains stores static, infrequently changing content, pillar the opposite2.grains is stored locally on Minion, while Pillar is stored in master local3.minion has permissions to manipulate its own grains values, such as additions, deletions, but Minion can only view its own pillar, not authorized to modifyRelated commands:Salt ' * ' Grains.ls # lists all keys for grainsSalt '*' grains.i
PillarPillar and grains are not the same, they are defined on the server and are some information that is defined for minion. Like some of the more important data (passwords) can exist in pillar, you can also define variables and so on.View the pillar value for the specified minion (the version I tested is empty):Salt ' client.wyp.com ' pillar.itemsConfigure custom pillar on serverVim/etc/salt/msterLocate the following configuration:Pillar_roots:Base: #空两个空格-/srv/pillar #继续空两个空格, YAML format. Fi
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.