diff --git a/README.rst b/README.rst index 34b87ec..2f61b7d 100644 --- a/README.rst +++ b/README.rst @@ -49,10 +49,10 @@ Installs nginx via the source files. ``nginx.users`` --------------- -Installs apache utils, and configures nginx users specified in the pillar. -This requires `basicauth `_ -from `salt-contrib `_ (either add it to your salt or ship -this single file in your `_modules` directory see `Dynamic Module Distribution +Installs apache utils, and configures nginx users specified in the pillar. +This requires `basicauth `_ +from `salt-contrib `_ (either add it to your salt or ship +this single file in your `_modules` directory see `Dynamic Module Distribution `_ Next-generation, alternate approach @@ -108,7 +108,7 @@ Manages nginx virtual hosts files and binds them to service calls. ---------------------- Installs and configures Phusion Passenger module for nginx. You need to enable -the upstream phusion passenger repository with `install_from_phusionpassenger: true`. +the upstream phusion passenger repository with `install_from_phusionpassenger: true`. Nginx will also be installed from that repository, as it needs to be modified to -allow the passenger module to work. +allow the passenger module to work. diff --git a/nginx/ng/config.sls b/nginx/ng/config.sls index 0bca27a..1944101 100644 --- a/nginx/ng/config.sls +++ b/nginx/ng/config.sls @@ -14,8 +14,8 @@ nginx_log_dir: {% if 'source_path' in nginx.server.config %} {% set source_path = nginx.server.config.source_path %} -{% else %} -{% set source_path = 'salt://nginx/ng/files/nginx.conf' %} +{% else %} +{% set source_path = 'salt://nginx/ng/files/nginx.conf' %} {% endif %} nginx_config: file.managed: diff --git a/nginx/ng/map.jinja b/nginx/ng/map.jinja index fc3c45d..e0665ec 100644 --- a/nginx/ng/map.jinja +++ b/nginx/ng/map.jinja @@ -80,6 +80,17 @@ 'server_enabled': '/etc/nginx/sites-enabled', 'server_use_symlink': True, }, + 'FreeBSD': { + 'package': 'nginx', + 'passenger_package': 'passenger', + 'service': 'nginx', + 'webuser': 'www', + 'conf_file': '/usr/local/etc/nginx/nginx.conf', + 'server_available': '/usr/local/etc/nginx/sites-available', + 'server_enabled': '/usr/local/etc/nginx/sites-enabled', + 'server_use_symlink': True, + 'pid_file': '/var/run/nginx.pid', + }, }, default='Debian' ), 'install_from_source': False, 'install_from_ppa': False, @@ -117,9 +128,9 @@ 'gzip': 'off', 'gzip_disable': '"msie6"', 'include': [ - '/etc/nginx/mime.types', - '/etc/nginx/conf.d/*.conf', - '/etc/nginx/sites-enabled/*', + 'mime.types', + 'conf.d/*.conf', + 'sites-enabled/*', ], }, }, diff --git a/nginx/ng/service.sls b/nginx/ng/service.sls index 2cc51c6..59fe80f 100644 --- a/nginx/ng/service.sls +++ b/nginx/ng/service.sls @@ -17,8 +17,8 @@ nginx_systemd_service_file: file.managed: - name: /lib/systemd/system/nginx.service - source: salt://nginx/ng/files/nginx.service -{% endif %} - +{% endif %} + nginx_service: service.{{ service_function }}: {{ sls_block(nginx.service.opts) }} diff --git a/nginx/openresty.sls b/nginx/openresty.sls index fc51a17..23764df 100644 --- a/nginx/openresty.sls +++ b/nginx/openresty.sls @@ -21,10 +21,10 @@ get-openresty: install_openresty: cmd.wait: - cwd: {{ home }}/ngx_openresty-{{ openresty_version }} - - names: + - names: - ./configure --with-luajit \ --with-http_drizzle_module \ - --with-http_postgres_module \ + --with-http_postgres_module \ --with-http_iconv_module - make && make install - watch: diff --git a/nginx/package.sls b/nginx/package.sls index 3a765e5..3229ae2 100644 --- a/nginx/package.sls +++ b/nginx/package.sls @@ -102,7 +102,7 @@ nginx: - require: - pkg: nginx - file: nginx-old-init - - module: nginx-old-init + - module: nginx-old-init {% endif %} service.running: - enable: True diff --git a/nginx/source.sls b/nginx/source.sls index 3d13f48..5af016b 100644 --- a/nginx/source.sls +++ b/nginx/source.sls @@ -216,7 +216,7 @@ nginx: {% if use_sysvinit %} - watch_in: {% set logger_types = ('access', 'error') %} - {% for log_type in logger_types %} + {% for log_type in logger_types %} - service: nginx-logger-{{ log_type }} {% endfor %} {% endif %} diff --git a/nginx/templates/upstart.jinja b/nginx/templates/upstart.jinja index a67fdd3..64bab02 100644 --- a/nginx/templates/upstart.jinja +++ b/nginx/templates/upstart.jinja @@ -1,23 +1,23 @@ # nginx - + description "nginx http daemon" author "George Shammas " - + start on (runlevel [345] and started network) stop on (runlevel [!345] or stopping network) - + env DAEMON=/usr/sbin/nginx - + expect fork respawn respawn limit 10 5 #oom never - + pre-start script $DAEMON -t if [ $? -ne 0 ] then exit $? fi end script - + exec $DAEMON diff --git a/pillar.example b/pillar.example index 7786849..1716034 100644 --- a/pillar.example +++ b/pillar.example @@ -40,7 +40,7 @@ nginx: # Source install source_version: '1.10.0' source_hash: '' - + # These are usually set by grains in map.jinja # Typically you can comment these out. lookup: @@ -56,7 +56,7 @@ nginx: # Currently it can be used on rhel/centos/suse when installing from repo gpg_check: True pid_file: /var/run/nginx.pid ### Prevent Rendering SLS error (map.jinja:149) if nginx.server.config.pid undefined (Ubuntu, etc) ### - + # Source compilation is not currently a part of nginx.ng from_source: False @@ -76,9 +76,9 @@ nginx: # nginx.conf (main server) declarations # dictionaries map to blocks {} and lists cause the same declaration to repeat with different values - config: + config: source_path: salt://path_to_nginx_conf_file/nginx.conf # IMPORTANT: This option is mutually exclusive with the rest of the - # options; if it is found other options (worker_processes: 4 and so + # options; if it is found other options (worker_processes: 4 and so # on) are not processed and just upload the file from source worker_processes: 4 pid: /var/run/nginx.pid ### Directory location must exist @@ -108,22 +108,22 @@ nginx: # Remove the site config file. Nice to clean up the conf.d (or sites-available). # It also remove the symlink (if it is exists). # The site MUST be disabled before delete it (if not the nginx is not reloaded). - deleted: True - ########### + deleted: True + ########### ## Modify 'available_dir' AND 'enabled_dir' '/etc/nginx' location to alternative value. ########### available_dir: /etc/nginx/sites-available # an alternate directory (not sites-available) where this server may be found enabled_dir: /etc/nginx/sites-enabled # an alternate directory (not sites-enabled) where this server may be found disabled_name: mysite.aint_on # an alternative disabled name to be use when not symlinking overwrite: True # overwrite an existing server file or not - + # May be a list of config options or None, if None, no server file will be managed/templated # Take server directives as lists of dictionaries. If the dictionary value is another list of # dictionaries a block {} will be started with the dictionary key name config: - server: - server_name: localhost - - listen: + - listen: - 80 - default_server - index: @@ -134,7 +134,7 @@ nginx: - $uri - $uri/ =404 - test: something else - + # The above outputs: # server { # server_name localhost; @@ -144,7 +144,7 @@ nginx: # try_files $uri $uri/ =404; # test something else; # } - # } + # } mysite2: # Using source_path options to upload the file instead of templating all the file enabled: True available_dir: /etc/nginx/sites-available