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