修改配置文件:(base用来放初始化环境、prod用来放生产配置环境)
[[email protected] ~]# vim /etc/salt/master
[[email protected] ~]# mkdir -p /srv/salt/{base,prod}
[[email protected] ~]# mkdir -p /srv/pillar/{base,prod}
[[email protected] ~]# /etc/init.d/salt-master restart
Stopping salt-master daemon: [ OK ]
Starting salt-master daemon: [ OK ]
初始化:(批量配置dns文件和历史记录加上执行时间)
编写states文件:
[[email protected] base]# pwd
/srv/salt/base
[[email protected] base]# cat top.sls
base:
‘*‘:
- init.env_init
[[email protected] base]# cat init/env_init.sls
include:
- init.dns
- init.history
[[email protected] base]# cat init/dns.sls
/etc/resolve.conf:
file.managed:
- source: salt://init/files/resolv.conf
- user: root
- group: root
- mode: 644
[[email protected] base]# cat init/history.sls
/etc/profile:
file.append:
- text:
- export HISTTIMEFORMAT="%F %T `whoami` "
测试执行:
[[email protected] ~]# salt ‘*‘ state.highstate test=True
正式执行:
[[email protected] ~]# salt ‘*‘ state.highstate