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

Array sorted in python module #586

Closed
GillesBIANNIC opened this issue Nov 21, 2016 · 3 comments
Closed

Array sorted in python module #586

GillesBIANNIC opened this issue Nov 21, 2016 · 3 comments
Labels
beginner-friendly enhancement New feature or request

Comments

@GillesBIANNIC
Copy link

Hello,

In the python module, there is a template used to write config files for collectd.

https://github.com/voxpupuli/puppet-collectd/blob/master/templates/plugin/python/module.conf.erb#L7

Values are written in an order (with a sort). I understand : this is puppet's logic.
But, I think it shouldn't be like this for arrays (see line 7). We're loosing the array's order to an alphabetic order :/
This is a problem because the array in puppet's config is not the same in the file (order has been changed).
For my part, I removed the sort and replaced this code :

<%- if value.is_a?(Array) -%>
<%- value.sort.each do |v| -%>
...
<%- end -%>

By this :

<%- if value.is_a?(Array) -%>
<%- value.each do |v| -%> # no sort
...
<%- end -%>

in this file : https://github.com/voxpupuli/puppet-collectd/blob/master/templates/plugin/python/module.conf.erb#L7

Thanks for your attention,

Gilles

@petems
Copy link
Member

petems commented Nov 29, 2016

@GillesBIANNIC Is there a requirement to have the values in a specific order? Does it change the behaviour if it is ordered differently?

@GillesBIANNIC
Copy link
Author

Everywhere arrays are ordered, so I was very surprised when I discovered the alphabetic order.
We're using a plugin which reads some RegExs in a config file and apply them one by one (in the config order) on strings. If Puppet changes the order of the regexs in config, the result will not be the same :(

bastelfreak added a commit that referenced this issue May 20, 2018
Remove array sorting in python module template (#586)
@traylenator
Copy link
Contributor

The templates contain no sort anymore so this is presumably fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginner-friendly enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants