First, System initialization
1. Writing resolv.conf (DNS) files
[Email protected] init]# Cat/etc/salt/states/init/dns.sls
/etc/resolv.conf:
File.managed:
-Source:salt://init/files/resolv.conf
-User:root
-Group:root
-mode:644
2. Add time to Historical order (history)
[Email protected] init]# Cat/etc/salt/states/init/history.sls
/etc/profile:
File.append:
-Text:
-Export histtimeformat= "%F%T ' WhoAmI '"
3. Write command audit function
[email protected] init]# cat Audit.sls
/etc/bashrc
File.append:
-Text:
-Export prompt_command= ' {msg=$ (History 1 | {read x y; echo $y;}); Logger "[euid=$ (WhoAmI)]": $ (Who am I): [' pwd '] "$msg"; }‘
4. Changing kernel parameters
[email protected] init]# cat Sysctl.sls
Vm.swappiness:
Sysctl.present:
-value:0
Net.ipv4.ip_local_port_range:
Sysctl.present:
-value:10000 65000
Fs.file-max:
Sysctl.present:
-value:100000
5. Centralized management of the above 4 configuration files
[email protected] init]# cat Env_init.sls
Include
-Init.dns
-Init.history
-Init.audit
-Init.sysctl
6. Writing the Top.sls file
[Email protected] init]# CD.
[email protected] states]# cat Top.sls
Base
‘*‘:
-Init.env_init
7. Execute salt
[[email protected] states]# Salt ' * ' state.highstate test=true #模拟运行 (Build environment Run method)
8. See if the Minion side is performing successfully
[[email protected] init]# Salt ' * ' state.highstate
[[email protected] init]# Salt ' * ' cmd.run ' cat/etc/resolv.conf '
Node2.bier.com:
; Generated By/sbin/dhclient-script
Search Localdomain
NameServer 114.114.114.114
Node3.bier.com:
; Generated By/sbin/dhclient-script
Search Localdomain
NameServer 114.114.114.114
This article is from the "Bill Linux Operations Notes" blog, please be sure to keep this source http://chenshoubiao.blog.51cto.com/6159058/1884490
(vi) Saltstack Project actual Combat _ system initialization