配置仓库根目录:
file_roots:
base:
- /srv/salt
创建入口文件:
cat > /srv/salt/top.sls << EOF
base:
'*': #匹配所有受控主机
- nginx
EOF
创建nginx sls:
mkdir -p /srv/salt/nginx
cat > /srv/salt/nginx/init.sls << EOF
nginx:
pkg:
- name: nginx
- installed
service:
- running
- enable: True
- reload: True
- require:
- pkg: nginx
- pkg: httpd
- watch:
- pkg: nginx
- file: /etc/nginx/nginx.conf
- file: /etc/nginx/conf.d/
httpd:
pkg:
- name: httpd
- removed
/etc/nginx/nginx.conf:
file.managed:
- source: salt://nginx/nginx.conf
- user: root
- group: root
- mode: 644
/etc/nginx/conf.d/:
file.recurse:
- source: salt://nginx/conf.d/
- user: root
- group: root
- dir_mode: 755
- file_mode: 644
/home/wwwlogs/:
file.directory:
- makedirs: True
- user: nginx
- group: nginx
- mode: 0755
- recurse:
- user
- group
- mode
EOF
执行:
salt '*' state.highstate
或
salt '*' state.sls nginx
标签:none