Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nginx_http_extra_params variable in default vars #149

Merged
merged 9 commits into from
Jan 6, 2017

Conversation

sysarcher
Copy link
Contributor

Hello Everyone, I would like to propose an additional variable in the defaults/main.yml file called nginx_http_extra_params.

Purpose

If someone wants to retain the defaults in jdauphant.nginx/defaults/main.yml and bring in additional variables to http_params, he should be able to use the nginx_http_extra_params variable. This would append to http_params retaining the defaults.

This would also help us in maintaining a common set of group_vars for nginx config and have additional params when needed for our deploys.

Example

# retain defaults and add additional `client_max_body_size` param
- role: jdauphant.nginx
      nginx_http_extra_params:
       - client_max_body_size 200M

@jdauphant
Copy link
Owner

Hello @shrmrf,
Thanks for the proposition.
What do you think by somethings like that:

  • We create nginx_http_params_defaults in vars/main.yml and we put all the default we already have
  • In defaults/main.yml we change to nginx_http_params: {{ nginx_http_params_defaults }}

By doing that people can use the power of ansible to combine or not parameters by doing something like that: nginx_http_params: {{ nginx_http_params_defaults + my_extra_params }}

@sysarcher
Copy link
Contributor Author

Yeah, makes sense. This is what I proposed too but instead of concatenating the two lists to create the parameters, I just added another one. Both are good IMO. (though nginx_http_extra_params is a better name than my_extra_params hehe)

I can add it to the pull request if you like but I was scared that you will break code of people already abusing the nginx_http_params somehow.

It makes more sense to have the operation nginx_http_params: {{ nginx_http_params_defaults + my_extra_params }} done in /vars instead of /defaults if we take the addition approach.

Let me know what you think and I can update my pull request.

@jdauphant
Copy link
Owner

There is little misunderstand I think.
When I was talking about nginx_http_params: {{ nginx_http_params_defaults + my_extra_params }}, it's a possible usage by the user and "my_extra_params" will be an user variable not a variable from this role.

By implementing just:

  • nginx_http_params_defaults in vars/main.yml and we put all the defaults params we already have
  • In defaults/main.yml we change nginx_http_params to nginx_http_params: {{ nginx_http_params_defaults }}

We normally have retrocompatibility, we limit the complexity of the project and we have possibility to manage extra params in the playbook easely (for people that need advance usage).

@sysarcher
Copy link
Contributor Author

hmmm.... Okay. I think this is better. So a usage will look like:

vars:
  - my_extra_params:
      - client_max_body_size 200M
# retain defaults and add additional `client_max_body_size` param
- role: jdauphant.nginx
      nginx_http_params: {{ nginx_http_params_defaults + my_extra_params }}

This is a good solution too. Agreed. Should I update my pull request?

@jdauphant
Copy link
Owner

yes, it's exactly that !
If you can update the PR, it will be perfect :)

Thanks for your help

Taimoor added 2 commits January 5, 2017 16:03
assign default param var to  nginx params
update readme with example
@sysarcher
Copy link
Contributor Author

Hello @jdauphant updated the pull request to the best of my understanding.

Copy link
Owner

@jdauphant jdauphant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the change, I made a few comments

@@ -138,6 +138,19 @@ for details.
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for
```

4) Install nginx and add extra variables to default config
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have two number "4)"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated wth the requests!

roles:
- role: jdauphant.nginx
nginx_http_params: "{{ nginx_http_params_defaults + my_extra_params }}"
```
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kudos for the documentation !

@@ -48,6 +48,8 @@ nginx_http_params:
- server_tokens off
- types_hash_max_size 2048

nginx_http_params: { nginx_http_default_params }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this syntax is good, it break on CI : https://travis-ci.org/jdauphant/ansible-role-nginx/builds/189216001#L1713

It will be more : nginx_http_params: "{{ nginx_http_default_params }}"

@@ -38,7 +38,7 @@ nginx_extra_root_params: []
nginx_events_params:
- worker_connections {% if nginx_max_clients is defined %}{{nginx_max_clients}}{% else %}512{% endif %}

nginx_http_params:
nginx_http_default_params:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can put this variable in the file "vars/main.yml" instead, it should not be changeable by the user

@sysarcher
Copy link
Contributor Author

woops... sorry. I'll fix these asap . Did a quick/dirty job that fixed my issue and pull requested it naively.

@sysarcher
Copy link
Contributor Author

sysarcher commented Jan 6, 2017

I updated the pull request. Also pulled in your changes from yesterday.

@jdauphant jdauphant merged commit 37de6ef into jdauphant:master Jan 6, 2017
@jdauphant
Copy link
Owner

@shrmrf Thanks for your help

sysarcher pushed a commit to sysarcher/ansible-role-nginx that referenced this pull request Jan 6, 2017
Add `nginx_http_extra_params` variable in default vars (jdauphant#149)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants