一、用户和用户组模块
说明:该sls文件用来在Minion端创建nginx用户和nginx用户组,当创建nginx用户时,对nginx用户组是否已存在做判断!
(1) /srv/salt/create_user/nginx_user.sls
nginx_user: user.present: - name: nginx - uid: 121 - gid: 121 - createhome: true - shell: /bin/bash - require: - group: nginx group.present: - name: nginx - gid: 121
(2) /srv/tops
说明:将nginx_user.sls所在的目录在top.sls文件进行引用
/srv/top.sls
base: '*': - cpitables.* - install_zabbix.* - install_mysql.* - create_user.*
(3) 调用sls文件创建用户和用户
salt '*' state.sls create_user.nginx_user
二、服务模块
nginx_service: //声明id service.running: //服务运行模块 - name: nginx - enable: True - reload: True - watch: //监测以下条件是否变化,如果改变则重启服务 - file: /usr/local/nginx/conf/nginx.conf