一、使用者和使用者組模組
說明:該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