设置DNS执行文件
[root@linux-node1 base]# cd /srv/salt/base/
[root@linux-node1 base]# mkdir -pv init/files
# dns设置
[root@linux-node1 base]# cat /srv/salt/base/init/dns.sls
/etc/resolv.conf:
file.managed:
- source: salt://init/files/resolv.conf
- user: root
- group: root
- mode: 644
[root@linux-node1 base]# cp /etc/resolv.conf /srv/salt/base/init/files/
记录历史命令
格式:时间 用户 命令
[root@linux-node1 base]# cat /srv/salt/base/init/history.sls
/etc/profile:
file.append:
- text:
- export HISTTIMEFORMAT="%F %T `whoami`"
[root@linux-node1 base]# tree /srv/salt/base/
/srv/salt/base/
├── init
│ ├── dns.sls
│ ├── files
│ │ └── resolv.conf
│ └── history.sls
└── top.sls
记录操作日志
写到/var/log/message
[root@linux-node1 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";}'
内核调优
使用salt自带的模块sysctl
[root@linux-node1 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
#如何找呢?从/proc/sys/里面,然后后面的/用.来代替
将初始化的sls放在一起
[root@linux-node1 init]# cat env_init.sls
include:
- init.dns
- init.history
- init.audit
- init.sysctl
修改top.sls文件
base环境下init目录下的env_init.sls
[root@linux-node1 init]# cat /srv/salt/base/top.sls
base:
'*':
- init.env_init
重新打开minion的tty窗口,分别执行history和去message下面查看,检测