今天周五,为了迎接美好的周末。下午写了些sls。希望可以愉快的度过一个完美的周末 [root@master salt]# pwd /srv/salt [root@master salt]# tree nginx/ nginx/ ├── conf.sls ├── files │ ├── blog.conf │ ├── nginx.conf │ └── www.conf ├── init.sls └── install.sls 1 directory, 6 files [root@master salt]# more nginx/init.sls include: - nginx.install - nginx.conf [root@master salt]# more nginx/install.sls nginx: pkg.installed: - names: - gcc-c++ - pcre-devel - zlib-devel - openssl-devel - libxslt-devel - gd-devel user.present: - shell: /sbin/nologin - uid: 1001 - gid_from_name: True archive.extracted: - name: /tmp/ - source: http://nginx.org/download/nginx-1.12.2.tar.gz - skip_verify: True cmd.run: - cwd: /tmp/nginx-1.12.2/ - names: - ./configure --prefix=/usr/local/nginx112 --user=nginx --group=nginx --with-http_stub_status_module --with-pcre --with-http_realip_module --with-htt p_image_filter_module --with-http_ssl_module --with-http_gzip_static_module && make - make install - require: - archive: nginx [root@master salt]# more nginx/conf.sls master: file.managed: - name: /usr/local/nginx112/conf/nginx.conf - source: salt://nginx/files/nginx.conf - template: jinja www: file.managed: - name: /usr/local/nginx112/conf.d/www.conf - source: salt://nginx/files/www.conf - makedirs: True - require: - file: master blog: file.managed: - name: /usr/local/nginx112/conf.d/blog.conf - source: salt://nginx/files/blog.conf - makedirs: True - require: - file: master [root@master salt]# more nginx/files/nginx.conf user nginx nignx; worker_processes {{ grains[‘num_cpus‘] }}; {% if grains[‘num_cpus‘] == 2 %} worker_cpu_affinity 10 01; {% elif grains[‘num_cpus‘] == 4 %} worker_cpu_affinity 1000 0100 0010 0001; {% elif grains[‘num_cpus‘] >= 8 %} worker_cpu_affinity 10000000 01000000 00100000 00010000 00001000 00000100 00000010 00000001; {% else %} worker_processes 1; {% endif %} error_log logs/error.log; error_log logs/error.log notice; worker_rlimit_nofile 4096; #pid logs/nginx.pid; events { use epoll; worker_connections 4096; } http { include mime.types; default_type application/octet-stream; log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘ ‘$status $body_bytes_sent "$http_referer" ‘ ‘"$http_user_agent" "$http_x_forwarded_for"‘; sendfile on; tcp_nopush on; keepalive_timeout 65; include /usr/local/nginx1.10/conf.d/*.conf; server { listen 80; server_name ngx.status; location /status { stub_status on; access_log off; allow 192.168.199.0/24; deny all; } error_page 404 /404.html; location = /404.html { root html; } } } [root@master salt]# more nginx/files/www.conf server { listen 80; server_name www.bjdaos.com bjdaos.com; location / { root html; access_log logs/www.access.log main; index index.html index.htm; } } [root@master salt]# more nginx/files/blog.conf server { listen 80; server_name blog.bjdaos.com; location / { root html/word; index index.php index.html index.htm; } } 最后: salt ‘*‘ state.sls nginx
本文出自 “努力奔小康” 博客,请务必保留此出处http://302876016.blog.51cto.com/12889292/1976880
原文地址:http://302876016.blog.51cto.com/12889292/1976880