这里用 ubuntu 中安装 redis 作为示例
创建 top.sls
/srv/salt/top.sls
1 2 3 4
| base: 'server-01': - roles.redis
|
server-01 是需要安装redis的一台机器
创建redis states 树
/srv/salt/roles/redis/init.sls
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| redis-server: pkg: - installed #使用 pkg install 安装 redis-server 包 service: - name: redis-server - running #运行 - require: - pkg: redis-server - watch: - pkg: redis-server - file: /etc/redis/redis.conf
/etc/redis/redis.conf: file.managed: - source: salt://roles/redis/redis.conf - template: jinja - user: root - group: root - mode: 644
|
参考
http://docs.saltstack.cn/zh_CN/latest/topics/tutorials/starting_states.html