voxpupuli / puppet-nginx

Puppet Module to manage NGINX on various UNIXes
https://forge.puppet.com/puppet/nginx
MIT License
471 stars 881 forks source link

Do not re-order parameters in location_custom_cfg alphabetically #828

Closed hostingnuggets closed 8 years ago

hostingnuggets commented 8 years ago

I have some configuration parameters under location_custom_cfg which depend on a specific order to work correctly. Unfortunately the module re-orders my parameters alphabetically. Is it possible to avoid this re-ordering and just take the parameters in sequential order as I defined them? or do you see any other alternatives? My example config (taken from hiera) for this specific location is listed below.

nginx::nginx_locations:
 'php_files':
    priority: 503
    location: '~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/)'
    vhost: 'myvhost.com'
    ssl: true
    ssl_only: true
    location_custom_cfg:
      include: 'fastcgi_params'
      fastcgi_split_path_info: '^(.+\.php)(/.+)$'
      fastcgi_param:
        SCRIPT_FILENAME: '$document_root$fastcgi_script_name'
        PATH_INFO: '$fastcgi_path_info'
        HTTPS: 'on'
        modHeadersAvailable: 'true'
        front_controller_active: 'true'
      fastcgi_pass: 'phpfpm'
      fastcgi_intercept_errors: 'on'
      fastcgi_request_buffering: 'off'
3flex commented 8 years ago

This is tricky... https://github.com/jfryman/puppet-nginx/pull/532 introduced the ordering, and it's to work around https://tickets.puppetlabs.com/browse/PUP-1755 where official Puppet policy is that

There will never be any guarantees about the order of elements in a hash from the Puppet Language perspective.

To work around this, ordering by hash key was added to this module, so there would be a consistent, defined order for parameters. However, it does create problems like the above.

We can have a PR that adds raw_append to the empty.erb template. It's a hacky workaround but should allow you to do what you need.

A wishlist item for this module is to extend puppetlabs-concat support (see https://github.com/jfryman/puppet-nginx/issues/538) which would allow completely custom code to be added to the config files without having to dance around hiera. That's a much bigger task though.

hostingnuggets commented 8 years ago

@3flex thanks for your analysis, I would really be looking forward to a raw_append parameter where I could pass many nginx parameters in sequential order without any re-ordering. I think this is a reasonable workaround which could be implemented quite fast.

wyardley commented 8 years ago

vhost and location now both have $raw_append, so I think this can be closed.