saltstack-系统初始化
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了saltstack-系统初始化相关的知识,希望对你有一定的参考价值。
1 . 编写resolv.conf(dns) 文件
[[email protected] ~]# cat /srv/salt/system/dns/dns.sls
/etc/resolv.conf:
file.managed:
- source: salt://system/dns/resolv.conf
- user: root
- group: root
- mode: 644
2 . 给历史命令(history)添加时间
[[email protected] ~]# cat /srv/salt/system/history/history.sls
/etc/profile:
file.append:
- text:
- export HISTTIMEFORMAT="%F %T `whoami`"
3 . 编写命令审计功能
[[email protected] ~]# 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 .更改内核参数
[[email protected] ~]# 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个配置文件
[[email protected] ~]# cat /srv/salt/system/init.sls
include:
- system.dns
- system.history
- system.audit
- system.sysctl
6.执行salt
[[email protected] ~]# salt ‘*‘ state.sls system.dns system.history system.audit system.sysctl
7.查看minion端是否执行成功
[[email protected] init]# salt ‘*‘ cmd.run ‘cat /etc/resolv.conf‘
salt-minion:
nameserver 8.8.8.8
本文出自 “Linux” 博客,请务必保留此出处http://syklinux.blog.51cto.com/9631548/1891873
以上是关于saltstack-系统初始化的主要内容,如果未能解决你的问题,请参考以下文章