1 . 編寫resolv.conf(dns) 文件node
[root@node1 ~]# cat /srv/salt/system/dns/dns.sls bash
/etc/resolv.conf: app
file.managed: ide
- source: salt://system/dns/resolv.conf ui
- user: rootspa
- group: root orm
- mode: 644 server
2 . 給歷史命令(history)添加時間dns
[root@node1 ~]# cat /srv/salt/system/history/history.sls ip
/etc/profile:
file.append:
- text:
- export HISTTIMEFORMAT="%F %T `whoami`"
3 . 編寫命令審計功能
[root@node1 ~]# 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 .更改內核參數
[root@node1 ~]# 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.集中管理上面4個配置文件
[root@node1 ~]# cat /srv/salt/system/init.sls
include:
- system.dns
- system.history
- system.audit
- system.sysctl
6.執行salt
[root@node1 ~]# salt '*' state.sls system.dns system.history system.audit system.sysctl
7.查看minion端是否執行成功
[root@node1 init]# salt '*' cmd.run 'cat /etc/resolv.conf'
salt-minion:
nameserver 8.8.8.8