Comments (12)
Hi there!
Guys, could you please provide any updates regarding the variables using in nginx.conf and templates of http blocks? Will it be possible to use j2 templates for generating virtual hosts in the next releases?
Thanks in advance!
from ansible-role-nginx.
Quick update - more advanced main/http templating options are almost done and ready to be released. The way templates work has been slightly reworked and should hopefully provide further flexibility on how to approach templating.
from ansible-role-nginx.
@Uhanga88 support for virtual hosts is still on the roadmap but I cannot provide an ETA. Re nginx.conf
templating are there any extra specific variables that you'd like to see included in the nginx.conf.j2
template?
from ansible-role-nginx.
For the time until all this variables are implemented it would be really helpful to have role variables specifying my own template to use instead of the one provided by the role iteself. Currently (as far as i understand) it is only possible to push my own configuration files via copy - there are no modifications possible anymore at this point and i have to somehow create them locally as needed as the copy operation in use does not allow setting remote source (an file i templated before) as copy source.
Or do i miss something?
Thanks in advance
from ansible-role-nginx.
There are some tentative plans to refactor this role into smaller roles with more concise functionalities. One of the smaller roles would be dedicated to templating vs installing NGINX, and should make both roles run faster if you only need the functionality of one of them.
from ansible-role-nginx.
Hi @robgarner!
The variables are already implemented (although admittedly the implementation is very basic at this stage). The idea is to use main_template_*
to manage the nginx.conf
file, http_template_*
to manage http
blocks, and stream_template_*
to manage stream
blocks.
For example, you can use main_template_enable
by setting its value to true
. You can then set other values such as main_template_user
or main_template_error_level
to tweak nginx.conf
values (you can find these values and their defaults at defaults/main.yml
).
As far as further development of NGINX templating goes - the plan is to gradually add support for all the major NGINX directives - starting with the main nginx.conf
templating, then moving to http
blocks, and finally moving to stream
blocks.
from ansible-role-nginx.
I agree with @sseide – being able to set a custom template filename would be really useful to be able to just have a
- role: nginx
tags: nginx
vars:
nginx_main_template_file: "templates/my.custom.nginx.conf.j2"
dependency stanza and have everything approximately work :)
from ansible-role-nginx.
@alessfg geerlingguy has some pretty great templating in his role. Since ansible 2.6 you can actually separate out your defaults/ vars files if you want to look into that.
from ansible-role-nginx.
I have implemented faux vhost support by doing this
- name: install and configure the reverse proxied HTTPS servers
include_role:
name: nginxinc.nginx
vars:
nginx_http_template_enable: true
nginx_http_template:
'{{ vhost.name }}':
port: 443
server_name: "{{ vhost.fqdn }}"
autoindex: false
template_file: http/default.conf.j2
conf_file_name: '{{ vhost.name }}.conf'
conf_file_location: /etc/nginx/conf.d/
ssl:
cert: "/etc/letsencrypt/live/{{ vhost.fqdn }}/fullchain.pem"
key: "/etc/letsencrypt/live/{{ vhost.fqdn }}/privkey.pem"
web_server:
locations: []
http_demo_conf: false
reverse_proxy:
locations:
backend:
location: /
proxy_pass: 'http://{{ vhost.name }}'
websocket: true
health_check_plus: false
upstreams:
'{{ vhost.name }}':
name: '{{ vhost.name }}'
lb_method: least_conn
zone_name: '{{ vhost.name }}'
zone_size: 64k
sticky_cookie: false
servers:
'{{ vhost.name }}':
address: '{{ vhost.local_ip }}'
port: '{{ vhost.local_port }}'
weight: 1
health_check: max_fails=1 fail_timeout=10s
nginx_html_demo_template_enable: false
loop: '{{ proxied_vhosts }}'
loop_control:
loop_var: 'vhost'
from ansible-role-nginx.
The bad thing with this solution is that the installation phase of the role must be run for every vhost. Would it be possible to provide an option to not do the installation part of the role until the vhost support is implemented that would save me a lot of time :)
Just realised this is already possible by
nginx_enable: false
from ansible-role-nginx.
it's still takes quite a long time to just skip all the steps though.
from ansible-role-nginx.
There's now way better templating support, including variables to add any number of additional custom options and include other configuration files in your system to your NGINX configuration. Doing some prep work before the next release, at which point all these new templating options should also be available on Ansible Galaxy.
from ansible-role-nginx.
Related Issues (20)
- Can't deploy Nginx role on a RHEL machine behind a proxy HOT 4
- Bug nginx_install_from: source (update zlib_version) HOT 1
- Is it possible to install nginx with streams without installing from source? HOT 1
- Unable to install NGINX on SLES (packagekit locks system management) HOT 3
- Mainline to stable apt repository switch is not managed correctly HOT 4
- Allow users to add a dynamic module during a build from source HOT 5
- its not possible to define `nginx_version` with `nginx_install_from: source` to pin the version HOT 2
- idempotency of `nginx_install_from: source`: current validations lack server reboot and ignore installed version HOT 1
- Error when installing the role from Ansible Galaxy: Unable to compare role versions HOT 4
- NGINX Amplify installation changes `agent.conf` even if it's already in the desired state
- Bug with lograte formating HOT 1
- SELinux set to permissive during role run HOT 1
- Incorrect role name in sample playbooks HOT 1
- Validation support for Ubuntu 24.04 (Noble) HOT 2
- Nginx will not install on FreeBSD
- Updated NGINX Signing Keys cause "Add NGINX signing key" task to fail HOT 3
- The specified fingerprint, '573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62', does not match the key fingerprint '8540A6F18833A80E9C1653A42FD21310B49F6B46 HOT 5
- nginxinc.nginx on Ansible Galaxy is out-of-date HOT 2
- GPG invalid signatures HOT 3
- Instalation error fingerprint. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansible-role-nginx.